Linux/centos installation of Nginx (RPM installation and source installation) detailed steps

Source: Internet
Author: User

Linux/centos installation of Nginx (RPM installation and source installation) detailed steps to install nginx RPM Package 1 on the Nginx official website to download an RPM package, is: Http://nginx.org/en/download.htmlwget http ://nginx.org/packages/centos/6/noarch/rpms/nginx-release-centos-6-0.el6.ngx.noarch.rpm2 Install this RPM package RPM-IVH NGINX-RELEASE-CENTOS-6-0.EL6.NGX.NOARCH.RPM installed ...

Install Nginx RPM package under CentOS

1 Download an RPM package on the Nginx official website, yes: http://nginx.org/en/download.html

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

2 Install this RPM package

RPM-IVH nginx-release-centos-6-0.el6.ngx.noarch.rpm

An error message will appear during the installation process:

Warning:nginx-release-centos-6-0.el6.ngx.noarch.rpm:header V4 rsa/sha1 Signature, key ID 7bd9bf62:nokey

Ignore can

3 start to install Nginx formally

Yum Install Nginx

A whole bunch of information is displayed: Is this OK [y/n]:

Enter Y, the screen rolls for a while and then installs, the last hint "complete!" Is that it's finished.

Several default directories for 4 Nginx

Input command: Whereis nginx

Nginx:/usr/sbin/nginx/etc/nginx/usr/share/nginx

1) configuration directory:/etc/nginx/

2) PID directory:/var/run/nginx.pid

3) error log:/var/log/nginx/error.log

4) Access log:/var/log/nginx/access.log

5) Default Site Directory:/usr/share/nginx/html

5 Common commands

1) Start Nginx:nginx

2) Restart Nginx:killall-hup nginx

3) Test Nginx configuration: nginx-t

6 Nginx cannot be accessed outside the station?

Just installed Nginx A common problem is unable to stand outside the access, native wget, Telnet are normal. Outside the server, the site is inaccessible to other hosts on the LAN or to hosts on the Internet. If

With Telnet, Tip:

Connecting to 192.168.0.xxx ... Cannot open connection to host on port 80: Connection Failed

If you use the wget command, prompt:

Connecting to 192.168.0.100:80 ... Failed:no route to host.

If it is the above phenomenon, it is likely that the CentOS firewall to the 80 port stopped, try to execute the following command, open 80 port:

Iptables-i input-p TCP--dport 80-j ACCEPT

Then use:

/etc/init.d/iptables status

Review the current firewall rules, if one is found:

ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:80

This means that the firewall rules have been added successfully, and then access outside the station is normal.

General Linux under the Source installation procedure for reference

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/SRC

Cd/usr/local/src

2. Installing the Pcre Library

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Download the latest pcre source package, download the compile and install the Pcre package using the command below:

Cd/usr/local/src

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

TAR-ZXVF pcre-8.21.tar.gz

CD pcre-8.21

./configure

Make

Make install

3. Installing the Zlib Library

http://zlib.net/zlib-1.2.8.tar.gz Download the latest zlib source package, download the compile and install the zlib package using the command below:

Cd/usr/local/src

wget http://zlib.net/zlib-1.2.8.tar.gz

TAR-ZXVF zlib-1.2.8.tar.gz

CD zlib-1.2.8

./configure

Make

Make install

4. Install SSL (some VPS does not install SSL by default)

Cd/usr/local/src

wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz

TAR-ZXVF openssl-1.0.1c.tar.gz

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 to install Nginx into the/usr/local/nginx directory :

Cd/usr/local/src

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

TAR-ZXVF nginx-1.4.2.tar.gz

CD nginx-1.4.2

./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/src/pcre-8.21 \

--with-zlib=/usr/local/src/zlib-1.2.8 \

--with-openssl=/usr/local/src/openssl-1.0.1c

Make

Make install

--with-pcre=/usr/src/pcre-8.21 refers to the pcre-8.21 source path.

--with-zlib=/usr/src/zlib-1.2.7 refers to the zlib-1.2.7 source path.

After successful installation, 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. Start

Ensure that the 80 port of the system is not occupied by other programs, run the/usr/local/nginx/nginx command to start Nginx,

Netstat-ano|grep 80

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.

Installation of Nginx under Linux/centos (RPM installation and source installation) detailed steps

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.