ubuntu下如何安装与卸载nginx。
1、安装nginx 
 
复制代码 代码示例:
#sudo apt-add-repository ppa:nginx/development  
#sudo apt-get update  
sudo apt-get install nginx 
2、配置 
查询 nginx 配置文件位置 
 
复制代码 代码示例:
sudo vim /usr/share/nginx/www/index.html 
#sudo find / -name nginx.conf | less  
sudo vim /etc/nginx/nginx.conf 
在安装nginx之前已安装了apahe以及nexus,所以在后面直接加入,如果没有安装的忽略以下部分 
 
复制代码 代码示例:
upstream  nexus {  
   server 192.168.36.134:8081;  
}  
  
server {  
listen       80;  
server_name  192.168.36.134;  
  
location /nexus {  
   proxy_pass      http://nexus;  
   proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;  
   proxy_redirect off;  
   proxy_buffering 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;  
}
} 
测试配置问题: 
 
复制代码 代码示例:
$ sudo nginx -t  
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok  
nginx: configuration file /etc/nginx/nginx.conf test is successful 
3、启动nginx 
 
复制代码 代码示例:
sudo /etc/init.d/nginx start  
sudo nginx -s reload 
nginx在ubuntu下会被安装成service, 所以相应的起止办法是:
 
复制代码 代码示例:
sudo service nginx start|stop|restart 
卸载方法1. 
 
复制代码 代码示例:
sudo apt-get remove nginx # 删除nginx,保留配置文件  
rm -rf /etc/nginx #删除配置文件 
卸载方法2. 
 
复制代码 代码示例:
sudo apt-get purge nginx #删除nginx连带配置文件  
sudo apt-get autoremove #卸载不再需要的nginx依赖程序