Nginx server configuration tutorial (centos6.0) in linux, nginxcentos6.0

Source: Internet
Author: User
Tags nginx server

Nginx server configuration tutorial (centos6.0) in linux, nginxcentos6.0

Configure the nginx server in linux.

In the download and installation of pcre and nginx, the root identity should be used, generally downloaded to/usr/local/src/, download to other places to configure? (Failed to test several times)

1. the compiling environment gcc g ++ needs to be installed in advance

Yum-y install make zlib-devel gcc-c ++ libtool openssl-devel

2. First install the PCRE pcre function to enable nginx to have the rewrite Function

Download PCRE

Unzip installation package: tar zxvf pcre-8.35.tar.gz

Go to the installation package Directory: cd pcre-8.35

Compile:./configure

Install: make & make install

Check the installation version: pcre-config -- version. if the version number is displayed, the installation is successful.

Check if pcre software is installed in the system

If rpm-qa pcre is not displayed, it indicates that it has not been installed, and vice versa.

Rpm-e -- nodeps pcre Delete pcre

3. Install nginx

Download nginx: wget https://nginx.org/download/nginx-1.6.2.tar.gz

Unzip installation package: tar zxvf nginx-1.6.2.tar.gz

Go to the installation package Directory: cd nginx-1.6.2

Compile and install:./configure Default address/usr/local/nginx

Install: make

Install: make install

Note:

During the first compilation:

The first time a 64-bit system is compiled and installed

Error while loading shared libraries: libpcre. so.1: cannot open shared object file: No such file or directory in this case, nginx is in lib64 by default, 32 is in lib

Find: find/-name 'libpcre. so.1 '/usr/local/lib/libpcre. so.1, we establish a symbolic link: ln-s/usr/local/lib/libpcre. so.1/lib64/libpcre. so.1

In this way, you can check the version of nginx/usr/local/nginx/sbin/nginx-v.

Check whether the configuration is correct.

The following two statements indicate correct #/usr/local/nginx/sbin/nginx-t

Nginx: the configuration file/usr/local/nginx/conf/nginx. conf syntax is OK

Nginx: configuration file/usr/local/nginx/conf/nginx. conf test is successful

5. Start nginx

The following error is reported during startup:

Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)

Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)

Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)

Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use )...

This indicates that 80 interfaces are occupied. View interfaces.

Netstat-ntpl

Kill-9 $ pid // kill the process

Start again

/Usr/local/nginx/sbin/nginx

Stop a server

/Usr/local/nginx/sbin/nginx-s stop or/usr/local/nginx/sbin/nginx-s quick

Disable firewall command: service iptables stop

Permanently disable the firewall: chkconfig iptables off

Run the two commands at the same time. After running, check the firewall shutdown status.

Close command: service iptables stop

Permanently disable the firewall: chkconfig iptables off

Run the two commands at the same time. After running, check the firewall shutdown status.

Service iptables status

Webpage access (local IP address)

Uninstall nginx

Delete the nginx file.

Rm-rf/usr/local/nginx

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.