CentOS System Nginx Installation

Source: Internet
Author: User
Tags openssl versions centos

Reference: Http://www.nginx.cn/install

Confirm installation Make tool: GCC automake autoconf libtool do

Confirm Installation g++ tool: GCC gcc-c++


The following officially begins
---------------------------------------------------------------------------
Generally we need to first install Pcre, Zlib, the former in order to rewrite rewrite, the latter in order to gzip compression.
1. Select the source directory
Can be any directory, this article is selected/usr/local
Cd/usr/local


2. Installing the Pcre Library
Cd/usr/local
TAR-ZXVF pcre-8.37.tar.gz
MV pcre-8.37 Pcre
CD Pcre
./configure
Make
Make install


3. Installing the Zlib Library
Cd/usr/local
TAR-XF zlib-1.2.8.tar.gz
MV zlib-1.2.8 zlib
CD zlib
./configure
Make
Make install


4. Install SSL (some VPS does not install SSL by default)
Cd/usr/local
TAR-XF openssl-1.0.2d.tar.gz
MV Openssl-1.0.2d OpenSSL


5. Installing Nginx
Nginx generally has two versions, the stable version and the development version, you can choose one of these two versions according to your purpose, below is the detailed steps of installing nginx into the/usr/local/nginx directory:

Cd/usr/local
TAR-XF nginx-1.9.3.tar.gz
CD nginx-1.9.3
MV nginx-1.9.3 Nginx

./configure--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/pcre \
--with-zlib=/usr/local/zlib \
--with-openssl=/usr/local/openssl

Make
Make install
--with-pcre=/usr/local/pcre refers to the pcre source path.
--with-zlib=/usr/local/zlib refers to the zlib source path.


After the installation is successful, the/usr/local/nginx directory is as follows
fastcgi.conf Koi-win Nginx.conf.default
Fastcgi.conf.default logs Scgi_params
Fastcgi_params Mime.types Scgi_params.default
Fastcgi_params.default Mime.types.default Uwsgi_params
HTML Nginx Uwsgi_params.default
Koi-utf nginx.conf Win-utf


6. Modify the nginx.conf file in the Nginx directory, where the 88 port is used


#user nobody;
Worker_processes 1;


#error_log Logs/error.log;
#error_log Logs/error.log Notice;
#error_log Logs/error.log Info;


#pid Logs/nginx.pid;




Events {
Worker_connections 1024;
}




HTTP {
Include Mime.types;
Default_type Application/octet-stream;


#log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
# ' $status $body _bytes_sent ' $http _referer '
# ' "$http _user_agent" "$http _x_forwarded_for" ';


#access_log Logs/access.log Main;


Sendfile on;
#tcp_nopush on;


#keepalive_timeout 0;
Keepalive_timeout 65;


#gzip on;
Upstream localhost {
Server 192.168.5.151:8080;
}


server {
Listen 88;
server_name localhost;


#charset Koi8-r;


#access_log Logs/host.access.log Main;


Location/{
root HTML;
Index index.html index.htm;
Proxy_pass http://localhost;
}


#error_page 404/404.html;


# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}


# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}


# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000;
# Fastcgi_index index.php;
# Fastcgi_param Script_filename/scripts$fastcgi_script_name;
# include Fastcgi_params;
#}


# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
#location ~/\.ht {
# Deny All;
#}
}




# Another virtual host using mix of ip-, name-, and port-based configuration
#
#server {
# Listen 8000;
# Listen somename:8080;
# server_name somename alias Another.alias;


# location/{
# root HTML;
# index index.html index.htm;
#    }
#}




# HTTPS Server
#
#server {
# Listen 443 SSL;
# server_name localhost;


# ssl_certificate Cert.pem;
# Ssl_certificate_key Cert.key;


# Ssl_session_cache shared:ssl:1m;
# ssl_session_timeout 5m;


# ssl_ciphers high:!anull:! MD5;
# ssl_prefer_server_ciphers on;


# location/{
# root HTML;
# index index.html index.htm;
#    }
#}


}

7. Start
Make sure that the 88 port of the system is not occupied by another program, run the./usr/local/nginx/nginx command to start Nginx,

Netstat-ano|grep 88
If the results are not found after the execution, the result is ignored this step (Ubuntu must be started with sudo, or can only be run in the foreground)

Sudo/usr/local/nginx/nginx
Open the browser to access the IP of this machine if the browser appears Welcome to nginx! Indicates that Nginx is installed and running successfully.


Related Article

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.