lnmp
nginx配制虚拟域名
nginx默认站点目录是:/usr/share/nginx/html/
权限设置:chown nginx.nginx/usr/share/nginx/html/ -R
MySQL数据库目录是:/var/lib/mysql
权限设置:chown mysql.mysql -R /var/lib/mysql
/etc/nginx/conf.d 建立一个 虚拟域名 如:www.yii.cc.conf
配制内容如下:
server {
listen 80;
server_name www.yii.cc;
index index.php index.html;
#root /usr/share/nginx/html/basic/web;
root /usr/share/nginx/html/yii;
#access_log /www/access_ example1.log main;
location / {
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
第二:/etc/nginx => nginx.conf 下面配制:
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
重启 nginx
1. /etc/init.d/nginx restart
2.平滑重启命令:kill -HUP 住进称号或进程号文件路径或者使用/usr/nginx/sbin/nginx -s reload注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf或者/usr/nginx/sbin/nginx -t
3.nginx reload重启执行# /usr/local/nginx/sbin/nginx -s reload nginx已经重启成功用root权限 重启#killall nginx#nginx
4.Ubuntu Nginx$sudo service nginx start$sudo service nginx stop