0%

ubuntu下nginx安装使用

apt包源安装

下载

1
sudo apt install nginx

查看版本

1
nginx -v

查看安装位置

1
whereis nginx

输出信息

1
2
3
4
5
6
nginx:
/usr/sbin/nginx
/usr/lib/nginx
/etc/nginx
/usr/share/nginx
/usr/share/man/man8/nginx.8.gz

卸载

1
2
sudo apt purge  nginx nginx-common
sudo autoremove

使用

1
2
3
sudo service nginx start
sudo service nginx stop
sudo service nginx restart

安装包安装

下载

官网下载需要的版本:
http://nginx.org/en/download.html

解压

1
tar -zxvf nginx-1.14.2.tar.gz

编译安装

1
2
3
4
cd nginx-1.14.2
./configure --prefix=/home/environment/nginx/
make
make install

验证

1
/home/environment/nginx/sbin/nginx -t

使用

启动:

1
/home/environment/nginx/sbin/nginx -c /home/environment/nginx/conf/nginx.conf

关闭:杀进程