Linux system installation configuration Nginx environment finishing

Source: Internet
Author: User


PHP in these environments under Linux has also been a lot of times, every reload to find these documents, memory is not good, or to organize their own.

Nginx Installation

# yum-y Install gcc* pcre glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel lrzsz

# groupadd www &am p;& useradd www-g www

# wget http://nginx.org/download/nginx-1.6.1.tar.gz

# tar ZXVF nginx-1.6.1.tar.gz

# cd nginx-1.6.1

#/configure--user=www--group=www--prefix=/usr/local/webserver/ Nginx--with-http_stub_status_module--with-http_ssl_module--error-log-path=/data/logs/nginx/error.log-- Http-log-path=/data/logs/nginx/access.log

# make && make install

Machine for Aliyun 512MCentOS, just initialized the machine found no make command, through the Yum installation can be.

# yum-y Install make

Common operations

--Root soft connection to nginx.conf
# ln-s/usr/local/webserver/nginx/conf/nginx.conf/root/nginx.conf
- Direct restart script in root directory
# echo-e ' #!/bin/bash \n/usr/local/webserver/nginx/sbin/nginx-s reload ' >>/root/nginx_resta rt.sh
--Add Execute Permissions
# chmod +x/root/nginx_restart.sh
--Add to self-start
# echo '/usr/local/webserver/ Nginx/sbin/nginx ' >>/etc/rc.local
start nginx
#/usr/local/webserver/nginx/sbin/nginx
- Detect if the configuration file is correct
#/usr/local/webserver/nginx/sbin/nginx-t
-reboot nginx
#/usr/local/webserver/ Nginx/sbin/nginx-s Reload
nginx.conf

Configuration example, through Vhost to configure a new site, to avoid nginx.conf files too long, inconvenient to manage.

# more /root/nginx.conf  user  www www;

worker_processes  1;

  error_log  logs/error.log;

pid        logs/nginx.pid;

  events {    use epoll;

    worker_connections  1024;

}   http {    include       mime.types;

    default_type  application/octet-stream;

      server_names_hash_bucket_size 128;

    client_header_buffer_size 32k;

    large_client_header_buffers 4 32k;

    client_max_body_size 50m;       log_format  main   ' $remote _addr -  $remote _user  [$time _local]  "$request"   '                        ' $status   $body _bytes_sent  ' $ Http_referer " "                

        ' "$http _user_agent"   "$http _x_forwarded_for";

    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;

      include vhost/*.conf; }

Add 80 ports

server {

listen;

server_name localhost;

Index index.htm index.html index.php;

root/data/www;

Access_log/data/logs/nginx/default.access.log;

}

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.