ubuntu系統(tǒng)下,安裝
$ sudo apt-get install nginx
進(jìn)入/etc/nginx/sites-enabled 目錄,新建文件比如 hq
配置nginx患久,
內(nèi)容大致如下元咙, 具體什么意思,這個需要學(xué)習(xí)湃密, 供參考
server {
listen 80;
# listen 443 ssl;
ssl on;
ssl_certificate /mnt/ssl/fenguo.pem;
ssl_certificate_key /mnt/ssl/fenguo.key;
index index.html index.htm;
server_name hq.fourtrees.cn;
gzip on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css application/xml application/json;
client_max_body_size 200m;
location / {
root /mnt/fenguo/rate;
# proxy_pass http://127.0.0.1:8080;
# rewrite /api/(.*)$ /$1 break;
}
# 線上api
location /api {
proxy_pass http://127.0.0.1:8080;
rewrite /api/(.*)$ /$1 break;
}
}
然后移除默認(rèn)的配置
$ sudo rm default
測試配置文件是否生效
$ sudo service nginx configtest
如果錯誤的話诅挑,去這里查看
$ cat /var/log/nginx/error.log
其他日志
$ cat /var/log/nginx/access.log
啟動nginx
$ sudo service nginx start
重啟
$ sudo service nginx restart