Instalasi Nginx dan membuat multiple vhost di Centos7
Step1#:Install repositori EPEL
[root@centos7 centos]#yum install epel-release
[root@centos7 centos]#yum install nginx
[root@centos7 centos]#systemctl enable nginx
[root@centos7 centos]#systemctl start nginx
[root@centos7 centos]#systemctl status nginx
Jika server dilindungi oleh firewall, buka port HTTP (80) dan HTTPS (443). Gunakan perintah berikut
[root@centos7 centos]#firewall-cmd --permanent --zone=public --add-service=http
[root@centos7 centos]#firewall-cmd --permanent --zone=public --add-service=https
[root@centos7 centos]#firewall-cmd --reload
Step2#:Install Vhost
Supaya bisa menggunakan virtual host, perlu ubah konfigurasi nginx, ikuti instruksi di bawah ini.
[root@centos7 centos]# vim /etc/nginx/nginx.conf
Tambah script persis di bawah “include /etc/nginx/conf.d/*.conf;”
include /etc/nginx/sites-enabled/*;
ini agar konfigurasi virtual host yang dilakukan di sites-available dan sites-enabled dapat dibaca oleh Nginx.
Step3#:Buat Directory
[root@centos7 centos]# mkdir -p /etc/nginx/sites-available/
[root@centos7 centos]# mkdir -p /etc/nginx/sites-enabled/
ubah ownership dan permissionnya:
[root@centos7 centos]# chmod 755 /etc/nginx/sites-available/
[root@centos7 centos]# chmod 755 /etc/nginx/sites-enabled/
Step4#:Buat Directory
[root@centos7 centos]# mkdir -p /var/www/cbtbidan
[root@centos7 centos]# mkdir -p /var/www/cbt
[root@centos7 centos]# mkdir -p /var/www/cbtgizi
Step5#:Ubah ownership dan permissionnya:
[root@centos7 centos]# chown -R nginx:nginx /var/www/cbtbidan
[root@centos7 centos]# chown -R nginx:nginx /var/www/cbt
[root@centos7 centos]# chown -R nginx:nginx /var/www/cbtgizi
[root@centos7 centos]# chmod -R 755 /var/www/
Step6#:Buat file html
[root@centos7 centos]# vim /var/www/cbt/index.html
[root@centos7 centos]# vim /var/www/cbt/index.html
[root@centos7 centos]# cp /var/www/cbt/index.html /var/www/cbtgizi/index.html
[root@centos7 centos]# cp /var/www/cbt/index.html /var/www/cbtbidan/index.html
[root@centos7 centos]# vim /var/www/cbtgizi/index.html
[root@centos7 centos]# vim /var/www/cbtbidan/index.html
[root@centos7 centos]# vim /var/www/cbtbidan/index.html
Step7#:Buat Konfigurasi Domainnya
[root@centos7 centos]# vim /etc/nginx/sites-available/cbt
[root@centos7 centos]# vim /etc/nginx/sites-available/cbtgizi
[root@centos7 centos]# vim /etc/nginx/sites-available/cbtbidan
Step8#:Buat Symlink
[root@centos7 centos]# ln -s /etc/nginx/sites-available/cbt /etc/nginx/sites-enabled/
[root@centos7 centos]# ln -s /etc/nginx/sites-available/cbtbidan /etc/nginx/sites-enabled/
[root@centos7 centos]# ln -s /etc/nginx/sites-available/cbtgizi /etc/nginx/sites-enabled/
Step9#:Mengetahui ada syntax error pada konfigurasi diatas
[root@centos7 centos]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@centos7 centos]# systemctl restart nginx
Step10#:Cek log
tail -n 20 /var/log/nginx/error.log
Step11#:contoh error
solusidisable SELinux
vim /etc/selinux/config
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
reboot kemudian cek selinux
#SESTATUS
Belum ada Komentar untuk "Instalasi Nginx dan membuat multiple vhost di Centos7"
Posting Komentar