Nginx
首先给默认的Nginx配置备个份,这是好习惯。目录位于/etc/nginx/sites-available/default
cp /etc/nginx/sites-available/default default.bak
然后Vim编辑
vim /etc/nginx/sites-available/default
server {
listen 80;
server_name www.isaced.com;
access_log /var/log/nginx/isaced.log;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
root /data/isaced; #Django项目
启动 nginx
sudo service nginx restart
三、配置 Nginx
先在服务器的 /etc/nginx/sites-available/ 目录下新建一个配置文件,文件名我一般就设置为域名。写上下面的配置内容:
/etc/nginx/sites-available/demo.zmrenwu.com server { charset utf-8; listen 80; server_name demo.zmrenwu.com; ① location /static { ② alias /home/yangxg/sites/demo.zmrenwu.com/django-blog-tutorial/static; } location / { ③ proxy_set_header Host $host; proxy_pass http://unix:/tmp/demo.zmrenwu.com.socket; } }
创建软链接:从 sites-available/ 目录下发送了一个配置文件的快捷方式到 sites-enabled/ 目录
sudo ln -s /etc/nginx/sites-available/demo.zmrenwu.com /etc/nginx/sites-enabled/demo.zmrenwu.com
网友评论