Cara install LAMP di Ubuntu 16.04

Panduan cara install Apache, MariaDB/MySQL, PHP (LAMP stack) di Linux Ubuntu 16.04. Untuk memulai tutorial ini bagi teman-teman pengguna windows, silahkan memakai aplikasi Putty.

Langkah 1 – Update system

Biasakan update system linux dengan menjalankan baris perintah berikut. Perintah dengan opsi -y = yes agar nanti tidak perlu konfirmasi ulang menekan huruf y.

apt-get update -y

Langkah 2 – Install Apache

apt-get install apache2 -y
systemctl enable apache2

Cek melalui browser http://ip/, jika sukses, ada tulisan It works!.

Langkah 3 – Install MariaDB/MySQL

Ada dua opsi, silahkan pilih mau pakai MariaDB atau MySQL (rekomendasi pakai MariaDB saja)

Instalasi untuk MariaDB

apt-get install mariadb-server

Jika ingin MySQL sebagai database (tidak disarankan)

apt-get install mysql-server

Selanjutnya adalah menigkatkan keamanan instalasi MariaDB/MySQL, seperti mengatur password dan lain-lain.

mysql_secure_installation

Ada beberapa pertanyaan yang perlu dijawab, dan diantaranya sebagai berikut, lihat bagian yang saya warnai

Securing the MySQL server deployment.

Enter password for user root: ketik password kemudian tekan Enter

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: Enter saja

Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Enter saja

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

Pastikan service MariaDB/MySQL auto start saat mesin restart

untuk MariaDB

systemctl enable mariadb

untuk MySQL

systemctl enable mysql

Langkah 4 – Install PHP

Langkah selanjutnya, install PHP dan modul-modul yang umum di-install.

apt-get install php7.0 php7.0-common php7.0-mbstring php7.0-gd php7.0-mcrypt libapache2-mod-php7.0 php7.0-curl php7.0-zip php7.0-mysql

Buat file info.php untuk mengecek keberhasilan dari tutorial ini.

nano /var/www/html/info.php

Isi dengan baris kode berikut

<?php phpinfo();

Simpan, cara menyimpan di nano editor, dengan menekan Ctrl+O kemudian Ctrl+X

Kemudian kita perlu me-restart apache2,

systemctl restart apache2

Terakhir, cek melalui browser http://ip/info.php

 

Selesai, selamat mencoba 😀

5 of 5

from 1 ratings

Leave a Reply

Your email address will not be published. Required fields are marked *