Uninstall all nginx under linux, reinstall and run

Because the previous download was too messy, I found the relevant directory for a long time to find the wrong location, so I decided to uninstall nginx and reinstall it
. The first thing to do is to execute the following command to uninstall all nginx

rm -rf /etc/nginx/
rm -rf /usr/sbin/nginx
rm /usr/share/man/man1/nginx.1.gz
sudo apt-get remove nginx*

insert image description here
After the uninstallation is complete, find a relatively clean directory to install nginx. I usually install it in the /usr/local/src directory by default.

//0. 进入要安装的目录
cd /usr/local/src/
//1. 下载
sudo wget http://nginx.org/download/nginx-1.10.2.tar.gz
//2. 解压
sudo tar -xvf nginx-1.10.2.tar.gz
# 重命名(之前的名字带版本号太长)
sudo mv  nginx-1.10.2  nginx

At this point we look at the current directory, there are the following files
insert image description here
and then need to configure, compile and install

cd nginx
sudo ./configure
//执行./configure时很有可能失败,因为会缺少一些安装包,,
//这时候它需要什么再去下载就好了。直到成功执行完该条命令。
sudo make
make install

Next is to run nginx.
We can first find the nginx configuration file

sudo find / -name nginx.conf

You can enter those directories separately, we need to find the directory with sbin, because sbin stores the runnable nginx.

insert image description here
We need to enter sbin and then execute nginx

sudo ./nginx

Then the browser accesses your ip address, the following means the startup is successful!
insert image description here

Guess you like

Origin blog.csdn.net/changyana/article/details/123452943