"Nginx Installation-Configuration" CentOS7 Installation maintenance Nginx

Source: Internet
Author: User
Tags epoll install openssl openssl iptables
Nginx Installation

here is the continuous update fix

Nginx is a performance-oriented HTTP server that can reverse proxy http,https and mail-related (SMTP,POP3,IMAP) protocol links. It also provides load balancing and HTTP caching. Its design fully uses the asynchronous event model, reduces the cost of context scheduling, and improves the server concurrency capability. Modular design is used to provide a rich module of third-party modules.

So about Nginx, there are these tags: "async" event "modular" high performance "high concurrency" reverse proxy "load balancing"

Linux system: Centos 7 x64
Nginx version: 1.11.5 installation dependencies

Prce (redirect support) and OpenSSL (HTTPS support, if HTTPS is not required, can not be installed.) )

Yum-y Install pcre*
yum-y Install openssl*

CentOS 6.5 When I installed the "basic server", the default of these two packages are not fully installed, so the two are installed to run. Download

wget http://nginx.org/download/nginx-1.11.5.tar.gz

# if not installed wget
# Download compiled version
$ yum Install wget
Compiling the installation

Then enter the directory compile installation, configure parameter description

CD nginx-1.11.5
./configure

Installation report error such as: "C compiler cc is not found", this is the lack of a compilation environment, installation can be yum-y install gcc make gcc-c++ openssl-devel wget

If there is no error information, you can perform the installation below:

Make make
Install
nginx Test

Two results will appear when you run the following command

./nginx-t

# nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK
# nginx:configuration fi Le/usr/local/nginx/conf/nginx.conf Test is successful
power-on self-starter

Edit the vi/lib/systemd/system/nginx.service file without creating a touch nginx.service and then modify the following according to the specific circumstances Add to Nginx.service file:

[Unit]
description=nginx1.11.5
after=network.target remote-fs.target nss-lookup.target

[Service]

Type= Forking
pidfile=/var/run/nginx.pid
execstartpre=/usr/local/nginx/sbin/nginx-t-c/usr/local/nginx/conf/ nginx.conf
execstart=/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
ExecReload=/bin/ Kill-s HUP $MAINPID
execstop=/bin/kill-s QUIT $MAINPID
privatetmp=true

[Install]
wantedby= Multi-user.target

Set the boot up to make the configuration effective:

Systemctl Enable Nginx.service
Yun-Wei Service Management
# start
/usr/local/nginx/sbin/nginx

# reboot
/usr/local/nginx/sbin/nginx-s Reload

# Shut down process
/usr/local/ Nginx/sbin/nginx-s Stop

# smooth off nginx
/usr/local/nginx/sbin/nginx-s quit

# View the installation status of Nginx

turn off the firewall or add firewall rules to test the

Service Iptables Stop

or edit the configuration file:

Vi/etc/sysconfig/iptables

Save after adding such an open 80-port rule:

-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

Restart the service:

Service Iptables Restart
Restart Service Firewall error Resolution
Service iptables Restart
# redirecting To/bin/systemctl restart Iptables.service # Failed to
restart Iptables.service:Unit Iptables.service failed to load:no such file or directory.

Firewalls are managed by Firewalld in CentOS 7 or Rhel 7 or Fedora, and of course you can restore the traditional management style. or use the new command for management.
If you use tradition, please execute the order:

# Traditional Command
systemctl stop firewalld
systemctl mask Firewalld
# installation Command
yum install iptables-services

systemctl enable iptables 
service iptables restart
Nginx Uninstall

If you are installing by yum, install it using the following command.

Yum Remove Nginx

Compile installation, delete/usr/local/nginx directory
If you have configured your own startup scripts, you also need to delete them. parameter Description

