ubuntu系统下,安装
$ sudo apt-get install nginx
进入/etc/nginx/sites-enabled 目录,新建文件比如 hq
配置nginx,
内容大致如下, 具体什么意思,这个需要学习, 供参考
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;
}
}
然后移除默认的配置
$ 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