標籤:伺服器 wordpress 最新版 localhost
系統平台:CentOS 7 1611
WordPress
phpMyAdmin(CentOS 7 建議不要安裝最新版,否則需要編譯最新的php-fpm)
分別在三台主機上安裝httpd(192.168.1.200),php-fpm(192.168.1.201),mariadb(192.168.1.202),
並提供WordPress、phpMyAdmin應用
1、安裝並配置httpd伺服器
1.1 安裝httpd服務
[[email protected] ~]# yum install -y httpd
1.2 編輯httpd設定檔並建立虛擬機器主機
[[email protected] ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs[[email protected] ~]# vim /etc/httpd/conf/httpd.confServerName localhost:80#DocumentRoot "/www/wp.com/htdcos"<VirtualHost 192.168.1.200:80> ServerName www.wp.com DocumentRoot "/www/wp.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/wp.com/htdocs/$1 <Directory "/www/wp.com/htdocs/"> Options None AllowOverride None Require all granted </Directory></VirtualHost><VirtualHost 192.168.1.200:80> ServerName www.pma.com DocumentRoot "/www/pma.com/htdocs/" ProxyRequests off ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/pma.com/htdocs/$1 <Directory "/www/pma.com/htdocs/"> Options FollowSymLinks AllowOverride None Require all granted </Directory></VirtualHost>
2、安裝並配置php-fpm服務
2.1 安裝php-fpm、php-mbstring、php-mysql服務
[[email protected] ~]# yum -y install php-fpm php-mbstring.x86_64 php-mysql
2.2 修改php-fpm設定檔
[[email protected] ~]# vim /etc/php-fpm.d/www.conf listen = 0.0.0.0:9000 #表示監聽所有連接埠 ;listen.allowed_clients = 127.0.0.1 #注釋掉後,預設允許所有主機訪問
2.3 建立/wordpress和phpmyadmin的網頁檔案目錄,並將WordPress和phpmyadmin檔案放置在該檔案夾中
[[email protected] ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs
註:如果遇到phpmyadmin登入無反應,請嘗試下面操作:
[[email protected] pma]# mkdir /var/lib/php/session -pv[[email protected] pma]# chown -R apache.apache /var/lib/php/session/[[email protected] pma]# systemctl restart php-fpm.service
3、安裝配置mariadb服務
3.1 安裝mariadb服務(CentOS 7內建有mariadb服務,啟動即可)
[[email protected] ~]# yum -y install mariadb-server
[[email protected] ~]# systemctl start mariadb.service
3.2 建立資料庫並添加使用者、賦予許可權
MariaDB [(none)]> create database wp; MariaDB [(none)]> CREATE UESR ‘wp‘@‘%.%.%.%‘ IDENTIFIED BY ‘wppasswd‘; MariaDB [(none)]> GRANT ALL ON *.* TO [email protected]‘192.168.1.%‘ IDENTIFIED BY ‘wppasswd‘;
4、配置WordPress、phpMyAdmin
4.1 解壓下載的檔案並為phpmyadmin建立連結
[[email protected] wordpress]# unzip wordpress-4.7.4-zh_CN.zip [[email protected] wordpress]# unzip phpMyAdmin-4.0.10.20-all-languages.zip [[email protected] html]# ln -sv phpMyAdmin-4.0.10.20-all-languages pma
4.2 修改WordPress配置文件
[[email protected] html]# cd wordpress/ [[email protected] wordpress]# cp wp-config-sample.php wp-config.php [[email protected] wordpress]# vim wp-config.php define(‘DB_NAME‘, ‘wp‘); #資料庫名稱 define(‘DB_USER‘, ‘wp‘); #用於串連資料庫的使用者名稱 define(‘DB_PASSWORD‘, ‘wppasswd‘); #用於串連資料庫的密碼 define(‘DB_HOST‘, ‘192.168.1.202‘); #資料庫的路徑
4.3 修改phpMyAdmin的設定檔
[[email protected] wordpress]# cd /var/www/html/pma/[[email protected] pma]# cp config.sample.inc.php config.php[[email protected] pma]# openssl rand -base64 15 #組建組態檔案中所需的隨機數A42B1Noto1YiqQMC3DV7[[email protected] pma]# vim config.php$cfg[‘blowfish_secret‘] = ‘A42B1Noto1YiqQMC3DV7‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */$cfg[‘Servers‘][$i][‘host‘] = ‘192.168.1.202‘;
4.4 複製WordPress和phpMyAdmin到httpd伺服器上對應的路徑中
[[email protected] pma]# scp -P 22 /var/www/html/pma/* [email protected]:/var/www/html/pma[[email protected] pma]# scp -P 22 /var/www/html/wordpress/* [email protected]:/var/www/html/wordpress
本文出自 “7358072” 部落格,請務必保留此出處http://7368072.blog.51cto.com/7358072/1925398
CentOS 7 yum安裝lamp,三者位於不同伺服器,並為之安裝WordPress及phpmyadmin