1. Install dependency packages
Yum -y install GCC zlib zlib-devel pcre-devel openssl openssl-develCopy the code
2. Download and decompress the installation package
Create a folder / / CD/usr/local mkdir nginx nginx/CD/download the tar packages wget tar XVF - http://nginx.org/download/nginx-1.19.5.tar.gz Nginx - 1.19.5. Tar. GzCopy the code
3. Install nginx
// Go to the nginx directory. CD /usr/local/nginx // Go to the directory. CD nginx-1.19.5 // Run the command installCopy the code
4. To configure nginx. Conf
# open configuration file/usr/local/vi nginx/conf/nginx. ConfCopy the code
Change the port number to 8089, because apeache may occupy port 80, apeache port should not be changed, we choose to change nginx port.
Change localhost to your server IP address.
5. Start the nginx
/usr/local/nginx/sbin/nginx -s reload
Copy the code
If there is an error: nginx: [error] open () “/ usr/local/nginx/logs/nginx pid” failed
Run: / usr/local/nginx/sbin/nginx – c/usr/local/nginx/conf/nginx. Conf
Start again!
Check whether the nginx process is started:
ps -ef | grep nginx
6. Disable the FIREWALL on the VM if you want to use an external host to connect to port 192.168.131.2.
CentOS6 and earlier versions run the systemctl stop iptables.service command
CentOS7 Run the systemctl stop firewalld.service command to disable the firewall
Then access that IP to see the Nginx interface.
7. Access the server IP address to check (note, because I am still listening to port 80, so the port number behind the IP is omitted)
Common commands used when the installation is complete
Go to the installation directory.
Run the CD /usr/local/nginx/sbin command
Start, close, restart, command:
. / nginx start
/nginx -s stop Closes the command
/nginx -s reload Restarts