Install Nginx, PHP5+PHP-FPM, MySQL di Ubuntu 11.04 Natty
Halo.. ,
Seperti biasa saya membuat artikel ini bertujuan untuk contekan pribadi saya, tapi kalo temen-temen membutuhkan artikel semacam ini.. ya silahkan diperdayagunakan.. hehehe.. langsung aja deh..
Dalam Artikel ini saya menggunakan mesin ubuntu Natty 11.04
1. Menjadi Akses root
$ sudo su
2. Install MySQL
# apt-get install mysql-server mysql-client
New password for the MySQL “root” user: <— isikan password untuk akses root pada akun mysql (password bebas)
Repeat password for the MySQL “root” user: <— isikan password yang sama, sama seperti diatas line ini (verifikasi password)
3. Install Nginx
# apt-get install nginx
Jalankan service Nginx, setelah installasi Nginx selesai..
# /etc/init.d/nginx start
Dokumen root untuk Nginx disini ada pada /usr/share/nginx/www
Coba dibuka pada Web Browser, tampilan akan seperti ini:
4. Install PHP5
Disini saya menggunakan php5-fpm, fpm = FastCGI Process Manager, kenapa saya pilih fpm? karena ini cukup stabil dan cocok untuk website yang hit traficnya tinggi.
# apt-get install php5-fpm
php5-fpm mempunyai script init pada /etc/init.d/php5-fpm
5. Mengkonfigurasi Nginx :
# nano /etc/nginx/nginx.conf
rubah menjadi:
worker_processes 5; keepalive_timeout 2;
default vhost ada di /etc/nginx/sites-available/default
menjadi seperti ini :
# You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/QuickStart # http://wiki.nginx.org/Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name 10.10.2.239; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ /index.html; # } #} # HTTPS server # #server { # listen 443; # server_name localhost; # # root html; # index index.html index.htm; # # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # # ssl_session_timeout 5m; # # ssl_protocols SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; # ssl_prefer_server_ciphers on; # # location / { # try_files $uri $uri/ /index.html; # } #}
Kemudian Save, Close dan Restart Nginx
# /etc/init.d/nginx restart
buat folder pada /var/www
# mkdir /var/www
Membuktikan bahwa PHPnya sudah jalan dengan cara buat file dengan nama ex: info.php pada direktori /var/www
# nano /var/www/info.php
isi dari info.php :
<? phpinfo(); ?>
Save dan Close
Buka di browser apakah tampilan akan seperti gambar dibawah ini :
6. Mempersiapkan MySQL agar bisa mendukung PHP
Hapus yang anda anggap tidak butuh.
# apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Setelah Install Selesai :
# /etc/init.d/php5-fpm restart
Pada bagian MySQL di file info.php, akan seperti ini:
kiranya cukup, coretan saya ini bisa berguna buat temen-temen yang lagi membutuhkan.
7. Link
- nginx: http://nginx.net/
- Tutorial : http://www.howtoforge.com/
- nginx Wiki: http://wiki.codemongers.com/Main
- PHP: http://www.php.net/
- PHP-FPM: http://php-fpm.org/
- MySQL: http://www.mysql.com/
- Ubuntu: http://www.ubuntu.com/
Cukup informatif