CentOS installation Nginx

Source: Internet
Author: User
Tags install openssl nginx server

Install Nginx on the CentOS I just installed. I use the download Nginx source code to install the code.


The installation will be error, mainly missing some libraries, or although some libraries have been installed, but not the development version of the corresponding module is missing.


1, download Nginx, and unzip, into the Nginx directory, run

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

which

--prefix=path # specifying the installation destination path

--with-http_stub_status_module # turn on HTTP status monitoring


2. In the Configure phase will be error, found missing the following template:

Gcc

PCRE

Zlib

Openssl

Install the appropriate development version and update the local library before installing.

Yum Update # updates the local library

Yum Install GCC

Yum Install Pcre-devel

Yum Install Zlib-devel

Yum Install Openssl-devel

Configure after installation to see if it was successful


3. In the Nginx directory make, no error after make install


4. Because I am not very familiar with Nginx configuration, temporarily do not talk about the configuration, later will be supplemented. Use the default configuration file to start Nginx.


/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf


If the operation succeeds, use the command NETSTAT-ANTLP | grep can see the nginx listening on TCP 80 port.


TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1440/nginx


5. Run wget HTTP://127.0.0.1/in the CentOS terminal to see if you can get to the index.html page. Then run wget or browser input http://xxx.xxx.xxx.xxx/on the other machine through the command line to access Nginx, see if the success, if unsuccessful, may be the cause of the firewall.


Because there will be a default firewall policy to prohibit external machine access under CentOS, you need to modify the firewall policy, modify the configuration file/etc/sysconfig/iptables, and increase the permission to allow external access to port 80:

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

This configuration means:

-A: Add a strategy

Input: For incoming traffic

-M state--state New: Makes a status match, and the packet is the packet on a new connection.

-M Tcp-p TCP--dport 80: TCP Match, protocol is TCP, destination port number is 80 port

-j: After a successful match, the adoption action is to allow the packet to pass


My current firewall configuration file is as follows:


: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state--state established,related-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT


At this point, my nginx server is running properly. Although currently not able to run PHP, but also the lack of common modules, but at least to run normally, the future needs of the module added later.

This article is from the "Chhquan" blog, make sure to keep this source http://chhquan.blog.51cto.com/1346841/1791524

CentOS installation Nginx

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.