Nginx ("Engine X") is a high-performance Web and reverse proxy server developed by the Russian program designer Igor Sysoev and is also a IMAP/POP3/SMTP proxy server.
In the case of high connection concurrency, Nginx is a good substitute for Apache server.
Nginx Installation
System platform: CentOS release 6.6 (Final) 64-bit.
First, install the compilation tools and library files
-y install make zlib zlib-devel gcc-c+ + libtool OpenSSL OpenSSL-devel /c8>
Second, first to install PCRE
PCRE function is to let Ngnix support Rewrite function.
1, download PCRE installation package,: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
[[email protected] src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/ pcre-8.35.tar.gz
2. Unpack the installation package:
[email protected] src]# tar zxvf pcre-8.35. Tar. GZ
3. Enter the installation package directory
[email protected] src]# cd pcre-8.35
4. Compile and install
[email protected] pcre-8.35]#./Configure[[email protected] pcre- 8.35]# make && make install
5. View Pcre Version
[email protected] pcre-8.35]# pcre---version
Installing Nginx
1. Download nginx,:http://nginx.org/download/nginx-1.6.2.tar.gz
[[email protected] src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
2. Unpack the installation package
[email protected] src]# tar zxvf nginx-1.6. 2.tar. GZ
3. Enter the installation package directory
[email protected] src]# cd nginx-1.6. 2
4. Compile and install
[[Email protected] Nginx-1.6.2]# ./Configure--Prefix=/usr/Local/Webserver/Nginx--With-Http_stub_status_module--with-http_ssl_module -- with-pcre=/usr/local/src/pcre -8.35[[email Protected] nginx-1.6. 2]# Make[[email protected] Nginx-1.6. 2]# make install
5. View Nginx Version
[email protected] nginx-1.6. 2]#/usr/local/webserver/nginx/sbin/-v
To this, Nginx installation is complete.
Nginx Configuration
Create Nginx to run users using www:
[Email protected] conf]#/usr/sbin/groupadd www [[email protected] Conf ]#/usr/sbin/-g www www
Configure NGINX.CONF to replace/usr/local/webserver/nginx/conf/nginx.conf with the following
[[Email protected] Conf]#Cat/Usr/Local/Webserver/Nginx/Conf/Nginx.Confuser www www;Worker_processes2; #设置值和CPU核心数一致Error_log/Usr/Local/Webserver/Nginx/Logs/Nginx_error.Log Crit; #日志位置和日志级别Pid/Usr/Local/Webserver/Nginx/Nginx.Pid;#Specifies the value for maximum file descriptors the can is opened by this process.Worker_rlimit_nofile65535;Events{UseEpoll;Worker_connections65535;}http{Include 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 ';#charset gb2312;Server_names_hash_bucket_size128;Client_header_buffer_size32k;Large_client_header_buffers4 32k;Client_max_body_size8m;Sendfile on;Tcp_nopush on;Keepalive_timeout60;Tcp_nodelay on;Fastcgi_connect_timeout300;Fastcgi_send_timeout300;Fastcgi_read_timeout300;Fastcgi_buffer_size64k;Fastcgi_buffers4 64k;Fastcgi_busy_buffers_size128k;Fastcgi_temp_file_write_size128k;Gzip on;Gzip_min_length1k;Gzip_buffers4 16k;Gzip_http_version1.0;Gzip_comp_level2;Gzip_types text/Plain Application/X-JavaScript text/CSS Application/Xml;Gzip_vary on;#limit_zone crawler $binary _remote_addr 10m;#下面是server虚拟主机的配置Server{Listen80; #监听端口server_name localhost; #域名Index Index.HTML index.HTM indexphp;/usr/local /webserver/nginx/< Span class= "PLN" >html; #站点目录 location ~. *\. (PHP|PHP5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; include fastcgi.conf; }& nbsp Location ~. *\. (Gif|jpg|jpeg|png|bmp|swf|ico) $ { Expires 30d; # access_log off; }&NB Sp Location ~. *\. (JS|CSS)?$ { expires 15d; # access_log off; } acces S_log off; }}
Check the correctness of the configuration file ngnix.conf command:
[Email protected] conf]#/usr/local/webserver/nginx/sbin /-t
Start Nginx
The Nginx startup command is as follows:
[Email protected] conf]#/usr/local/webserver/nginx/sbin /nginx
Visit site
To access our configured site IP from the browser:
Nginx Other Commands
Here are a few of the most common commands for Nginx:
/usr/Local/Webserver/Nginx/Sbin/Nginx-s reload # reload config file /usr /local/webserver/< Span class= "PLN" >nginx/sbin/nginx -s reopen # restart Nginx/usr/local/webserver /nginx/sbin/ nginx -s stop # stop nginx
"Go" Nginx installation configuration