CentOS Installation Configuration Nginx

Source: Internet
Author: User

1. Installing GCC

Yum Install GCC

2, install Pcre,zlib,openssl (which devel, is the meaning of the develop development package)

Yum install-y pcre Pcre-devel

Yum install-y zlib Zlib-devel

Yum Install-y OpenSSL Openssl-devel

3. Download and install Nginx

mkdir nginx-src && CD nginx-src
wget http://nginx.org/download/nginx-1.7.3.tar.gz
Tar xzf nginx-1.7.3.tar.gz
CD nginx-1.7.3
./configure
Make
Make install
Whereis Nginx

4, Sbin/nginx start Nginx

Start: Nginx
Stop: Nginx-s stop

5. Configuration

#启动进程, usually set to equal to the number of CPUs worker_processes1; #全局错误日志及PID文件error_log/var/log/nginx/Error.log;pid/var/run/nginx.pid; #工作模式及连接数上限events {use epoll; #epoll是多路复用IO (I/O multiplexing), but only for linux2.6 above the core, can greatly improve the performance of Nginx Worker_connections1024;}  #设定http服务器, using its reverse proxy feature to provide load balancing support for HTTP {include mime.types; #设定mime类型, the type is defined by the Mime.type file Default_type application/octet-stream;    Sendfile on; #设置链接超时时间 Keepalive_timeout65;   #开启gzip压缩 # gzip on; # gzip_disable"MSIE [1-6]\. (?!. *SV1) "; #设定负载均衡的服务器列表 upstream Mysvr {#weigth参数表示权值, the higher the weight, the greater the chance of being allocated # #本机上的Squid开启3128端口 server192.168.8.151:80 weight=6; Server192.168.8.120:80 weight=6; } server {#侦听80端口 listen80;            #定义使用www. xx.com visit server_name localhost; Location/{root HTML;        Index index.html index.htm; } error_page500 502 503 504/50x.html; Location= /50x.html {root html; } Location~\.php$ {root/Root; Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php; Fastcgi_param Script_filename/home/www/Www$fastcgi_script_name;    Include Fastcgi_params; } #设定查看Nginx状态的地址 # location/Nginxstatus {# stub_status on;    # Access_log on; # Auth_basic"Nginxstatus"; # Auth_basic_user_file conf/htpasswd; #} # #禁止访问. htxxx File # Location~ /\.ht {# deny all; #    }    }}
View Code

CentOS Installation Configuration 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.