Dokumentasi untuk Lab Reverse Proxy with Nginx Centos 7
Instalasi & Konfigurasi:
Ketentuan:
# useradd wordpress # useradd prestashop # useradd nextcloud
# yum -y install httpd
Ubah agar apache listen pada 127.0.0.1 dan pada port 8080
# vim /etc/httpd/conf/httpd.conf
Disini kita merubah listen menjadi 127.0.0.1 agar apache tidak bisa diakses dari luar, karena webserver dan reverse proxy dalam 1 server yang sama dan kita merubah port menjadi 8080 agar tidak bentrok dengan nginx yang akan berjalan pada port 80
Tambahkan repo mariadb
# vim /etc/yum.repos.d/mariadb.repo
# MariaDB 10.1 CentOS repository # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Simpan dan keluar, selanjut nya install mariadb
# yum -y install mariadb-server
Start dan enable MariaDB
# systemctl start mariadb # systemctl enable mariadb
Kemudian setup MariaDB
# mysql_secure_installation
* Enter current password for root (enter for none): Just press the Enter * Set root password? [Y/n]: Y * New password: Enter password * Re-enter new password: Repeat password * Remove anonymous users? [Y/n]: Y * Disallow root login remotely? [Y/n]: Y * Remove test database and access to it? [Y/n]: Y * Reload privilege tables now? [Y/n]: Y
Selanjutnya install php, karena disini kita akan menggunakan 3 php dengan versi berbeda sekaligus, maka kita akan menggunakan php-fpm dan kita akan mengubah setiap port default ketiga php aga bisa berjalan secara bersamaan diwaktu yang sama
Install repositori php remi
# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
Lalu install php satu per satu
php 7.1
# yum install php71 php71-php-fpm php71-php-mysql php71-php-pdo php71-php-gd php71-php-mbstring php71-php-mcrypt php71-php-xml php71-php-zip php71-php-intl php71-php-process php71-php-apcu -y
php 7.2
# yum -y install php72 php72-php-fpm php72-php-pdo php72-php-mysqlnd php72-php-opcache php72-php-xml php72-php-gd php72-php-devel php72-php-mysql php72-php-intl php72-php-mbstring php72-php-bcmath php72-php-json php72-php-iconv php72-php-soap php72-php-zip php72-php-mcrypt
php 7.3
# yum -y install php73 php73-php-fpm php73-php-pdo php73-php-mysqlnd php73-php-opcache php73-php-xml php73-php-gd php73-php-devel php73-php-mysql php73-php-intl php73-php-mbstring php73-php-bcmath php73-php-json php73-php-iconv php73-php-soap php73-php-zip php73-php-mcrypt
Konfigurasi php71. , buka www.conf
# vim /etc/opt/remi/php71/php-fpm.d/www.conf
Lalu tambahkan user dan group prestashop setelah apache, disini kita membuat agar webserver dapat mengakses direktory user
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache user chosen to provide access to the same directories as httpd user = apache user = prestashop ; RPM: Keep a group allowed to write in log dir. group = apache group = prestashop
Kemudian ubah listen port :9000 menjadi :9071
; Note: This value is mandatory. listen = 127.0.0.1:9071
Lakukan untuk kedua user lainnya juga, sesuaikan dengan task
Ubah settingan selinux dari enforcing menjadi permissive
# setenforce 0
Jalankan Service php
# systemctl start php71-php-fpm # systemctl enable php71-php-fpm # systemctl start php72-php-fpm # systemctl enable php72-php-fpm # systemctl start php73-php-fpm # systemctl enable php73-php-fpm
# yum -y install nginx
Start dan enable Nginx
# systemctl start nginx # systemctl enable nginx
Pertama kita harus mengubah userdir.conf agar apache dapat mengakses user direktory
# vim /etc/httpd/conf.d/userdir.conf
Ubah UserDir Disabled menjadi UserDir Enabled [nama user], jika lebih dari satu user maka tambahkan [nama user] setelah [nama user] sebelumnya. lihat gambar dibawah agar lebih jelas