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: CentOSrelease6.6 (Final) 64-bit.
First, install the compilation tools and library files
Yum-yinstallmakezlibzlib-develgcc-c++libtoolopensslopenssl-devel
Second, first to install Pcre
Pcre function is to let nginx support rewrite function.
1. Download Pcre installation package
[[email protected]] #wgethttp://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2. Unpack the installation package:
[[email protected]] #tarzxvfpcre -8.35.tar.gz
3. Enter the installation package directory
[[email protected]] #cdpcre-8.35
4. Compile and install
[[email Protected]]#./configure[[email protected]] #make &&makeinstall
5. View Pcre Version
[[email protected]] #pcre-config--version
Installing Nginx
1. Download Nginx
[[email protected]] #wgethttp://nginx.org/download/nginx-1.6.2.tar.gz
2. Unpack the installation package
[[email protected]] #tarzxvfnginx -1.6.2.tar.gz
3. Enter the installation package directory
[[email protected]] #cdnginx -1.6.2
4. Compile and install
[[Email Protected]]#./configure--prefix=/usr/local/webserver/nginx--with-http_stub_status_module--with-http_ssl _module--with-pcre=/usr/local/src/pcre-8.35[root[email protected]] #make [[email protected]] #makeinstall
5. View Nginx Version
[[Email Protected]]#/usr/local/webserver/nginx/sbin/nginx-v
To this, Nginx installation is complete.
Nginx Configuration
Create Nginx to run users using www:
[[Email Protected]]#/usr/sbin/groupaddwww[[email protected]]#/usr/sbin/useradd-gwwwwww
Configure NGINX.CONF to replace/usr/local/webserver/nginx/conf/nginx.conf with the following
[[email protected]] #cat/usr/local/webserver/nginx/conf/nginx.confuserwwwwww;worker_processes2;# Set value and CPU core number consistent error_log/usr/local/webserver/nginx/logs/nginx_error.logcrit; #日志位置和日志级别pid/usr/local/webserver/ Nginx/nginx.pid, #Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess. Worker_rlimit_ nofile65535;events{useepoll;worker_connections65535;} Http{includemime.types;default_typeapplication/octet-stream;log_formatmain ' $remote _addr-$remote _user[$time _ Local] "$request" $status $body_bytes_sent "$http _referer" "$http _user_agent" $http _x_forwarded_for '; charsetgb2312;server_names_hash_bucket_size128;client_header_buffer_size32k;large_client_header_buffers432k; client_max_body_size8m;sendfileon;tcp_nopushon;keepalive_timeout60;tcp_nodelayon;fastcgi_connect_timeout300; Fastcgi_send_timeout300;fastcgi_read_timeout300;fastcgi_buffer_size64k;fastcgi_buffers464k;fastcgi_busy_ Buffers_size128k;fastcgi_temp_file_write_size128k;gzipon;gzip_min_length1k;gzip_buffers416k;gzip_http_version1.0;gzip_comp_level2;gzip_typestext/plainapplication/x-javascripttext/cssapplication/xml;gzip_varyon; #limit_ zonecrawler$binary_remote_addr10m, #下面是server虚拟主机的配置server {listen80; #监听端口server_namelocalhost; Domain name indexindex.htmlindex.htmindex.php;root/usr/local/webserver/nginx/html; #站点目录location ~.. (PHP|PHP5)? ${#fastcgi_passunix:/tmp/php-cgi.sock;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php; includefastcgi.conf;} location~.. (Gif|jpg|jpeg|png|bmp|swf|ico) ${expires30d; #access_logoff;} location~.*. (JS|CSS) ${expires15d; #access_logoff;} Access_logoff;}}
Check the correctness of the configuration file ngnix.conf command:
[[Email Protected]]#/usr/local/webserver/nginx/sbin/nginx-t
Start Nginx
The Nginx startup command is as follows:
[[Email Protected]]#/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-sreload# Reload configuration file/usr/local/webserver/nginx/sbin/nginx-sreopen# Restart nginx/ usr/local/webserver/nginx/sbin/nginx-sstop# Stop Nginx
Problem can add our Linux Learning Exchange Group: 422345477, into the group can exchange technical problems of the HA
Nginx installation configuration of Linux development