1. Download Nginx from the official website
2. Unzip the file
tar -zxvf nginx-1.20.2.tar.gz
3. Configure nginx
Execute the command in the directory /usr/local/nginx/nginx-1.20.2
./configure
Execute the make command again
make
If an error is reported
make: *** No rule to make target
build
, needed bydefault
. Stop.
Solution
You need to install openssl and ncurses components and enter the following commands in order
yum install -y openssl*
yum -y install ncurses-devel
After installation, you need to re-execute ./configure under the current file
./configure #先执行
make #执行完./configure之后,敲make回车
make install #确认是否安装成功(可执行可不执行,没有影响)
4. Start nginx
It is generally installed in the /usr/local/nginx directory on the Linux virtual machine. You can search
whereis nginx #查找nginx文件
cd /usr/local/nginx #进入该文件
Start the nginx file in the sbin/ directory
cd ./sbin #进入sbin文件
./nginx #启动nginx程序
If no error is reported, the startup is successful.
This shows that it was successful
5. Commonly used commands
./nginx -s stop #停止nginx
./nginx -s quit #安全退出
./nginx -s reload #修改了文件之后重新加载该程序文件
ps aux|grep nginx #查看nginx进程