Berikut ini adalah langkah-langkah yang biasa saya lakukan ketika instalasi LEMP di Ubuntu 14.04, bagi Anda yang mempunyai kebutuhan yang sama bisa mengikuti langkah-langkah berikut ini :
Langkah pertama : install Nginx
Install Nginx dengan perintah :
sudo apt-get install nginx
Nyalakan service Nginx dengan perintah :sudo service nginx start
Buka browser dan buka halaman http://localhost jika instalasi dilakukan dengan benar, maka akan muncul pesan pembuka Welcome to Nginx!Langkah kedua : lakukan pengaturan dan optimasi Nginx
Buka file konfigurasi Nginx dengan memasukkan perintah di terminal :
sudo nano /etc/nginx/nginx.conf
Kemudian rubah dan tambahkan bagian ini :
worker_processes auto;
worker_rlimit_nofile 100000;
worker_connections 4000;
use epoll;
multi_accept on;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
server_tokens off;
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
server {
limit_conn conn_limit_per_ip 10;
limit_req zone=req_limit_per_ip burst=10 nodelay;
}
client_body_buffer_size 128k;
client_header_buffer_size 3m;
large_client_header_buffers 4 256k;
client_body_timeout 3m;
client_header_timeout 3m;
client_max_body_size 1000M;
access_log off;
gzip on;
# gzip_static on;
gzip_min_length 10240;
gzip_comp_level 1;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
reset_timedout_connection on;
send_timeout 2;
keepalive_timeout 30;
keepalive_requests 100000;
Kemudian restart Nginx dengan perintah :
Buka file konfigurasi default vhost (server block) dengan memasukkan perintah di terminal : sudo service nginx restart
sudo nano /etc/nginx/sites-available/default
Kemudian rubah dan tambahkan bagian ini :
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
# # 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_params;
}
}
Langkah ketiga : lakukan test error konfigurasi Nginx
Kemudian restart Nginx dengan perintah :sudo nginx -t
Jika pengaturan Anda benar maka akan didapat sample output seperti ini :nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo service nginx restart
Langkah keempat : install MariaDBInstall MariaDB dengan perintah :
sudo apt-get install mariadb-server mariadb-client
Kemudian masukkan password Anda untuk MariaDB dan setelah installasi selesai, silahkan lakukan pengecekan dengan perintah :sudo mysql -v -u root -p
Langkah kelima : lakukan optimasi MariaDBMasukkan perintah :
sudo mysql -u root -p
MariaDB [(none)]> show variables like 'have_query_cache';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> show variables like 'query%';
+------------------------------+-----------+
| Variable_name | Value |
+------------------------------+-----------+
| query_alloc_block_size | 8192 |
| query_cache_limit | 4194304 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 268435456 |
| query_cache_strip_comments | OFF |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
| query_prealloc_size | 8192 |
+------------------------------+-----------+
8 rows in set (0.00 sec)
SET GLOBAL query_cache_size = 268435456;
SET GLOBAL query_cache_limit = 4194304;
SET GLOBAL query_cache_type = 1;
Kemudian rubah/tambahkan bagian /etc/mysql/my.cnf
query_cache_size = 268435456
query_cache_type = 1
query_cache_limit=4194304
Restart MariaDB dengan perintahservice mariadb restart
Post a Comment