Nginx compilation and configuration

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.