Centos6.x install and configure nginx

Source: Internet
Author: User
Tags ssl certificate nginx ssl

Nginx Installation

Nginx Official Website: http://nginx.org/Corresponding download page: http://nginx.org/en/download.html I here using nginx Yum online Installation

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

Install source Library

Chmod + x nginx-release-centos-6-0.el6.ngx.noarch.rpm

Rpm-I nginx-release-centos-6-0.el6.ngx.noarch.rpm

Install nginx

Yum install nginx

After installation, the default nginx configuration file is/etc/nginx. conf [main nginx configuration file] default nginx SSL configuration file:/etc/nginx/CONF. d/SSL. conf [configure the SSL Certificate, which can also be incorporated into nginx. in the conf file] The default nginx virtual host configuration file:/etc/nginx/CONF. d/virtual. conf [Like Apache's virtual host configuration, it can also be incorporated into nginx. in the conf file] default web_root folder path:/usr/share/nginx/html [web directory folder, place magento main program] configure iptables

Iptables-I input 5-P TCP -- dport 80-J accept

Start nginx

Service nginx start

Open the IP address and you can see "Welcome to nginx !" Indicates that the installation is successful.

 

========================================================== ================================== Add the following by yourself, if nginx is not started by root, disable nginx started by default.

Chkconfig -- level 2345 nginx off

Copy/etc/nginx. conf to another location

CP/etc/nginx. CONF/home/user/etc/nginx. conf

Start

/Usr/sbin/nginx-C/home/user/etc/nginx. conf

Close

Killall nginx

 

========================================================== ==================== Conf is changed to the following:

 

User nginx; worker_processes 1; error_log/home/user/log/nginx/error. log warn; PID/home/user/log/nginx/run/nginx. PID; events {worker_connections 1024;} HTTP {include/etc/nginx/mime. types; default_type application/octet-stream; log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request" ''$ Status $ response" $ http_referer "'' "$ http_user_agent" "$ http_x_forwarded_for "'; access_log/home/user/log/nginx/access. log main; sendfile on; # tcp_nopush on; keepalive_timeout 65; gzip on; Include/home/user/etc/nginx/CONF. d /*. conf ;}

 

/Home/user/etc/nginx/CONF. d/default. conf; server {Listen 8080; Note: If the port is lower than 1024, it must be started with the root permission (this is a problem with the Linux system mechanism); otherwise, the system will prompt that the port cannot be bound if the port is not root.

========================================================== =

Start a non-root user and use port 80:

CD/usr/sbin

Found:-rwxr-XR-X. 1 Root 834352 Dec 12 nginx according to the online statement, add the s permission to nginx:

Chmod U + S nginx

Check again:-rwsr-XR-X. 1 Root 834352 Dec 12 nginx started again as non-root: Root 1736 1 0? 00:00:00 nginx: Master process/usr/sbin/nginx-C/home/user/etc/nginx. confnginx 1737 1736 0? 00:00:00 nginx: The Master thread of worker process is still root. The subthread is not necessarily root.

In addition:

If the nginx setting directory is under/home/user. /Home/user must grant O + x permissions; otherwise, 403 Forbidden will be reported.

Centos6.x install and configure 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.