将服务全部正常开启:
[root@server5 fpm]# netstat -antlp # 查看端口开启情况
php:9000
nginx:80
mysql:3306
[root@server5 fpm]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5356/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 682/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 775/master
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14908/php-fpm: mast
tcp 0 0 172.25.7.5:22 172.25.7.250:46956 ESTABLISHED 2455/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 15083/mysqld
tcp6 0 0 :::22 :::* LISTEN 682/sshd
tcp6 0 0 ::1:25 :::* LISTEN 775/master
nginx、mysql、php均正常开启,端口正常
1 、设置nginx服务
1 修改nginx配置文件
cd /usr/local/lnmp/nginx/conf/
vim nginx.conf
#nginx配置文件中 http部分中的server 添加识别php文件
location / {
root html;
index index.php index.html index.htm;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts $fastcgi_script_name;
include fastcgi.conf; # 添加fastcgi,作为一个连接nginx和php的桥梁
}
2 下载论坛安装包并且解压到nginx共享发布目录中:/usr/local/lnmp/nginx/html/
[root@server5 html]# cd /root/lnmp/
[root@server5 lnmp]# unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/
[root@server5 html]# ls
50x.html index.html readme upload utility
3 设置解压出来的论坛文件的权限:由于解决文件权限不够,导致无法进行安装
[root@server5 ~]# cd /usr/local/lnmp/nginx/html/upload/
[root@server5 upload]# ls
admin.php connect.php forum.php member.php search.php uc_server
api cp.php group.php misc.php source userapp.php
api.php crossdomain.xml home.php plugin.php static
archiver data index.php portal.php template
config favicon.ico install robots.txt uc_client
[root@server5 upload]# chmod 777 -R uc_client/ uc_server/ data/ config/
4 重新加载nginx配置: nginx -s reload
2 、设置mysql服务
需要修改mysql中的data目录的权限,由于nginx前端页面上的所有的数据都需要在数据库中进行读写。使用nginx用户的身份。所有该目录的必须对nginx可以读写。
[root@server5 mysql]# ll -d data/
drwxr-x--- 5 mysql mysql 259 Jun 30 23:13 data/ # 该目录的所有者和所有均为mysql
[root@server5mysql]# chmod 775 /usr/local/lnmp/mysql/data/
[root@server5 mysql]# ll -d data/
drwxrwxr-x 5 mysql mysql 259 Jun 30 23:13 data/
3 、设置php服务
修改php配置文件:
vim /usr/local/lnmp/php/etc/php.ini 解决php和数据库的连接问题:
#修改以下三行。填写完整的数据库sock文件路径
1013 pdo_mysql.default_socket= /usr/local/lnmp/mysql/data/mysql.sock
1162 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
1221 mysqli.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
重新加载php配置: /etc/init.d/php-fpm reload
到此lnmp搭建完成,可以通过 访问http://172.25.7.5/upload 按照提示进行论坛安装。