Setup Linux, Nginx, MySQL, PHP (LEMP) di Centos 7

Setup Linux, Nginx, MySQL, PHP (LEMP) di Centos 7

Kalau abis beli vps baru kadang bingung kan apa dulu yang mau di install? wkwk. Nih gue udah tulisin step step yang biasanya gue lakuin pas mau setup server Linux yang ntar bakal diisi Nginx, Mysql sama PHP. Kenapa Centos? karena dari pemerintahan bro 😂. Tapi server kantor gue dulu pake Ubuntu, tapi karena mau pake DRC di Alibabacloud yang ternyata cuman support Centos, jadinya setup ulang pake Centos.

  1. Yang pertama set localtime ke waktu tempate lo berada. Kalau gue biasanya Asia/Jakarta.
    timedatectl set-timezone Asia/Jakarta
  2. Install extra package buat Centos
    yum install epel-release -y
  3. Install NGINX
    yum install nginx -y
  4. Enable NGINX
    systemctl enable nginx
  5. Buat database, yang dari repo centos adanya cuman MariaDB. Cara install maria db :
    yum install mariadb-server mariadb
    systemctl start mariadb
    mysql_secure_installation
    systemctl enable mariadb
  6. Kalau yang udah biasa pake Mysql, harus lewatin beberapa step. Cara install mysql community :
    rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
    sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
    yum --enablerepo=mysql80-community install mysql-community-server -y
    service mysqld start
    grep "A temporary password" /var/log/mysqld.log
    mysql_secure_installation
  7. Next, install PHP. Disini gue mau install php 7.4, kalo lo mau install versi lain, tinggal ganti ke versi yang lo pengen.
    yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
    yum --disablerepo="*" --enablerepo="remi-safe" list php[7-9][0-9].x86_64
    yum install yum-utils -y
    yum-config-manager --enable remi-php74
    yum install php php-mysqlnd php-fpm php-common php-xml php-mbstring php-json php-zip php-gd -y
    nano /etc/php-fpm.d/www.conf
    set user ke nginx dan listen = /var/run/php-fpm/php-fpm.sock
    systemctl start php-fpm
  8. Bikin config nginx buat arahin ke folder selain default. Kalau mo pake default, ga usah bikin.
  9. systemctl restart nginx
  10. Kalau lo pake laravel kayak gue, perlu installin composer sekalian
    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer
    chmod +x /usr/local/bin/composer
  11. Kalau lo mo pake buat React atau perlu node, sekalian dah installin
    curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
    yum install nodejs
  12. Nah tinggal aktifin firewallnya
    firewall-cmd --zone=public --add-service=http
  13. Kalau yang ga mau ribet setup SELinux, di disable aja
    sudo setenforce 0

Set localtime
Tampilan kalo udah kelar
Set password MariaDB
Ali Akbar

Gue programer B)

Leave a reply