I. Prepare the environment
1. Install gcc
Yum install GCC gcc-C ++
2. Install PCRE
To make sure that you can use regular expressions in nginx for more flexible configuration, You need to determine whether the PCRE (Perl Compatible Regular Expressions) package is installed in the system before installation.
Download pcre-8.20.tar.gz, address: http://sourceforge.net/projects/pcre/files/pcre/, upload to/usr/local, installation directory:/usr/local/PCRE
# Mkdir-P PCRE
# Tar zxvf pcre-8.20.tar.gz
# Cd pcre-8.20
#./Configure -- prefix =/usr/local/PCRE
# Make
# Make install
2. install nginx
download nginx-0.8.54.tar.gz, address: http://nginx.org/en/download.html, upload to/usr/local, installation directory: /usr/local
2. 1. install
# tar zxvf nginx-0.8.54.tar.gz
# mv nginx-0.8.54 nginx
# cd nginx-0.8.54
#. /configure -- sbin-Path =/usr/local/nginx -- conf-Path =/usr/local/nginx -- PID-Path =/usr/local/nginx -- The with-http_ssl_module --- PCRE =/usr/local/pcre-8.20
# Make
# make install
2. Check whether nginx is successfully installed.
# Cd/usr/local/nginx/sbin
#./Nginx-T
Result:
Nginx: the configuration file/usr/local/nginx/CONF/nginx. conf syntax is OK
Nginx: configuration file/usr/local/nginx/CONF/nginx. conf test is successful
2. 3. Start nginx
# Cd/usr/local/nginx/sbin
#./Nginx
. Check whether startup is successful
Enter http: // ip (Linux) in the IE browser of the Client)
Parameters:
-- With-PCRE =/usr/local/pcre-8.20 refers to the source code path of the pcre-8.20, not the installation path.
After successful installation, the/usr/local/webserver/nginx directory contains four subdirectories: Conf, HTML, logs, and sbin. The nginx configuration file is stored in CONF/nginx. conf, and nginx has only oneProgramThe nginx file in the sbin directory. Make sure that port 80 of the system is not occupied by other programs. Run the sbin/nginx command to start nginx and open the browser to access the IP address of the machine (enter 127.0.0.1 in the address bar ), if the browser displays welcome to nginx! Nginx has been installed and runs successfully.
Iii. Problems During Installation
1. PCRE:/configure: Error: no acceptable C compiler found in $ PATH see 'config. log' For more details
The reason is that GCC is not installed.
Solution: Yum install gcc
2../configure: checking for C ++ compiler default output file name... configure: Error: C ++ compiler cannot create executables
See 'config. log' for more details.
The reason is that the package related to the C ++ compiler is not installed.
Solution: Yum install gcc-C ++
3. PCRE: Make: [pcrecpp. Lo] Error 1
The reason is that the package related to the C ++ compiler is not installed.
Solution: Yum install gcc-C ++, re-configure, make & make install.
4./configure: error: the HTTP rewrite module requires the PCRE Library
The reason is that PCRE Library is required.
Solution: Yum-y install PCRE-devel
5 ../configure: error: the HTTP cache module requires MD5 Functions
From OpenSSL library. You can either disable the module by using
-- Without-http-Cache option, or install the OpenSSL library into the system,
Or build the OpenSSL library statically from the source with nginx by using
-- With-http_ssl_module -- With-OpenSSL = <path> options.
The reason is that OpenSSL library is required.
Solution: Yum-y install OpenSSL-devel