This is the fifth day of my participation in the August More text Challenge. For details, see: August More Text Challenge

Install nginx

Under Centos, the yum source does not provide nginx installation. You can switch the YUM source to install nginx. You can also directly download the installation package and run the following commands with the root permission:

First install the necessary libraries (zlib for the Gzip module in Nginx, PCRE for the rewrite module, and OpenSSL for the SSL function). Select **/usr/local** as the installation directory. The following versions vary according to the actual conditions.

Install GCC GCC -c++

1. Download a package from the nginx official website at nginx.org/en/download…

2. WinSCP(FTP upload tool). Exe The FTP upload tool is uploaded to the CentOS

3, I first create a directory, to use the installation package to put together.

# CD nginx-1.4.1 # CD nginx-1.4.1 # CD nginx-1.4.1Copy the code

4. Install the PCRE development package

#yum install -y pcre-devel 
Copy the code

5, if the installation appears the following error is the lack of compilation environment. Install the tools and libraries needed to compile the source code

./configure: error: C compiler cc is not found 
#yum install gcc gcc-c++ ncurses-devel perl 
Copy the code

6, install cmake, download the source code from www.cmake.org, compile and install

#yum -y install make gcc gcc-c++ ncurses-devel 
#yum -y install zlib zlib-devel 
Copy the code

7. Openssl library is required if SSL function is required

#yum -y install openssl openssl-devel 
Copy the code

Install nginx

# # CD nginx - 1.4.1. / configure -- prefix = / usr/local/nginxCopy the code

Error message:

Error message 1:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
Copy the code

Solution:

Install pcre-devel yum -y install pcre-develCopy the code

Error message 2:

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
Copy the code

Solution:

Install zlib-devel yum install -y zlib-develCopy the code

Error message 3:

./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option. Yum -y install openssl openssl-develCopy the code

Installing an SSL Module

Note:

If "[emerg] 10464#0: Unknown directive "SSL" in/usr/local/nginx 0.6.32 / conf/nginx. Conf: 74 "show that no nginx did not install the SSL module. / configure --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --prefix=/usr/local/nginxCopy the code
#make 
#make install 
Copy the code

9. Start the service

#/opt/nginx/sbin/nginx  -c /opt/nginx/conf/nginx.conf 
Copy the code

10. Stop the service

 #/opt/nginx/sbin/nginx -s stop 
Copy the code

11. Check whether the port is occupied

#netstat -tunlp 
Copy the code

12. If other machines cannot access, the solution is as follows:

#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 
Copy the code

Then save:

#/etc/rc.d/init.d/iptables save 
Copy the code

Restarting the Firewall

#/etc/init.d/iptables restart
Copy the code