LNMP结合discuz的配置

时间:2024-05-01 02:06:54

一、安装discuz

配置参照LAMP结合discuz的第一部分

不要忘记了 添加hosts~!!!!

===============我是分割线。==========================

二、nginx与discuz结合

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
//将server以及其对应的括号删除
...
...
server
{
listen ;
... {
...
}
}
//在最后一个括号前加入,让nginx能够执行vhosts文件夹里配置的conf
include /usr/local/nginx/conf/vhosts/*.conf;
} [root@localhost ~]# /usr/local/nginx/sbin/nginx -t
[root@localhost ~]# cd /usr/local/nginx/conf
[root@localhost conf]# mkdir vhosts
[root@localhost vhosts]# vim default.conf //配置虚拟主机
//加入内容
server
{
listen 80 default_server;
server_name 123.com;
index index.html index.htm index.php;
root /tmp/tmp;
} [root@localhost vhosts]# mkdir /tmp/tmp //测试
/*设置虚拟主机后,什么网站都是403*/
[root@localhost vhosts]# curl -x127.0.0.: www.baidu.com -I
HTTP/1.1 Forbidden
Server: nginx/1.4.
Date: Sun, Apr :: GMT
Content-Type: text/html
Content-Length:
Connection: keep-alive [root@localhost vhosts]# curl -x127.0.0.: www.qq.com -I
HTTP/1.1 Forbidden
Server: nginx/1.4.
Date: Sun, Apr :: GMT
Content-Type: text/html
Content-Length:
Connection: keep-alive //设置discuz
[root@localhost vhosts]# vim test.conf
server
{
listen ;
server_name test.com;
index index.html index.htm index.php;
root /data/www; location ~ \.php$ {
include fastcgi_params;
#fastcgi_pass unix:/tmp/php-fcgi.sock;
#这里常使用127.0.0.:9000来配置
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
[root@localhost vhosts]# /usr/local/nginx/sbin/nginx -t //检测
//还需要修改php-fpm
[root@localhost vhosts]# vim /usr/local/php/etc/php-fpm.conf
...
...
[www]
listen = /tmp/php-fcgi.sock //修改为 listen = 127.0.0.1:9000
...
...
[root@localhost vhosts]# /usr/local/php/sbin/php-fpm -t //检测是否有错误
[root@localhost vhosts]# service php-fpm restart
[root@localhost vhosts]# service nginx restart
[root@localhost vhosts]# curl -x127.0.0.: test.com -I
HTTP/1.1 Moved Permanently
Server: nginx/1.4.
Date: Sun, Apr :: GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.
location: install //success