Cara Install Nginx di Centos 5 dan 6

 CentOS, Tutorial, Webserver

cara install nginx pada centos logo

Tutorial cara install nginx webserver pada centos 5 dan centos 6

  1. Add repo
    • Untuk centOS 5

      rpm -Uvh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm

    • Untuk CentOS 6

      rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

  2. Install Nginx via yum

    yum install nginx

    Contoh config nginx (/etc/nginx/nginx.conf)

    user  nginx;
    worker_processes  auto;
    
    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       /etc/nginx/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"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
        gzip  on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
        server_tokens off;
    
        include /etc/nginx/conf.d/*.conf;
    }
    
  3. Jalankan nginx webserver (start nginx)

    service nginx start

    cara install nginx pada centos
    Untuk stop atau restart nginx:

    service nginx stop
    service nginx restart

  4. Autostart Nginx

    chkconfig nginx on