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, installation of the compilation tools and library files
Yum Install Make gcc-c++ libtool OpenSSL openssl-devel
Second, first to install PCRE
PCRE function is to let Nginx support Rewrite function.
1, download PCRE installation package,: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2. Unpack the installation package:
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-config--version
Third, install Nginx
1. Download nginx,:http://nginx.org/download/nginx-1.6.2.tar.gz
wget http://nginx.org/download/nginx-1.6.2.tar.gz
2. Unpack the installation package
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. 2make[email protected] nginx-1.6. 2makeinstall
5. View Nginx Version
[Email protected] nginx-1.6. 2] #/usr/local/webserver/nginx/sbin/nginx-v
To this, Nginx installation is complete.
Four, Nginx configuration
Create Nginx to run users using www:
[Email protected] conf]#/usr/sbin//usr/sbin/useradd-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 forMaximumfiledescriptors that can is opened by this process.worker_rlimit_nofile65535; events{use Epoll; 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_size -; Client_header_buffer_size 32k; Large_client_header_buffers432k; Client_max_body_size 8m; Sendfile on; Tcp_nopush on; Keepalive_timeout -; Tcp_nodelay on; Fastcgi_connect_timeout -; Fastcgi_send_timeout -; Fastcgi_read_timeout -; Fastcgi_buffer_size 64k; Fastcgi_buffers464k; Fastcgi_busy_buffers_size 128k; Fastcgi_temp_file_write_size 128k; gzipOn ; Gzip_min_length 1k; Gzip_buffers416k; 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 {Listen the; #监听端口 server_name localhost; #域名 index index.html index.htm index.php; Root/usr/local/webserver/nginx/html; #站点目录location~ .*\. (PHP|PHP5)?$ {#fastcgi_pass Unix:/tmp/php-Cgi.sock; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Include fastcgi.conf; } Location~ .*\. (gif|jpg|jpeg|png|bmp|swf|ico) $ {expires 30d; # Access_log off; } Location~ .*\. (JS|CSS)?$ {Expires 15d; # Access_log off; } Access_log off; }}
Check the correctness of the configuration file ngnix.conf command:
[Email protected] conf]#/usr/local/webserver/nginx/sbin/nginx-t
Five, start Nginx
The Nginx startup command is as follows:
[Email protected] conf]#/usr/local/webserver/nginx/sbin/nginx
Vi. Visit the site
To access our configured site IP from the browser:
Seven, Nginx other commands
Here are a few of the most common commands for Nginx:
/usr/local/webserver/nginx/sbin/nginx-s Reload # reload configuration file /usr/local/webserver/nginx/sbin/nginx- s reopen # restart Nginx/usr/local/webserver/nginx/sbin/nginx-s Stop # stop Nginx
Conclusion: Life is not Lin Daiyu, not because of sadness and amorous feelings.
Cute bo master: Alanlee
Blog Address: Http://www.cnblogs.com/AlanLee
This article is from the blog garden, welcome everyone to join the blog park.
Linux Server Installation configuration Nginx server