uwsgi配置文件路径:/root/script/uwsgi.ini
nginx根目录:/etc/nginx
nginx默认配置文件:/etc/nginx/nginx.conf
项目自定义配置文件:/etc/nginx/conf.d/project.conf
php
1.uwsgi配置html
# uwsig使用配置文件启动 [uwsgi] # 项目目录 chdir=/root/project # 指定项目的application module=project.wsgi:application # 指定sock的文件路径 socket=/root/ctguinfowork/script/uwsgi.sock # 进程个数 workers=5 pidfile=/root/script/uwsgi.pid # 指定IP端口 http= :8080 # 指定静态文件,这个项目中没有,若是你的项目中有静态文件的话按这个目录结构配置 static-map=/static=/root/project/static # 启动uwsgi的用户名和用户组 uid=root gid=root # 启用主进程 master=true # 自动移除unix Socket和pid文件当服务中止的时候 vacuum=true # 序列化接受的内容,若是可能的话 thunder-lock=true # 启用线程 enable-threads=true # 设置自中断时间 harakiri=30 # 设置缓冲 post-buffering=4096 # 设置日志目录 daemonize=/root/script/uwsgi.log
2.启动uwsgi
启动uwsgi就比较简单(若是没有报错的话):uwsgi --ini /root/script/uwsgi.ini
启动成功后理论上来讲就能够在浏览器栏输入ip:port
来访问项目了,port为uwsgi中配置的端口node
3.1自定义配置nginx
upstream project{ server 47.100.118.99:8080; } server { listen 80; #监听端口 server_name 47.100.118.99; #访问地址,这里比较坑,填什么就映射什么,若是你填localhost、127.0.0.1之类的,就意味着你只能在本机浏览器上访问,由于别人在本身电脑输入127.0.0.1就不是你了 access_log /var/log/nginx/project.access.log main; #普通日志 error_log /var/log/nginx/project.error.log; #错误日志 #root html; #index index.html index.htm index.php; location / { proxy_pass http://project; #这里http后等于第一行配置的名字 #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; }
3.2 默认配置文件浏览器
默认配置文件基本上不用配置,保证其http{}里面包含上面的自定义文件就行了。app
user root; #这里改为root,由于默认nginx用户可能没有权限访问你的静态文件 worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; #保证配置文件含有咱们的自定义配置,其它路径也能够 }