Anda di halaman 1dari 26

Cara Install Nginx, MySQL, dan

PHP (FEMP) di FreeBSD 9.3


Created on 10 November 2015. Author: M. Rafi ul Ilmi S.
Su mber : http s:/ /www.d ig ita lo c ea n.co m/ co mmun ity/ tu to rials/ ho w- to -ins ta ll- an- nginx-m ysq l- and php -femp- stac k- on- fr eebs d-1 0- 1

Apa itu Nginx, MySQL, dan PHP (FEMP) ?


Nginx (baca: engine x) adalah server HTTP dan Proxy dengan kode sumber terbuka
yang bisa juga berfungsi sebagai proxy IMAP/POP3. Kode sumber nginx ditulis oleh
seorang warga negara Rusia yang bernama Igor Sysoev pada tahun 2002 dan dirilis
ke publik pada tahun 2004. Nginx terkenal karena stabil, memiliki tingkat
performansi tinggi dan minim mengonsumsi sumber daya (RAM).
Mysql adalah sebuah server database open source yang terkenal yang digunakan
berbagai aplikasi terutama untuk server atau membuat WEB. Mysql berfungsi
sebagai SQL (Structured Query Language) yang dimiliki sendiri dan sudah diperluas
oleh Mysql umumnya digunakan bersamaan dengan PHP untuk membuat aplikasi
server yang dinamis dan powerfull.
PHP is a server-side scripting language designed for web development but also
used as a general-purpose programming language.

Introduction
Nginx, MySQL, and PHP can be combined together easily as a powerful solution for
serving dynamic content on the web. These three pieces of software can be
installed and configured on a FreeBSD machine to create what is known as a FEMP
stack.
In this guide, we will demonstrate how to install a FEMP stack on a FreeBSD 9.3
server. We will be installing the software using packages in order to get up and
running more quickly. These packages provide reasonable defaults that work well
for most servers.

Install The Components

Configure PHP

Cari listen = 127.0.0.1:9000 Dengan cara, ctrl+y untuk mengaktifkan fungsi


find, lalu ketik listen". Jika masih belum ditemukan, tekan Ctrl+x sampai
ditemukan.

Tambahkan ; sebelum listen dan tambahkan listen = /var/run/php-fpm.sock


dibawah ;listen = 127.0.0.1:9000

Cari :
;listen.owner = www
;listen.group = www

;listen.mode = 0660
Kemudian jadikan semuanya enable dengan cara menghapus ; .

Setelah itu Save and Close . Tekan Esc pilih > leave editor > Save .
Kita butuh php.ini dan kita bisa copy php.ini-production sebagai php.ini

Configure MySQL

Tekan Enter

Configure Nginx

user www;
worker_processes
error_log

1;

/var/log/nginx/error.log info;

events {
worker_connections
}
http {
include
default_type
access_log

mime.types;
application/octet-stream;

/var/log/nginx/access.log;

sendfile

on;

server {
listen
server_name
root
index

1024;

80;
localhost;

/usr/local/www/nginx;
index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}
error_page
500 502 503 504 /50x.html;
location = /50x.html {
root
/usr/local/www/nginx-dist;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}

Tambahkan user www; dan cek nilai untuk worker_processes x; dengan perintah
sysctl hw.ncpu

hw.ncpu: 1 maka worker_processes 1;

Selanjutnya buat settings-nya sesuai dengan yang diatas.


note: jelaskan satu satu.
Kemudian Save.

Kemudian buat file access.log dan eror.log


touch /var/log/nginx/access.log
touch /var/log/nginx/error.log

Test Page info.php

Save
Check Syntax nginx apakah sudah benar, nginx t . Jika sudah benar, maka restart
nginx.

Lalu cek di webbrowser. Ini tampilan jika nginx berjalan mulus.


http://ip_servermu

Dan ini jika php-fpm berjalan

http://ip_servermu/info.php

Anda mungkin juga menyukai