Cara Install LEMP – Nginx, MySQL, PHP di Ubuntu 14.04

Artikel ini merupakan panduan cara install LEMP – Nginx, MySQL, PHP di Ubuntu 14.04 untuk membangun website di VPS. Sebagai bahan tutorial LEMP web server untuk kolom Ubuntu saya belum lama ini membeli VPS dengan harga kurang dari $1 di interserver.net dengan spek sebagai berikut:

Spesifikasi VPS

  • 1 CPU Core
  • 1GB RAM
  • 1 IPv4
  • OS Ubuntu 14.04
  • Kode Promo : 1CENT
  • Beli

Temukan harga VPS Murah lainya di: Kumpulan VPS Promo Murah Untuk 1 Bulan

Langkah-langkahnya sebagai berikut gan:

Update System

Update system dulu gan buat pemanasan

apt-get update

Install Nginx

Stop layanan apache2 kemudian remove apache2 dari system dan kita akan menggunakan nginx saja

/etc/init.d/apache2 stop
apt-get remove apache2* -y
apt-get autoremove
apt-get install nginx -y

Start nginx service

Selesai install nginx, ketik perintah berikut untuk menjalankan nginx

service nginx start

Buka browser, ketik IP anda ntar munculnya kira-kira seperti ini:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

Konfigurasi Nginx

Buka file /etc/nginx/sites-available/default sesuaikan, lihat yang berwarna merah

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name idnetter.com;

    location / {
        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Install MySQL

Selanjutnya install dan konfigurasi mySQL

apt-get install mysql-server -y

Kemudian akan muncul dialog yang meminta password baru root untuk akses ke MySQL, seperti screenshot dibawah ini, langsung aja ketik password yang anda inginkan, dilanjut tekan Enter.

Cara Install LEMP – Nginx, MySQL, PHP di Ubuntu 14.04

 

Nanti akan muncul lagi konfirmasi password baru root untuk SQL yang anda buat tadi, langsung aja ketik ulang trus Enter,

konfigurasi mysql

Selesai installasi dilanjut ketik perintah berikut untuk membuat dtruktur direktori  yang dibutuhkan untuk menyimpan informasi database.

mysql_install_db

Selanjutnya selesaikan dengan mysql_secure_installation, ketik perintah berikut:

mysql_secure_installation

Saat pertama nanti muncul dialog untuk memasukkan password root MySQL, ketik aja password yang kita buat tadi trus Enter.

Enter current password for root (Enter for none) :

Langkah selanjutnya, setiap ada pertanyaan jawab sama dengan yang dibawah ini, yang berwarna merah:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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 MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
... 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? [Y/n] y
... Success!

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? [Y/n] y
... Success!

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? [Y/n] y
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
... Failed!  Not critical, keep moving...
- 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? [Y/n] y
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Install PHP

Dan yang terkahir adalah install dan konfigurasi PHP serta dilanjut module-module PHP yang diperlukan untuk membangun website.

apt-get install php5-fpm php5-mysql -y

Install module PHP

apt-get install php-apc php-pear php-soap php5-gd php5-imagick php5-imap php5-ldap php5-odbc php5-xmlrpc php5-mcrypt php5-mssql php5-curl -y

Konfigurasi PHP

Buka file konfigurasi PHP /etc/php5/fpm/php.ini

nano  /etc/php5/fpm/php.ini

Temukan bagian ini, dan sesuaikan

cgi.fix_pathinfo = 0
date.timezone = Asia/Jakarta
expose_php = Off

Restart service

service php5-fpm restart
service nginx restart

Test

Buat file baru info.php pada direktori utama website yaitu di: /usr/share/nginx/html

nano /usr/share/nginx/html/info.php

Tambahkan kode berikut:

<?php phpinfo();

Ctrl+X kemudian y

Buka broser ketik IP anda misalnya: http://127.0.0.1/info.php

Alhamdulillah tutorial install LEMP di Ubuntu 14.04 selesai.

Met mencoba gan.




Share this post:

Leave a Reply

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