CentOS-64 bit install nginx through Yum Source

Source: Internet
Author: User

Step 1: Create a software source configuration file named nginx. Repo under the/etc/yum. Repos. d/directory.
The content of the nginx. Repo file is:

[nginx]   name=nginx repo   baseurl=http://nginx.org/packages/centos/$releasever/$basearch/   gpgcheck=0   enabled=1

Step 2: run the command Yum install nginx and follow the prompts to complete the installation;
Step 3: run the/etc/init. d/nginx start command to start the nginx service;

Step 4: Test. Enter the Server IP address in the browser to display the nginx welcome page;

Restart nginx command:
Service nginx restart;
Nginx-s reload;

 

Nginx installation path:/etc/nginx

Configuration File:/etc/nginx. conf

First, modify the/etc/nginx. conf file:

[[Email protected] nginx] # vi nginx. conf

User nginx;
Worker_processes 2;

Error_log/var/log/nginx/error. Log warn;
Pid/var/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 $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';

Access_log/var/log/nginx/access. Log main;

Sendfile on;
# Tcp_nopush on;

Keepalive_timeout 65;

Gzip on;

Include/etc/nginx/CONF. d/*. conf;

# The name after upstream is used later. backend is used here.

upstream backend { server 127.0.0.1:8080; }

}

 

Modify the/etc/nginx/CONF. d File

[[Email protected] Conf. d] # vi default. conf
Server {
Listen 80;
SERVER_NAME localhost;

# Charset koi8-r;
# Access_log/var/log/nginx/log/host. Access. Log main;

# Location /{
# Root/usr/share/nginx/html;
# Index index.html index.htm;
#}

 

location /{proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://backend;}

# Look familiar with the last line of proxy_pass http: // backend. backend is the name defined in the previous upstream.

# Error_page 404/404 .html;

# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/usr/share/nginx/html;
}

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.