Installing Nginx in Linux

Source: Internet
Author: User

1. Install the compiled files and library files

  Yum -y install make zlib zlib-devel gcc-c+ + libtool OpenSSL OpenSSL-devel

2, the installation of Pcre,nginx rewrite pseudo-static matching rules need to use the regular expression, Pcre is to play this role.

: wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

If wget is not installed, the Wget,yum-y install wget is required first. Wget is a download tool in the Linux environment. Use of the wget command see this article: http://www.cnblogs.com/cindy-cindy/p/6847502.html

3, Decompression Pcre installation package: TAR-ZXVF pcre-8.35.tar.gz

4, enter the installation directory, compile and install

CD pcre-8.35

./configure

Make && make install

5. View Pcre Version

  Pcre-config --version

6. Download Nginx

  wget http://nginx.org/download/nginx-1.6.2.tar.gz

7. Unzip and enter the installation package

8. Compile and install

   ./configure --prefix=/usr/local/ webserver/nginx ---http_stub_status_module --with< Span class= "pun" >-http_ssl_module --with -pcre=/usr/local/< Span class= "PLN" >src/pcre-8.35

/span> make

/span> make install

9. View Nginx Version

10. Nginx Configuration

1. Create a user with Nginx running

     /usr/sbin/groupadd www

     /usr/sbin/useradd -g www www

2, configure the nginx.conf, replace the/usr/local/webserver/nginx/conf/nginx.conf with the following content

User www www;worker_processes 2; #设置值和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 so 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 $body _bytes_sent" $http _re  Ferer "'" $http _user_agent "$http _x_forwarded_for";       #charset gb2312;  Server_names_hash_bucket_size 128;  Client_header_buffer_size 32k;  Large_client_header_buffers 4 32k;       Client_max_body_size 8m;  Sendfile on;  Tcp_nopush on;  Keepalive_timeout 60;  Tcp_nodelay on;  Fastcgi_connect_timeout 300;  Fastcgi_send_timeout 300;  Fastcgi_read_timeout 300;  Fastcgi_buffer_size 64k;  Fastcgi_buffers 4 64k;  Fastcgi_busy_buffers_size 128k; Fastcgi_temp_file_write_size 128k;   gzip on;  Gzip_min_length 1k;  Gzip_buffers 4 16k;  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 10m;    #下面是server虚拟主机的配置 server {listen; #监听端口 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_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;  } Access_log off; }}

3, check the correctness of nginx.conf configuration file

      /usr/local/webserver/nginx/sbin/nginx -t

4, about the configuration of Nginx connection number, please refer to the website: http://www.cnblogs.com/cindy-cindy/p/6847507.html

Installing Nginx in Linux

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.