[root@prayoga www]# mkdir -p alecsite.com/{htdocs,logs,status}
buat file vhost :
[root@prayoga www]# nano /etc/nginx/conf.d/alecsite.com.conf isi file konfigurasi sebagai berikut : server { listen 80; server_name alecsite.com; access_log /usr/share/nginx/html/alecsite.com/logs/access.log ; error_log /usr/share/nginx/html/alecsite.com/logs/error.log ; location / { root /usr/share/nginx/html/alecsite.com/htdocs; index index.php index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html/alecsite.com/htdocs; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; root /usr/share/nginx/html/nalecsite.com/htdocs; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/alecsite.com/htdocs$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
restart php-fpm dan nginx
[root@prayoga www]# /etc/init.d/php-fpm restart [root@prayoga www]# /etc/init.d/nginx restart
testing :
buat file index.html pada /usr/share/nginx/html/alecsite.com/htdocs
[root@prayoga www]# nano /usr/share/nginx/html/alecsite.com/htdocs/index.html
isi dengan :
Selamat datang di webserver baruku :)
simpan dan akses dari browser.
=============================================================
Jika saat mengakses menemui error seperti berikut : error 403 Forbidden
Periksa permission direktori :
[root@prayoga www]# ls -la /usr/share/nginx/ total 20 drwxr-xr-x 5 root root 4096 Mar 28 01:22 . drwxr-xr-x 64 root root 4096 Mar 28 01:04 .. drwxr-xr-x 2 root root 4096 Mar 28 20:17 html
direktori html dan direktori di dalam html harus 755 serta filenya harus 644
0 comments:
Post a Comment