机器名称 | 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
?部署完成
|