您好,登錄后才能下訂單哦!
三臺主機部署lamp(fast-cgi)
實驗要求:
創建兩個虛擬主機web1,web2,分別跑phpMyadmin、wordpress ,且為phpMyadmin提供https服務。
三臺主機:
1.Cehtos7.2 跑httpd.2-4 一塊網卡 eno16777728 橋接模式 ip 172.16.254.79/16
2.centos7.2 跑php-fpm 一塊網卡eno16777728 橋接模式 ip 172.16.250.205/16
3.centos7.2 跑mariadb-server 一塊網卡 eno16777728 橋接模式 ip 172.16.252.180/16
三臺主機安裝所需的軟件包:
1.yum -y install httpd samba mod-ssl
2.Yum -y install php-fpm php-mysql cifs-utils php-mbstring
3.Yum -y install mariadb-server
Httpd主機的配置:
創建兩個虛擬站點的根目錄:
Mkdir /data/web{1,2} -pv
Chown apache:apache /data/web{1,2}
把這兩個目錄/data/web1,/data/web2 通過samba共享出去。
Vim /etc/samba/smb.conf[php]
comment=php data
path=/data/web1
browseable=yes
write list=apache
[wordpress]
comment=wordpress data
path=/data/web2
browseable=yes
write list=apache
Pdbedit -a -u apache
Passwdord 123456
啟動samba server
Systemctl start smb.service
Systemctl start nmb.service
創建兩個虛擬主機web1,web2的配置文件:
<VirtualHost 172.16.254.79>
ServerName www1.wudang.com
DocumentRoot /data/web1
DirectoryIndex index.php
ErrorLog logs/www1_error_log
CustomLog logs/www1_access_log combined
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.250.205:9000/data/web1/$1
<Directory /data/web1/>
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 172.16.254.79>
ServerName www2.shaolin.com
DocumentRoot /data/web2
DirectoryIndex index.php
ErrorLog logs/www2_error_log
CustomLog logs/www2_access_log combined
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.250.205:9000/data/web2/$1
<Directory /data/web2/>
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
下載 phpMyAdmin-4.4.14.1-all-languages.zip wordpress-4.3.1-zh_CN.zip
解壓兩個應用程序包到站點根目錄:
Unzip phpMyAdmin-4.4.14.1-all-languages.zip
Unzip wordpress-4.3.1-zh_CN.zip
創建兩個應用程序根目錄的軟連接文件:
Ln -svf /data/web1/ phpMyAdmin-4.4.14.1-all-languages /data/web1/mpa
Ln -svf /data/web2/wordpress /data/web2/wordpress
配置兩個應用程序與數據庫mariadb的連接:
cp /data/web1/mpa/config.sample.inc.php /data/web1/mpa/config.inc.php
Vim /data/web1/mpa/config.inc.php
$cfg['blowfish_secret'] = '1rnbfOvowLY6GA'; ----生成密鑰的隨機數
$cfg['Servers'][$i]['host'] = 'localhost';-------------mariadb主機地址
Cp /data/web2/wordpress/wp-config-sample.php /data/web2/wordpress/wp-config.php
Vim /data/web2/wordpress/wp-config.php
define('DB_NAME', 'wordpress');-------事先創建好的數據庫
/** MySQL數據庫用戶名 */
define('DB_USER', 'jack');-------- 管理數據庫的用戶名
/** MySQL數據庫密碼 */-----Jack用戶連接數據庫的密碼
define('DB_PASSWORD', '123456');
/** MySQL主機 */
define('DB_HOST', '172.16.254.79');-------mariadb數據庫的地址
啟動mariadb
Mariadb-server 主機的配置:
Systemctl strart mariadb.service
連接數據庫
Mysql
創建一個數據庫用戶:
Grant all on *.* to ‘jack’@’%’ identified by ‘123456’ ;
Flush privileges;
啟動httpd
Systemctl start httpd
Php-fpm主機的配置:
mkdir /data/web{1,2}
mkdir /data/web{1,2} -pv
mount.cifs -o username=apache //172.16.254.79/php /data/web
mount.cifs -o username=apache //172.16.254.79/wordpress /data/web2
mkdir /var/lib/php/session
chown apache:apache /var/lib/php/session
Vim /etc/php-fpm.d/www.conf
listen = 172.16.250.205:9000
; Default Value: any
#listen.allowed_clients = 127.0.0.1-----允許任何主機反代訪問
啟動php-fpm
Systemctl start php-fpm
http服務測試:測試機win7 hosts文件添加一條記錄
172.16.254.79 www1.wudang.com www2.shaolin.com
http://www1.wudang.com/mpa
http://www2.shaolin.com/wordpress
創建CA證書:
(umask 066; openssl genrsa -out private/cakey.pem 1024)
openssl req -new -x509 -key private/cakey.pem -days 3650 -out cacert.pem
創建站點phpMyadmin私鑰和證書:
(umask 066;openssl genrsa -out /etc/httpd/web1/php.key 1024) openssl req -new -key /etc/httpd/web1/php.key -days 365 -out /etc/httpd/web1/php.csr
openssl ca -in /etc/httpd/web1/php.csr -out certs/php.crt
Listen 443 httpsi
<VirtualHost 172.16.254.79:443>
DocumentRoot "/data/web1/"
ServerName www1.wudang.com:443
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.250.205:9000/data/web1/$1
SSLProtocol All -SSLv2
DirectoryIndex index.php
SSLEngine on
ErrorLog logs/www1_ssl_error_log
LogLevel warn
SSLCertificateFIle /etc/httpd/web1/php.crt
SSLCertificateKeyFile /etc/httpd/web1/php.key
<Directory /data/web1/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
把CA的證書導入到瀏覽器中的受信任的根證書機構。
https測試:
https://www1.wudang.com/mpa
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。