Recently bought a CentOS environment server, in the configuration nginx a little problem, after a search finally solved the problem. The following is the installation configuration process: First, the preparatory work
1, the installation of Nginx depends on the following three packages, so before the installation to prepare the following three packages:
SSL function requires OpenSSL library, download address: http://www.openssl.org/
Gzip module requires zlib library, download address: http://www.zlib.net/
Rewrite module needs pcre library, download address: http://www.pcre.org/
2, prepare Nginx installation package: Download Address: http://nginx.org/en/download.html
3, (through WINSCP or other means) will download a good 4 packages uploaded to the server, my upload path is:/usr/local
4, the installation process requires the use of C + + compilation environment, installation commands are as follows:
Yum install-y gcc gcc-c++
second, the installation of SSL function requires OpenSSL library
1. TAR-ZXVF openssl-1.0.2n.tar.gz
2 cd openssl-1.0.2n
3./config
4. Make
5. Make install
If there is no error, install complete Three, install the Zlib library required by the GZIP module
1. TAR-ZXVF prce-8.38.tar.gz
2 cd prce-8.38
3./configure
4. Make
5. Make install
If there is no error, install complete four, install rewrite module need pcre library
1. TAR-ZXVF zlib-1.2.11.tar.gz
2 cd zlib-1.2.11
3./configure
4. Make
5. Make install
If there is no error, install the nginx service
1. TAR-ZXVF nginx-1.12.2.tar.gz
2 cd nginx-1.12.2
3 .../configure--with-pcre=. /pcre-8.38/--with-zlib=. /zlib-1.2.11/--with-openssl=. /openssl-1.0.2n/
4. Make
5. Make install
Step 3rd./configure The following parameter is the relative path of the three libraries previously installed
If there is no error, install completes six, start Nginx
If you have already performed this step, the Nginx has all been installed complete
/usr/local/nginx/sbin/nginx-t
If the following illustration shows, the configuration has been successfully installed.
If no permissions are present (Permission denied), you need to assign permissions to the file
Chmod-r 777/usr/local/nginx
Start Nginx
/usr/local/nginx/sbin/nginx
Vii. detect whether the Nginx has started successfully
View Nginx process number and operation
Ps-ef | grep nginx
To view the Nginx process listening port
NETSTAT-NTLP | grep 80
Links is a web browser that runs in command line mode and can only view characters.
installation command: Yum Install links
Bring command links test from Linux
Links 127.0.0.1
If Welcome to Nginx appears. Nginx service startup Success Viii. problem and solution if there is no permission (Permission denied), you need to assign permissions to the file
Chmod-r 777/usr/local/nginx
If the external environment is not accessible, see if port 80 is open
You can turn off the attempt firewall or change the firewall configuration
Service iptables stop//shutdown firewall
vim/etc/sysconfig/iptables//Edit profile
/etc/init.d/iptables restart//reboot firewall
Service iptables status/view firewall state
If the firewall is closed or 80 ports have been opened, but the external environment is still inaccessible, you can look at the security group configuration of the server and allow 80 ports
Nine, boot from start Nginx
First, Rc.local is the last script that Linux launcher executes before the login program
Vim/etc/rc.local
After opening the rc.local in the/etc directory, it is found that the top three lines have the default annotation:
This script is executed after all the other init scripts.
Can put your own initialization stuff with If you don ' t
Want to does the full Sys V style init stuff.
English is not very good, it does not translate, but it is obvious that nginx can be added to the launch command here:/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
Of course, you can also execute the command line directly and add the startup command to the/etc/rc.local
echo "/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf" >>/etc/rc.local
After restarting (shutdown-r now), you will find that Nginx has been activated.
Above, there are questions to add.
Copyright NOTICE: This article is the main original article, without the owner's permission not to reprint
http://blog.csdn.net/qq_39241443/article/details/79451433