/--- date: 2017-01-09 20:34:43 +0800 categories: 技术 ---/

LEMP环境搭建(三)website配置demo

一个默认配置demo

mkdir -p /home/www/cgi-bin  # 并创建一些测试文件
vim /usr/local/nginx/conf/conf.d/default.conf  #写入以下内容(去掉前面#),重启nginx查看效果

# server {
#     listen  80;
#     server_name _;
# 
#     root  /home/www/cgi-bin;
#     index index.html index.htm index.php;
# 
#     location / {
#         try_files $uri $uri/ =404;
#     }
# 
#     location ~ \.php$ {
#         try_files $uri =404;
#         #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#         fastcgi_pass 127.0.0.1:9000;
#         fastcgi_index index.php;
#         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#         include fastcgi_params;
#     }
# }

我的站点配置

mkdir -p /home/www/dingzhihao.org/{public_html,logs}
vim /usr/local/nginx/conf/conf.d/dingzhihao.org.conf  #写入以下内容(去掉前面#),重启nginx查看效果

# server {
#     listen  80;
#     server_name centos.dingzhihao.org;
#
#     access_log /home/www/dingzhihao.org/logs/access.log;
#     error_log /home/www/dingzhihao.org/logs/error.log;
#
#     root  /home/www/dingzhihao.org/public_html;
#     index index.php index.html index.htm;
#
#     location / {
#         rewrite (.*) /index.php;
#     }
#
#     location /ideas/wesaid/public_html {
#         rewrite (.*) /ideas/wesaid/public_html/index.php;
#     }
#
#     location ~* \.(html|js|css|jpg|jpeg|gif|png|swf)$ {
#         try_files $uri =404;
#     }
#
#     location ~ \.php$ {
#         fastcgi_split_path_info ^(.+\.php)(/.+)$;
#         fastcgi_pass 127.0.0.1:9000;
#         fastcgi_index index.php;
#         include fastcgi.conf;
#     }
# }

附1:参考

https://www.linode.com/docs/websites/lemp/lemp-server-on-centos-7-with-fastcgi https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 https://www.digitalocean.com/community/tutorials/how-to-configure-the-nginx-web-server-on-a-virtual-private-server http://nginx.org/en/docs/http/server_names.html