| 機器名稱 | IP | 服務 |
| c7--11 | 192.168.2.11/24 | nginx |
| c7--10 | 192.168.2.10/24 | PHP |
| c7--09 | 192.168.2.9/24 | MySQL |
一、部署nginx服務
在07--11上
部署nginx的步驟在這個文獻中:https://blog.csdn.net/KW__jiaoq/article/details/121375382
[root@C7--11 ~]# nginx -V
nginx version: nginx/1.18.0
安裝完成后配置nginx.conf檔案
[root@C7--11 ~]# vim /usr/local/nginx/conf/nginx.conf
.......
....
location / {
root /html; #這是本地nginx訪問頁面
index index.php index.html index.htm;
}
location ~ \.php$ {
root /html; #PHP服務器上的目錄
fastcgi_pass 192.168.2.10:9000; #指向PHP服務地址及埠
fastcgi_index index.php; #會查詢index.php檔案
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #變數
include fastcgi_params;
}
...........
.....
保存
[root@C7--11 ~]# vim /usr/local/nginx/conf/fastcgi_params
........
....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #在哪里添加都可以
保存
[root@C7--11 ~]# nginx -s reload
二、部署MySQL資料庫
在c7--09上
部署MySQL服務的文獻在:https://blog.csdn.net/KW__jiaoq/article/details/119994518
[root@C7--09 ~]# mysql -uroot -p123
..........
.....
mysql> quit
Bye
三、部署PHP
在c7--10上
上傳軟體包 libmcrypt-2.5.8.tar.gz php-5.5.38.tar.gz
[root@C7-10 ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel epel-release gcc gcc-c++
[root@C7-10 ~]# groupadd -r -g 955 php
[root@C7-10 ~]# useradd -M -s /sbin/nologin -g 955 -u 955 php
[root@C7-10 ~]# tar zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/
....................
[root@C7-10 ~]# cd /usr/src/libmcrypt-2.5.8/
[root@C7-10 libmcrypt-2.5.8]# ./configure && make && make install
[root@C7-10 libmcrypt-2.5.8]# cd
[root@C7-10 ~]# tar zxvf php-5.5.38.tar.gz -C /usr/src/
[root@C7-10 ~]# cd /usr/src/php-5.5.38/
[root@C7-10 php-5.5.38]# ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts && make && make install
.....................................
..............................
.......................
...........
..... #時間較長...... 安裝完成后顯示以下內容
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
[root@C7-10 php-5.5.38]# echo 'export PATH=/usr/local/php/bin:$PATH' > /etc/profile.d/php.sh
[root@C7-10 php-5.5.38]# source /etc/profile.d/php.sh
[root@C7-10 php-5.5.38]# cp php.ini-production /etc/php.ini
[root@C7-10 php-5.5.38]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@C7-10 php-5.5.38]#
[root@C7-10 php-5.5.38]# cd /usr/local/php/etc/
[root@C7-10 etc]# cp php-fpm.conf.default php-fpm.conf
[root@C7-10 etc]# vim php-fpm.conf
...........
....
40 ;ility = daemon #在前面添加;
....
149 user = php
150 group = php
.....
..
165 listen = 192.168.2.10:9000 #本地地址
.....
...
231 pm.max_children = 60
.....
..
236 pm.start_servers = 6
...
..
241 pm.min_spare_servers = 3
.......
...
246 pm.max_spare_servers = 6
保存
[root@C7-10 etc]# chmod 777 /etc/init.d/php-fpm -R
[root@C7-10 etc]# service php-fpm start #啟動php
Starting php-fpm done
[root@C7-10 etc]# netstat -auptn|grep php
tcp 0 0 192.168.2.10:9000 0.0.0.0:* LISTEN 76265/php-fpm: mast
或者
[root@C7-10 etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 192.168.2.10:9000 *:*
........
創建訪問頁面
[root@C7-10 etc]# cd
[root@C7-10 ~]# mkdir /html
[root@C7-10 ~]# chown -R php:php /html/
[root@C7-10 ~]# vim /html/index.php
<?php
phpinfo();
?>
保存
[root@C7-10 etc]# service php-fpm restart #重啟php
Gracefully shutting down php-fpm . done
Starting php-fpm done
四、進行訪問測驗
訪問:http://192.168.2.11/

http:192.168.2.11/index.php

五、部署社區論壇
1、 在c7--09上MySQL資料庫進行授權
或者可以部署 wordpress論壇;注意:如果版本過高那么PHP也需要安裝高版本
下載鏈接:版本發布 | WordPress.org China 簡體中文
[root@C7--09 ~]# mysql -uroot -p123
.......
...
mysql> create database sqlt;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on sqlt.* to 'admin'@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)
.....
..
退出即可
2、在c7--10上,上傳Discuz_X3.3_SC_UTF8.zip
[root@C7-10 ~]# ls
Discuz_X3.3_SC_UTF8.zip
[root@C7-10 ~]# unzip Discuz_X3.3_SC_UTF8.zip
[root@C7-10 ~]# mv upload/* /html
[root@C7-10 ~]# chmod 777 /html/ -R
3、在c7--11上同樣
[root@C7--11 ~]# unzip Discuz_X3.3_SC_UTF8.zip
[root@C7--11 ~]# mv upload/* /html/
[root@C7-10 ~]# chmod 777 /html/ -R
訪問測驗:192.168.2.11

部署完成
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/374667.html
標籤:其他
上一篇:RIP的防環機制詳解
