#!/usr/bin/ruby puts

SunDi3yansyah


puts

App Server, Database App, Web App

Cara Menambah Virtual Hosts Di Nginx

| Comments | Cahyadi Triyansyah Cahyadi Triyansyah

Kalau sebelumnya saya sudah menejalaskan tentang Cara Install Nginx, MySQL, PHP Di CentOS, sekarang bagaimana jika kita ingin menambahkan domain kita ke server yang pada tempo lalu sudah di install NGINX dan kawan-kawannya? Yah… tulisan & video di bawah ini yang akan menjawab, ini real saya praktekan langsung di domain saya, namun nama domain tsb adalah nama Nick teman saya smile

Langsung saja ke videonya.

Anda bisa melihat command line di bawah ini untuk mengikuti dari recorder di atas.

Direktori root bisa dimana saja, silakan disesuaikan

1
mkdir -p /srv/www/formatdongkrak.com/logs

for security secure, keep using chown root

1
nano /etc/php.ini

press on the keyboard CTRL+W find

1
cgi.fix_pathinfo

you will see like this

1
;cgi.fix_pathinfo=0

replace

1
cgi.fix_pathinfo=0
1
mkdir /etc/nginx/sites-available
1
mkdir /etc/nginx/sites-enabled
1
nano /etc/nginx/nginx.conf

add the code below, to the bottom before the closing }

1
include /etc/nginx/sites-enabled/*;
1
nano /etc/nginx/sites-available/formatdongkrak.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
    server_name formatdongkrak.com;
    access_log /srv/www/formatdongkrak.com/logs/access.log;
    error_log /srv/www/formatdongkrak.com/logs/error.log;
    root /srv/www/formatdongkrak.com;

    location / {
        index index.php index.html index.htm;
    }
    location ~ .php$ {
        include fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}
1
cd /etc/nginx/sites-enabled/
1
ln -s /etc/nginx/sites-available/formatdongkrak.com
1
service nginx restart
1
nano /srv/www/formatdongkrak.com/info.php

If permission denied

1
cd /srv/www
1
find . -type d | while read folder ; do chmod 755 "$folder" ; done
1
find . -type f | while read file ; do chmod 644 "$file" ; done
Comments