Install nginx on centos

Source: Internet
Author: User

Nginx installation in centos is summarized. The source code package wget is first sent to the server from the official website, through some nginx configuration, compilation, and finally service registration./etc/init.d, You can use System V,serviceCommand to control nginx.

Download source code package

Go to the nginx official website to download it. You can pull it directly on the server by wget, http://nginx.org/en/download.html, and selectStable versionVersion

Prerequisites

Nginx compilation requires several prerequisites,GCC,PCRE,zlib,OpenSSL

GCCThis command is used to compile nginx. It is executed at http://zh.wikipedia.org/wiki/gcc.gccTo test whether GCC has been installed. Installation instructions:

yum install gcc

PCREIs nginx rewrite core modules need regular expression support, http://www.pcre.org/

yum install pcre pcre-devel

zlibProvide compression algorithm, http://zh.wikipedia.org/wiki/Zlib

yum install zlib zlib-devel

OpenSSLOpen-source SSL/TLS Module

yum install openssl openssl-devel
Module configuration

Nginx many modules, core modules are enabled by default, such as gzip, rewrite, etc., need to select the configuration to enable and disable, the official module description http://wiki.nginx.org/Modules

Currently, I only need to enable HTTPS access and register an independent user for nginx in advance, such as a userwww, ThroughconfigureTo configure

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module

Compile

make

After compilation, install and automatically copy some files to some specific directories of the configuration.

make install

You can send some parameters to the nginx binary execution file to return some information, such as nginx version information and manually enabled module information.

<prefix>/sbin/nginx -V## nginx version: nginx/1.4.6## built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ## TLS SNI support enabled## configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module
Register System Service, System V script

Script http://www.rackspace.com/knowledge_center/article/centos-adding-an-nginx-init-script

Create a file nginx in/etc/init. d/and configure its executable permissions.chmod +x ./nginx, Modify some prefix-related paths in the script according to your own situation.

chkconfig nginx on

In this way, nginx can be automatically started as the system starts.serviceTo manage nginx, suchservice nginx stop


Install nginx on centos

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.