yum install httpd
安裝成功後,apache操做命令:php
systemctl start httpd //啓動apache systemctl stop httpd //中止apache systemctl restart httpd //重啓apache systemctl enable httpd //設置apache開機啓動
外部對其訪問時還須要對防火牆進行配置以下。html
CentOS 7.0默認使用的是firewall做爲防火牆,這裏改成iptables防火牆。mysql
1.關閉firewall:linux
systemctl stop firewalld.service //中止firewall服務 systemctl disable firewalld.service //禁止firewall開機啓動
2.安裝iptables防火牆sql
yum intall iptables-services //安裝 vim /etc/sysconfig/iptables //編輯防火牆配置文件 # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT :wq! #保存退出 systemctl restart iptables.service //最後重啓防火牆使配置生效 systemctl enable iptables.service //設置防火牆開機啓動
3.關閉SELINUXshell
vim /etc/selinux/config #SELINUX=enforcing #註釋掉 #SELINUXTYPE=targeted #註釋掉 SELINUX=disabled #增長 :wq! #保存退出 setenforce 0 //使配置當即生效
這時候restart一下apache服務,輸入localhost以後,會出現apache的測試頁面testing 123..數據庫
yum install mariadb mariadb-server
mariadb安裝成功後,須要配置mysql的root密碼,先備註一下經常使用命令:apache
systemctl start mariadb //啓動MariaDB systemctl stop mariadb //中止MariaDB systemctl restart mariadb //重啓MariaDB systemctl enable mariadb //設置開機啓動
設置root帳戶密碼vim
mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n]centos點擊回車而後提示是否設置root帳號密碼,輸入y
New password:
Re-enter new password:
Password updated successfully!提示輸入新密碼和重複輸入新密碼,重複輸入兩次後,出現更新密碼成功提示。
而後一路輸入y就能夠
Remove anonymous users? [Y/n] y
... Success!Disallow root login remotely? [Y/n] y
... Success!Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!Reload privilege tables now? [Y/n] y
... Success!Thanks for using MariaDB!
設置root密碼後,重啓mariadb生效
systemctl restart mariadb.service
測試訪問數據庫:
mysql -uroot -p
而後輸入密碼,登陸成功後顯示以下:
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB ServerCopyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>
輸入以下命令,查看數據庫服務器的數據庫
show databases;
退出命令
exit;
yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
安裝完成後,重啓apache服務器
systemctl restart httpd.service
測試php安裝結果
vim /var/www/html/index.php
輸入以下內容
<?php phpinfo(); ?> :wq!保存
在瀏覽器中輸入服務器地址,查看是否能夠看到:php的版本信息以及其餘具體信息頁面。
·1.用ftp工具將wordpress文件夾直接transfer到服務器/var/www目錄下,這時候在瀏覽器中訪問127.0.0.1/wordpress(ip地址爲服務器ip能夠看到wordpress的五分鐘安裝界面。
Q&A
第一步:先用ssh,打開php.ini
vim /etc/php.ini
第二步:php.ini中 添加
extension=mysql.so
第三步:在php.ini 中找到以下
extension_dir="xxxxxxx" 注: xxxxxxx指擴展安裝目錄,centos64位的主機通常安裝在extension_dir = "/usr/lib64/php/modules"
第四步:找到這個擴展安裝目錄,確認是否有mysql.so這個文件,若是沒有,下載
重啓服務。
不過mysql.so這個文件應該不是直接能夠yum的,我在有這個問題的時候發現是沒有安裝php-mysql擴展,裝上以後重啓服務應該就沒問題了。
2.這時候要在mysql中建立一個wordpress數據庫才能保證wordpress安裝成功,不過若是配置不成功,也不要緊,能夠後續操做wp-config-sample.php在其中手動輸入相關信息改動文件名爲wp-config.php便可。
新建數據庫指令以下,不要忘記加結尾的分號;
create database wordpress;
ps.
不過在訪問站點的時候,你可能會碰到新的問題,好比你沒法上傳自定義的圖片。
Q&A
確認擁有上傳目錄uploads,如沒有則手動建立一個目錄;
wordpress擁有對文件夾的操做權限,給文件夾賦權,在建立文件夾的時候勾選write和子文件夾賦權選項;
在數據庫中wp-options表中設置upload_path的值爲wp-content/uploads不須要加雙引號,能夠看到我上面的錯誤就是加了雙引號
其中第三步對數據庫進行操做咱們能夠在phpmyadmin中直接修改。
yum install epel-release yum install phpmyadmin php-mcrypt
phpmyadmin的默認安裝目錄是/usr/share/phpMyAdmin,同時會在 Apache 的配置文件目錄中自動建立虛擬主機配置文件 /etc/httpd/conf.d/phpMyAdmin.conf(區分大小寫)。默認狀況下,CentOS 7上的phpMyAdmin只容許從迴環地址(127.0.0.1)訪問。爲了能遠程鏈接,你須要改動它的配置。
<Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> # Require ip 127.0.0.1 #註釋掉 # Require ip ::1 #註釋掉 Require all granted #新添加 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> #Require ip 127.0.0.1 #註釋掉 #Require ip ::1 #註釋掉 Require all granted #新添加 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>
而後重啓apache服務器,就能夠經過ip地址/phpmyadmin訪問數據庫了。