Persiapan konfigurasi VPS Instalasi LAMPP

 Install LAMPP

Update Server

Login sebagai root ke server, kemudian perbarui versi server dan reboot.

 

$ apt-get update -y

$ reboot

 

Instalasi package yang dibutuhkan.

$ apt-get install perl git nano wget -y

 

Install Firewall

Firewall yang digunakan dalam instalasi ini adalah Config Security & Firewall (CSF).

 

$ cd /usr/src

$ wget https://download.configserver.com/csf.tgz 

$ tar -xzf csf.tgz

$ cd csf/

$ install.sh

Edit csf.conf lalu ubah value make TESTING menjadi 0.

 

$ nano /etc/csf/csf.conf

make TESTING=’0’

 

Simpan lalu keluar.

 

Muat ulang CSF dengan perintah di bawah ini.

 

$ csf -r

 

Install Apache Web Server

Mengingat kita menggunakan LAMP Stack untuk mengelola website, maka kamu wajib menggunakan Apache web server. Gunakan perintah berikut:

 

$ apt-get install apache2 -y

 

Start dan enable on-boot untuk apache.services:

$ systemctl enable apache2

$ systemctl start apache2

 

Cek status Apache, apakah sudah aktif atau belum.

$ systemctl status apache2
  •  apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:

  Drop-In: /lib/systemd/system/apache2.service.d

           └─apache2-systemd.conf

   Active: active (running) since Sat 2020-09-26 18:12:33 UTC; 34s ago

 Main PID: 3201 (apache2)

    Tasks: 55 (limit: 1152)

   CGroup: /system.slice/apache2.service

           ├─3201 /usr/sbin/apache2 -k start

           ├─3204 /usr/sbin/apache2 -k start

           └─3205 /usr/sbin/apache2 -k start

 

Install MariaDB Database Server

Saat ini, MariaDB adalah sistem pengelola database yang paling up-to-date dan cukup kompatibel untuk kamu gunakan. Ikuti perintah berikut untuk menginstal MariaDB.

$ apt-get install mariadb-server mariadb-client

 

Start dan enable on-boot untuk layanan MariaDB dan kemudian lakukan secure installation.

$ systemctl enable mariadb

$ systemctl start mariadb




$ mysql_secure_installation




Enter current password for root (enter for none): 

OK, successfully used password, moving on...




Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.




Set root password? [Y/n] y

New password: 

Re-enter new password: 

Password updated successfully!

Reloading privilege tables..

 ... Success!




Remove anonymous users? [Y/n] y

 ... Success!




Disallow root login remotely? [Y/n] y

 ... Success!




Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!




Reload privilege tables now? [Y/n] y

 ... Success!




Cleaning up...




All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.




Thanks for using MariaDB!


Kamu bisa langsung menekan Enter pada current password for root, kemudian pilih Y pada set root password dan terus pilih Y hingga proses pengamanan selesai. Setelah itu, cek apakah MariaDB sudah aktif atau belum.

$ systemctl status mariadb
  •  mariadb.service - MariaDB 10.1.44 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset:

   Active: active (running) since Sat 2020-09-26 18:14:34 UTC; 2min 22s ago

     Docs: man:mysqld(8)

           https://mariadb.com/kb/en/library/systemd/

 Main PID: 4321 (mysqld)

   Status: "Taking your SQL requests now..."

    Tasks: 27 (limit: 1152)

   CGroup: /system.slice/mariadb.service

           └─4321 /usr/sbin/mysqld

 

Baca Juga: Cara Install LAMP Stack di CentOS 7

Install PHP 7.2

Selanjutnya, pada cara install LAMP Stack di Ubuntu 18.04 ini, kami menggunakan PHP dengan versi 7.2. Maka kamu perlu menginstal PHP 7.2 serta beberapa ekstensi yang dibutuhkan dengan cara berikut.

$ apt-get install php7.2 php7.2-fpm php7.2-mysql php-common php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl libapache2-mod-php -y

 

Start dan enable on-boot untuk PHP 7.2-FPM.

$ systemctl enable php7.2-fpm

$ systemctl start php7.2-fpm

 

Cek apakah php7.2-fpm sudah aktif atau belum menggunakan perintah berikut:

$ systemctl status php7.2-fpm
  •  php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor prese

   Active: active (running) since Sat 2020-09-26 18:18:45 UTC; 4min 21s ago

     Docs: man:php-fpm7.2(8)

 Main PID: 15259 (php-fpm7.2)

   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/se

    Tasks: 3 (limit: 1152)

   CGroup: /system.slice/php7.2-fpm.service

           ├─15259 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)

           ├─15274 php-fpm: pool www

           └─15275 php-fpm: pool www

 

Agar Apache2 dampat membaca berkas dengan mengutamakan ekstensi index.php, perhatikan perintah berikut:

$ nano /etc/apache2/mods-enabled/dir.conf

Sebelum:

<IfModule mod_dir.c>

    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

 

Sesudah:

<IfModule mod_dir.c>

    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

</IfModule>

 

Configure PHP.ini

Buka file PHP ini dan php-fpm configuration. Ubah konfigurasi sesuai dengan yang di bawah ini.

$ nano /etc/php/7.2/fpm/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0


$ nano /etc/php/7.2/cli/php.ini

;cgi.fix_pathinfo=1 menjadi cgi.fix_pathinfo=0


Kemudian simpan dan keluar.

 

Setting Virtual Host Apache

Ketika menggunakan Apache web server, kamu bisa menggunakan virtual host (sama seperti server blocks di Nginx Web Server). Hal ini berguna jika kamu ingin menggunakan lebih dari satu domain pada server. Path untuk virtual host-nya berada pada “/etc/apache2/sites-available/”. Ubah nama domain dari perintah berikut sesuai dengan nama domain yang kamu gunakan.

$ nano /etc/apache2/sites-available/lampubuntu.dewiweb.net.conf

 

Masukkan script di bawah ini:

<VirtualHost *:80>

    ServerAdmin admin@dewiweb.net

    ServerName lampubuntu.dewiweb.net

    ServerAlias www.lampubuntu.dewiweb.net

    DocumentRoot /var/www/html/

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

 

Aktifkan file dengan a2ensite tool:

$ a2ensite lampubuntu.dewiweb.net.conf

Enabling site lampubuntu.dewiweb.net.

To activate the new configuration, you need to run:

  systemctl reload apache2




Disable default site pada 000-default.conf:

$ a2dissite 000-default.conf


Tes hasil konfigurasi:

$ apache2ctl configtest

 

Kemudian akan muncul output berikut ini:

Syntax OK

 

Kemudian reload dan restart Apache dengan perintah:

$ systemctl reload apache2

$ systemctl restart apache2

 

Testing

Gunakan file info.php pada path directory yang kamu atur di Nginx server block sebelumnya.

$ nano /var/www/html/info.php

 

Masukkan script di bawah ini:

<?php phpinfo(); ?>

 

Simpan dan keluar, lalu coba akses domainmu. Jika tampilannya sudah seperti ini, berarti kamu telah berhasil menyelesaikan cara install LAMP Stack di Ubuntu 18.04.

==================================================

sumber:

Tutorial Cara Install LAMP Stack di Server dengan Ubuntu 18.04 (dewaweb.com)

Posting Komentar untuk "Persiapan konfigurasi VPS Instalasi LAMPP"