: This article mainly introduces nginx compilation and configuration. if you are interested in the PHP Tutorial, you can refer to it. 1. preparations before installing nginx
Yum install-y gcc-c ++
Yum install zlib-devel
Yum install openssl
2. Compile and install pcre
Run the following command:
# Cd/data/software/pcre-8.32
#./Configure-prefix
# Make
# Make install
2. Compile and install nginx
Run the following command:
# Cd/data/software/nginx-1.7.0
#./Configure -- prefix =/data/nginx/-- with-http_ssl_module -- with-http_spdy_module \
With-http_stub_status_module -- with-pcre
# Make
# Make install
-With-http_stub_status_module: Support for nginx status query
-With-http_ssl_module: Support for https
-With-http_spdy_module: Support google spdy, would like to know Baidu spdy, this must have ssl support
-With-pcre: to support rewrite, you must specify a pcre
Start nginx after installation is complete.
[Root @ localhost conf] #/data/nginx/sbin/nginx (the following error is prompted when nginx is started)
/Data/nginx/sbin/nginx: error while loadingshared libraries: libpcre. so.1: cannot open shared object file: No such file ordirectory
Establish a soft connection
[Hadoop @ SCLABHADOOP01 ~] $ Ln-s/usr/local/lib/libpcre. so.1/lib64/
The command to determine whether the Nginx configuration is correct is as follows:
/Usr/nginx/sbin/nginx-t
/Data/nginx/sbin/nginx (start the service)
/Data/nginx/sbin/nginx-s stop (stop service)
/Data/nginx/sbin/nginx-s reload (restart the service)
Configure nginx
# Server {
# Listening to port 80
Listen 80;
# Define access using www.xx.com
Server_name www.xx.com;
# Set access logs for the current virtual host
Access_log logs/www.xx.com. access. log main;
# Default request
Location /{
Root/root; # define the default website root directory location of the server
Index index.phpindex.html index.htm; # define the name of the home index file
Example
Server {
Listen 80;
Server_name bo.artronekp.net;
Location /{
Root/data/software/beian /;
Index index.html help.html;
}
}
The above describes nginx compilation and configuration, including some content, and hope to help those who are interested in the PHP Tutorial.