卸载apache
service apache2 stop
service apache stop update-rc.d -f apache2 remove apt-get remove apache2
安装nginx
apt-get install nginx
nginx配置文件在/etc/nginx/conf.d文件夹内
配置nginx
cd /etc/nginx/conf.dvi 文件名称.conf
添加转发端口
upstream test{ //此处最好刚起的文件名称相同,便于后需修改,下面代码需要用到此名称 server 127.0.0.1:9000;}server { listen 80; server_name xxx.yyy.com //监听的域名 location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_pass http://test;//与上面的设置名称要相同 proxy_redirect off; }}
也可以省略upstream定义,直接在location定义server端口
server { listen 80; server_name xxx.yyy.com //监听的域名 location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_pass http://127.0.0.1:9000; proxy_redirect off; }}
修改完配置文件执行
nginx -s reload
完成