-
在nginx.conf的配置文件中加入一行代码(将配置文件统一放入文件夹中管理)
include conf.d/*.conf
2.在conf.d这个文件夹中建立对应网址的配置文件,简单配置信息如下
server { listen 80; server_name www.meixincms.com; root /mnt/hgfs/www/meixincms/news-cms/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #先加载默认后解析赋值 include fastcgi_params; #正则解析路径 fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } #阻止svn/git泄露 location ~ /\.(ht|svn|git) { deny all; } #日志 error_log logs/error_log.logi debug; access_log logs/localhost.log ; }
3.在system32下的hosts目录 绑定相关域名和对应ip
4.在命令行模式下,输入nginx -s reload 重新加载nginx配置后,浏览器输入配置的域名即可访问
发表于2017-01-13 21:59 沙发
写的很不错,简单明了