Ubuntu--nginx配置虚拟主机
来源:互联网 发布:兴城淘宝美工招聘 编辑:程序博客网 时间:2024/05/17 07:18
假定我们的虚拟主机存放目录为var/www/exp
创建nginx虚拟主机www.exp.com
文件配置(PHP域根据本机的PHP应用情况配置)
vim /etc/nginx/sites-available/www.exp.com
#Log Format log_format access_exp '$time_iso8601 | $remote_addr | $request | $status | $request_body | $http_referer | $http_user_agent | $http_x_forwarded_for'; server { listen 80; root /var/www/exp/web; index index.php index.html index.htm; server_name www.exp.com; # log access_log /var/log/nginx/www.exp.com.access.log access_exp; error_log /var/log/nginx/www.exp.com.error.log; #location /www.exp.com/ { location / { #try_files $uri $uri/ /www.exp.com/index.php?$args; try_files $uri $uri/ /index.php?$args; client_max_body_size 10m; } location ~ /(protected|\.git|framework|nbproject|themes/\w+/views|index-test\.php) { deny all; } location = /favicon.ico { log_not_found off; access_log off;} location = /robots.txt { log_not_found off; access_log off; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)\$ { expires max; log_not_found off; access_log off; } location ~ /\.ht { deny all; } location ~ \.php\$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
因为nginx的的主配置文件nginx.conf会自动应用启用的站点 - 中的配置文件,所以我们需要在启用网站-中建立一个www.exp.com
文件的链接
cd /etc/nginx/sites-enabledln -s ../sites-available/www.exp.com www.exp.com
重新加载nginx的使配置生效 nginx -s reload
至此,nginx虚拟主机就已配置完成,可在浏览器中访问测试。
在部署项目的过程中需要主要以下几点:
- 确保项目的缓存文件如css js 有相应的rwx权限
- 确保项目的日志文件有相应的rwx的权限
确保web/index.php在项目部署的过程中不会被git给过滤
附上参考文章链接:http://blog.csdn.net/stwstw0123/article/details/47122191
阅读全文
0 0
- Ubuntu--nginx配置虚拟主机
- Ubuntu nginx配置虚拟主机
- Ubuntu之nginx配置虚拟主机vhost
- Nginx 配置虚拟主机
- nginx配置虚拟主机
- 【NGINX】虚拟主机配置示例
- Nginx虚拟主机配置教程
- Nginx 虚拟主机 VirtualHost 配置
- Nginx虚拟主机配置教程
- nginx配置虚拟主机
- nginx配置+虚拟主机
- Nginx虚拟主机配置
- Nginx 虚拟主机 VirtualHost 配置
- nginx虚拟主机配置实例
- Nginx 虚拟主机 VirtualHost 配置
- Nginx 虚拟主机 VirtualHost 配置
- nginx多虚拟主机配置
- Nginx的虚拟主机配置
- Mac显示隐藏文件夹
- C语言 高速公路超速处罚
- c++位操作符
- 安卓实现多方分享资源 intent
- 获取原图宽高
- Ubuntu--nginx配置虚拟主机
- Flutter实战一Flutter聊天应用(十二)
- 2017-6-27(SVN安装与插件)
- Android-Rxjava+Retrofit2.x 获取Http状态码、响应头(Headers)等数据
- html 页面的生命周期内 四个重要的event(DOMContentLoaded, load, beforeunload, unload)
- Zookeeper安装与配置
- meizu魅族适配
- CSS之深入理解 flex 布局以及计算
- C++----范型算法