Cara Install Lemp Di Ubuntu 16.04

Panduan cara install Nginx, MariaDB 10, PHP 7 (LEMP stack) di Linux Ubuntu 16.04 LTS Xenial Xerus, bila versi ini bukan yang Anda gunakan silahkan pilih tutorial lainnya di bawah ini:



Langkah 1 – Install MariaDB


Diawali dengan instalasi MariaDB


apt update -y && apt upgrade -y
apt install mariadb-server mariadb-client -y
mysql_secure_installation

Saat ada pertanyaan untuk password root MySQL tekan Enter saja, selanjutnya ikuti ibarat dibawah ini:


Enter current password for root (enter for none): Tekan Enter
Set root password? [Y/n] y (kemudian ketik password baru)
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Pastikan MariaDB auto start dikala mesin direstart


systemctl enable mariadb

Langkah 2 – Install PHP


Tambahkan repo PPA ondrej, semoga kita sanggup menginstall PHP versi terbaru (7.x)


apt install software-properties-common
add-apt-repository ppa:ondrej/php
apt update -y

Sekarang install PHP 7.2


apt install php7.2-mysql php7.2-fpm php7.2-common php7.2-soap php7.2-json php7.2-xml php7.2-cli php7.2-mbstring php7.2-gd php7.2-curl php7.2-opcache php7.2-readline php7.2-curl php7.2 -y

Kemudian


systemctl start php7.2-fpm
systemctl enable php7.2-fpm

Langkah 3 – Install Nginx


Instalasi terakhir ialah Nginx web server, sanksi perintah berikut


apt install nginx
systemctl start nginx
systemctl enable nginx

Langkah 4 – Konfigurasi Nginx – PHP-FPM


Edit konfigurasi Nginx virtual host


nano /etc/nginx/sites-available/default

Hapus semua konten yang ada di dalamnya ganti dengan konfigurasi berikut dan ubah idnetter.com dengan nama domain Anda


server {
listen 80;
listen [::]:80;
server_name idnetter.com www.idnetter.com;

location /error/ {
alias /usr/share/nginx/html/errors/;
}

root /var/www/html/;
index index.htm index.html index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

access_log /var/log/nginx/access_log;
access_log off;
error_log /var/log/nginx/error_log error;

error_page 403 = 404;
location /\. { access_log off; log_not_found off; deny all; }
location $ { access_log off; log_not_found off; deny all; }

location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }

gzip on;
gzip_comp_level 9;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types application/atom+xml application/j4vascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon image/png image/gif image/jpeg text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/xml
text/vtt text/x-component text/x-cross-domain-policy;

location * \.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires max; }
location * \.(woff|svg)$ { access_log off; log_not_found off; expires 30d; }
location * \.(js)$ { access_log off; log_not_found off; expires 7d; add_header Cache-Control "public, no-transform"; }

location \.php?$ {
try_files $uri = 404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_hide_header X-Powered-By;
}
}

Simpan, Ctrl+O > Enter > Ctrl+X


Selesai, selamat mencoba kawan.



Sumber https://idnetter.com

Mari berteman dengan saya

Follow my Instagram _yudha58

Subscribe to receive free email updates:

0 Response to "Cara Install Lemp Di Ubuntu 16.04"

Posting Komentar