Cara Install LEMP Server (Nginx, MariaDB, PHP, phpMyAdmin) di Ubuntu

-Install Nginx-

Perintah install nginx

[INPUT]

1 sudo apt-get install nginx

Jalankan serive nginx

[INPUT]

1 sudo service nginx start

Test di browser dengan mengakses *http://localhost* atau *http://IP-ADDRESS*

Konfigurasi virtual host, buka file */etc/nginx/sites-available/default*

[INPUT]

1 sudo nano /etc/nginx/sites-available/default

Cari baris

[INPUT]

1 2 3 4 5 6 server {         listen 80 default_server;         listen [::]:80 default_server ipv6only=on;           root /usr/share/nginx/html;         index index.html index.htm;

*root* : document root directory, biasanya kalau memakai Apache lokasinya di /var/www/ *index* : file yang menjadi index pada directory atau file yang pertama dibaca dalam directroy. tambahkan index.php

[INPUT]

1 index index.php index.html index.htm;

Selanjutnya untuk *pembacaan file .php*, cari baris *location ~ .php*. Lepas tanda komentar seperti pada kode dibawah ini.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 location ~ .php$ {          try_files $uri =404;   ———> Tambahkan baris ini          fastcgi_split_path_info ^(.+.php)(/.+)$;          #       # NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini          #          #       # With php5-cgi alone:          #       fastcgi_pass 127.0.0.1:9000;          #       # With php5-fpm:          fastcgi_pass unix:/var/run/php5-fpm.sock;          fastcgi_index index.php;          include fastcgi.conf;     }

Uji coba konfigurasi nginx

[INPUT]

1 sudo nginx -t

Hasilnya

[INPUT]

1 2 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx

[INPUT]

1 sudo service nginx restart

-Install PHP-

[INPUT]

1 sudo apt-get install php5 php5-fpm php5-mysql

Konfigurasi PHP, buka file *php.ini*

[INPUT]

1 sudo nano /etc/php5/fpm/php.ini

Cari baris *cgi.fix_pathinfo=1*, lepas komentar dan ubah nilainya menjadi 0

[INPUT]

1 cgi.fix_pathinfo=

Restart fpm service

[INPUT]

1 sudo service php5-fpm restart

Uji coba file PHP

[INPUT]

1 sudo nano /usr/share/nginx/html/test.php

Masukkan kode phpinfo

[INPUT]

1

Akses *http://localhost/test.php*, hasilnya

-Install MariaDB-

[INPUT]

1 sudo apt-get install mariadb-server mariadb-client

Masukkan password user root database

Ulangi password

Uji coba login ke MariaDB

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 mysql -u root -p Enter password: Welcome to the MariaDB monitor.  Commands end with ; or g. Your MariaDB connection id is 56 Server version: 5.5.41-MariaDB-1ubuntu0.14.04.1 (Ubuntu)   Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.   Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.   MariaDB [(none)]>

-Install phpMyAdmin-

[INPUT]

1 sudo apt-get install phpmyadmin

Pilih Yes

Pilih saja apache2, nanti dikonfigurasi agar terhubung ke nginx

Masukkan password database administrative user

Masukkan password untuk phpMyAdmin

Ulangi password

Buat link agar terhubung ke folder nginx

[INPUT]

1 sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html

Uji coba masuk ke phpMyadmin, *http://localhost/phpmyadmin*

selamat mencoba 🙂

Leave a Reply

Your email address will not be published.