启动
./nginx
重启
./nginx -s reload
配置nginx:
#集群配置
upstream my-server {
server localhost:8081;
server localhost:8082;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/local/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
proxy_pass http://my-server/;
}
查看占用的端口:
netstat -tunlp | grep 8081
杀死占用端口的进程:
kill -9 16718(进程号)
设置开机启动:
cd /etc
vi /etc/rc.local
增加命令行:
/usr/local/nginx/sbin/nginx
/usr/local/tomcat/bin/startup.sh
/usr/local/redis/redis-server /usr/local/redis/redis.conf
保存后,设置执行权限:
chmod 755 rc.local