Build Nginx server under Linux

Source: Internet
Author: User
Tags openssl unpack nginx server

Nginx install one. Installing the compilation tools and library files
Yum-y install make zlib zlib-devel gcc-c++ libtool  OpenSSL openssl-devel
View CodeTwo. Install PCRE (PCRE function is to let Nginx support rewrite function)

1. Download the PCRE installation package: https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz

can go to the Web download can also be directly downloaded by the command:

wget https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz
View Code

2. Unpack the installation package to the specified directory:

TAR-ZXVF pcre-8.35.tar.gz-c/USR/LOCAL/SRC

3. Compile and install Pcre

cd/usr/local/src/pcre-8.3.5

./configure

Make && make install

Pcre-8.35.tar.gz

4. View Pcre version

Pcre-config--version

Three. Installing Nginx

1. Download nginx,:http://nginx.org/download/nginx-1.14.0.tar.gz

can go to the Web download can also be directly downloaded by the command:

wget http://nginx.org/download/nginx-1.14.0.tar.gz
View Code

2. Unpack the installation package to the specified directory:

TAR-ZXVF nginx-1.14.0.tar.gz-c/usr/local

3. Compile and install Nginx

cd/usr/local/nginx-1.14

#检查安装环境 and specify the path to be installed in the future

./configure--prefix=/usr/local/nginx

Make && make install

Pcre-8.35.tar.gz

4. View Nginx Version

Cd/usr/local/nginx/sbin

./nginx-v

Four. Nginx Configuration

#进入配置文件目录

Cd/usr/local/nginx/conf

#打开并修改配置文件

VI nginx.conf

#user nobody;worker_processes1; #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;events {worker_connections1024x768;}    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_timeout0; Keepalive_timeout $;    #gzip on; server {Listen the; #监听端口 server_name localhost; #域名 #charset koi8-S; #access_log logs/Host.access.log Main; Location/{root HTML; Site Directory index index.html index.htm; } #error_page404/404. html; # REDIRECT Server error pages to theStaticPage/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root html; } # Proxy The PHP scripts to Apache listening on127.0.0.1: the# #location~\.php$ {# Proxy_pass http://127.0.0.1;#} # Pass the PHP scripts to FastCGI server listening on127.0.0.1:9000# #location~\.php$ {# root HTML; # Fastcgi_pass127.0.0.1:9000;        # Fastcgi_index index.php; # Fastcgi_param Script_filename/Scripts$fastcgi_script_name;        # include Fastcgi_params; #} # Deny access to. htaccess files,ifApache's Document Root# concurs with Nginx'S One# #location~ /\.ht {# deny all; #}} # anotherVirtualHostusingMix of ip-, name-, and port-based configuration # #server {# listen8000; # Listen Somename:8080;    # server_name somename alias Another.alias; # Location/{# root HTML;    # index index.html index.htm; #} #} # HTTPS Server # #server {# listen443;    # server_name localhost;    # SSL on;    # ssl_certificate Cert.pem;    # Ssl_certificate_key Cert.key;    # ssl_session_timeout 5m;    # ssl_protocols SSLv2 SSLv3 TLSv1; # Ssl_ciphers High:!anull:!MD5;    # ssl_prefer_server_ciphers on; # Location/{# root HTML;    # index index.html index.htm; #    }    #}}
View Code

Change the domain name and the site directory to the address we need.

Two. Common commands of Nginx

#切换目录到指定目录

Cd/usr/local/nginx/sbin

1./nginx-s quit gracefully stop nginx, there will be a connection when the connection request is completed before killing the worker process2 3./nginx-s Reload graceful reboot and reload the configuration file nginx.conf4 5./nginx-s Stop6 7./nginx-s reopen reopen log file, typically used for cutting logs8 9./nginx-v View versionTen  One./nginx-t Check nginx configuration file A  -./nginx-h View Help information -  the./nginx-V detailed version information, including compilation parameters -  -./nginx-c filename Specifies the configuration file -  + quit is an elegant way to close, and Nginx completes an accepted connection request before exiting.  -  +  AStop is a quick shutdown, regardless of whether there is a request being processed.
View Code

Build Nginx server under Linux

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.