Install Nginx in Linux and Nginx in Linux
1. Install the compilation file and Library File
Yum-y install make zlib-devel gcc-c ++ libtool openssl-devel
2. Install PCRE. Regular Expressions are required for pseudo-static matching rules of Nginx rewrite. PCRE serves this purpose.
: Wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
If wget is not installed, install wget and yum-y install wget. wget in Linux. For the use of the wget command, see this article: http://www.cnblogs.com/cindy-cindy/p/6847502.html
3. Unzip the pcre installation package: tar-zxvf pcre-8.35.tar.gz
4. Go to the installation directory and compile and install
Cd pcre-8.35
./Configure
Make & make install
5. view the pcre version
Pcre-config -- version
6. Download Nginx
Wget http://nginx.org/download/nginx-1.6.2.tar.gz
7. decompress and enter the installation package
8. Compile and install
./Configure -- prefix =/usr/local/webserver/nginx -- with-http_stub_status_module -- with-http_ssl_module -- with-pcre =/usr/local/src/pcre-8.35
Make
Make install
9. View Nginx version
10. Nginx Configuration
1. Create a user for Nginx running
/Usr/sbin/groupadd www
/Usr/sbin/useradd-g www
2. Configure nginx. conf and replace/usr/local/webserver/nginx/conf/nginx. conf with the following content:
User www; worker_processes 2; # the set value is consistent with the number of CPU cores error_log/usr/local/webserver/nginx/logs/nginx_error.log crit; # log location and Log Level pid/usr/local/webserver/nginx. pid; # Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events {use epoll; worker_connections 65535;} http {include mime. types; default_type application/octet-stream; log_format main '$ Remote_addr-$ remote_user [$ time_local] "$ request" ''$ status $ response" $ http_referer "'' "$ http_user_agent" $ http_x_forwarded_for '; # charset gb2312; Limit 128; listen 32 k; Listen 4 32 k; client_max_body_size 8 m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; Limit 300; Limit 64 k; fastcgi_buffers 4 64 k; Limit 128 k; Limit 128 k; gzip on; gzip_min_length 1 k; gzip_buffers 4 16 k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # limit_zone crawler $ binary_remote_addr 10 m; # below is the server virtual host configuration server {lis Ten 80; # listener port server_name localhost; # domain name index index.html index.htm index. php; root/usr/local/webserver/nginx/html; # site directory location ~. * \. (Php | php5 )? $ {# Fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.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 ;}}
3. Check the correctness of the nginx. conf configuration file.
/Usr/local/webserver/nginx/sbin/nginx-t
4. For the Nginx connection configuration, see the web site: http://www.cnblogs.com/cindy-cindy/p/6847507.html