Cara install LAMP di Ubuntu 16.04

By | April 12, 2018

Panduan cara install Apache, MariaDB/MySQL, PHP (LAMP stack) di Linux Ubuntu 16.04. Bagi memulai panduan ini untuk teman-teman pengguna windows, silahkan memakai program Putty.

Langkah 1 – Update system

Biasakan update system linux dengan menjalankan baris command berikut. Command dengan opsi -y = yes agar nanti tak perlu konfirmasi ulang menekan huruf y.

apt-get update -y

Langkah 2 – Install Apache

apt-get install apache2 -y
systemctl enable apache2

Cek via browser http://ip/, kalau sukses, ada tulisan It works!.

Langkah 3 – Install MariaDB/MySQL

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

Instalasi bagi MariaDB

apt-get install mariadb-server

Sekiranya ingin MySQL selaku database (tak disarankan)

apt-get install mysql-server

Berikutnya yaitu menigkatkan keamanan instalasi MariaDB/MySQL, seperti mengatur password dan lain-lain.

mysql_secure_installation

Ada beberapa pertanyaan yang perlu dijawab, dan diantaranya selaku 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 ketika mesin restart

bagi MariaDB

systemctl enable mariadb

bagi MySQL

systemctl enable mysql

Langkah 4 – Install PHP

Langkah berikutnya, 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

Bikin file informasi.php bagi mengecek kesuksesan dari panduan ini.

nano /var/www/html/informasi.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 via browser http://ip/informasi.php

 

Selesai, selamat mencoba 😀


Sumber https://idnetter.com