1.lnmp架构的基础上保证php、nginx、mysql都开启服务
[root@server1 fpm]# /etc/init.d/mysqld start ##开启数据库
Starting MySQL.. SUCCESS!
[root@server1 fpm]# /etc/init.d/php-fpm start ##开启php
Starting php-fpm done
[root@server1 fpm]# nginx ##开启nginx
[root@server1 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 4121/nginx: master tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1132/php-fpm: maste
tcp6 0 0 :::3306 :::* LISTEN 1293/mysqld
1.设置nginx服务
修改nginx配置文件
[root@server1 lnmp]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
46 location / {
47 root html;
48 index index.html index.htm index.php;
49 }
68 location ~ \.php$ {
69 root html;
70 fastcgi_pass 127.0.0.1:9000;
71 fastcgi_index index.php;
72 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
73 include fastcgi.conf; #添加fastcgi,作为连接nginx和php的桥梁
74 }
2.解压论坛安装包到nginx共享目录:/usr/local/lnmp/nginx/html/
[root@server1 lnmp]# yum install -y unzip
[root@server1 lnmp]# unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/
如果文件权限不够无法安装:
[root@server1 upload]# cd /usr/local/lnmp/nginx/html/upload
[root@server1 upload]# chmod 777 -R uc_client/ uc_server/ data/ config/
[root@server1 html]# nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful
[root@server1 html]# nginx -s reload ##重新加载nginx配置文件
2.设置mysql服务
修改mysql中的data目录权限,由于nginx前端页面上的所有的数据都需要在数据库中进行读写,使用nginx用户的身份。所有该目录的必须对nginx可以读写。
[root@server1 mysql]# pwd
/usr/local/lnmp/mysql
[root@server1 mysql]# ll -d data/
drwxr-x--- 5 mysql mysql 263 Jun 30 23:11 data/
[root@server1 mysql]# chmod 775 /usr/local/lnmp/mysql/data/
[root@server1 mysql]# ll -d data/
drwxrwxr-x 5 mysql mysql 263 Jun 30 23:11 data/
3.设置php服务
修改php配置文件:
vim /usr/local/lnmp/php/etc/php.ini 解决php和数据库的连接问题:
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
[root@server1 mysql]# /etc/init.d/php-fpm reload
Reload service php-fpm done
此时lnmp搭建完成可以访问172.25.46.1/upload按照提示安装