How to install nginx on CentOS 7

1. Install nginx

(1.1) Install nginx dependency packages

yum -y install gcc gcc- c++ pcre-devel openssl-devel wget

(1.2) If you encounter problems such as sleeping processes during the installation process, you can use kill 19161 to end the process ID or directly delete the pid (the third command can be executed in silent state)

rm -rf /var/run/yum.pid delete pid

kill 19161 ends the process

! yum re-execute the installation

(1.3) Download the nginx installation package. What I downloaded here is the nginx-1.12.2 version.

wget http://nginx.org/download/nginx-1.12.2.tar.gz  

(1.4) Unzip the compressed package of nginx-1.12.2 and enter the nginx-1.12.2 file directory

    tar xf nginx-1.12.2.tar.gz Decompress the nginx compressed package

   cd nginx-1.12.2 Enter the nginx-1.12.2 file directory

(1.5) Configure the detection environment and file directory in /usr/local/nginx

 ./configure --prefix=/usr/local/nginx

(1.6) Compile and install, you need to make a soft connection and restart nginx

 make && make install

 ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx

nginx

nginx -t 

ps -ef | grep nginx View nginx status

  

   (1.7) If you are prompted during the process of restarting nginx and the command is not found, you need to modify the environment variables ( skip if there is no prompt )

       vim /etc/profile   At the end of the profile file, add a line  PATH=$PATH:/usr/local/nginx/sbin

   Then restart the environment and    source /etc/profile.   Restart nginx -s reload.

 

(1.8) Just enter the local IP in the local browser. If the following prompt appears, it means success.

 2. Port-based mode

 (1.1) First create a www file directory in the root directory and enter the www directory

 

(1.2), here I used ppt to create a file to store index.html 

mkdir ppt

echo " https (the content can be written according to the individual)" >ppt/index.html data writing

(2.1), enter the nginx directory

cd /usr/local/nginx/conf      There may be a problem with the hand-entered input method.

(2.2), edit nginx.conf file

vim nginx.conf 

(2.3), modify the html to the www just created

(2.4) After editing is completed, just restart nginx, so that you can see the continued content in the local browser.

nginx -s reload

Guess you like

Origin blog.csdn.net/JYSCDNKB/article/details/129632162