Parameters Description
--prefix=<path> Nginx installation path. If not specified, the default is/usr/local/nginx.
--sbin-path=<path> Nginx the executable file installation path. Can only be specified on installation, if not specified, default is <prefix>/sbin/nginx.
--conf-path=<path> The default nginx.conf path without the given-c option. If not specified, the default is <prefix>/conf/nginx.conf.
--pid-path=<path> The default nginx.pid path in the case where the PID directive is not specified in the nginx.conf. If not specified, the default is <prefix>/logs/nginx.pid.
--lock-path=<path> The path to the Nginx.lock file.
--error-log-path=<path> The path to the default error log in cases where the ERROR_LOG directive is not specified in nginx.conf. If not specified, the default is <prefix>/-Logs/error.log.
--http-log-path=<path> The path to the default access log in cases where the Access_log directive is not specified in nginx.conf. If not specified, the default is <prefix>/-Logs/access.log.
--user=<user> In the case where the user directive is not specified in nginx.conf, the default nginx is used. If not specified, the default is nobody.
--group=<group> In the case where the user directive is not specified in nginx.conf, the default nginx is used by the group. If not specified, the default is nobody.
--builddir=dir Specify the compiled directory
--with-rtsig_module Enable Rtsig module
--with-select_module--without-select_module Allows or does not allow select mode to be turned on if configure does not find a more appropriate pattern, such as: Kqueue (Sun OS), Epoll (Linux kenel 2.6+), Rtsig (-live signal) or/dev/poll ( A select-like pattern in which the underlying implementation is essentially the same as select, using the Rotation method) Select mode will be the default installation mode
--with-poll_module--without-poll_module Whether or not to enable the poll module. This module was enabled by, default if a more suitable method such as Kqueue, Epoll, Rtsig or/dev/poll are not discovered B Y Configure.
--with-http_ssl_module Enable Ngx_http_ssl_module. Enables SSL support and the ability to handle HTTPS requests. Requires OpenSSL. On Debian, this is Libssl-dev open the HTTP SSL module so that nginx can support HTTPS requests. This module needs to have been installed on OpenSSL, which is libssl on Debian
--with-http_realip_module Enable Ngx_http_realip_module
--with-http_addition_module Enable Ngx_http_addition_module
--with-http_sub_module Enable Ngx_http_sub_module
--with-http_dav_module Enable Ngx_http_dav_module
--with-http_flv_module Enable Ngx_http_flv_module
--with-http_stub_status_module Enable the Server Status page
--without-http_charset_module Disable Ngx_http_charset_module
--without-http_gzip_module Disables Ngx_http_gzip_module. If enabled, you need to zlib.
--without-http_ssi_module Disable Ngx_http_ssi_module
--without-http_userid_module Disable Ngx_http_userid_module
--without-http_access_module Disable Ngx_http_access_module
--without-http_auth_basic_module Disable Ngx_http_auth_basic_module
--without-http_autoindex_module Disable Ngx_http_autoindex_module
--without-http_geo_module Disable Ngx_http_geo_module
--without-http_map_module Disable Ngx_http_map_module
--without-http_referer_module Disable Ngx_http_referer_module
--without-http_rewrite_module Disables Ngx_http_rewrite_module. PCRE is required if enabled.
--without-http_proxy_module Disable Ngx_http_proxy_module
--without-http_fastcgi_module Disable Ngx_http_fastcgi_module
--without-http_memcached_module Disable Ngx_http_memcached_module
--without-http_limit_zone_module Disable Ngx_http_limit_zone_module
--without-http_empty_gif_module Disable Ngx_http_empty_gif_module
--without-http_browser_module Disable Ngx_http_browser_module
--without-http_upstream_ip_hash_module Disable Ngx_http_upstream_ip_hash_module
--with-http_perl_module Enable Ngx_http_perl_module
--with-perl_modules_path=path Specify the path to the Perl module
--with-perl=path Specify the path to the Perl execution file
--http-log-path=path Set path to the HTTP access log
--http-client-body-temp-path=path Set path to the HTTP client request body temporary files
--http-proxy-temp-path=path Set path to the HTTP proxy temporary files
--http-fastcgi-temp-path=path Set path to the HTTP fastcgi temporary files

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.