Install Nginx, Php5, Mysql-sever di Ubuntu 11.04


Hari ini ga ada kegiatan, akhirnya browsing kemudian akhirnya mau nyoba nginx pengganti apache, n katanya nginx lebih cepet daripada apache. langsung aja ya ga usah basa basi he..he... nanti malah ga di baca. silahkan masuk ke terminal anda dan pastikan terkonek internet untuk mempermudah langkah anda.
1. Install paket yang dibutuhkan
sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl nginx spawn-fcgi mysql-server


2. Jalankan service nginx
sudo /etc/init.d/nginx start

kalau sudah biar berjalan secara otomatis lakukan perintah berikut
sudo update-rc.d nginx defaults

3. edit file /etc/php5/cgi/php.ini
sudo gedit /etc/php5/cgi/php.ini

Ubah cgi.fix_pathinfo = 0 menjadi 1 (hilangkan tanda ;)
[...]
cgi.fix_pathinfo = 1

4. menjalankan php cgi
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

biar berjalan tiap komputer restart letakkan di rc.local sebelum exit 0 (kode yang diatas ya.
5. edit file nginx.conf
sudo gedit /etc/nginx/nginx.conf

edit bagian berikut
[...]
worker_processes 5;
[...]
keepalive_timeout 2;
[...]

6. Selajutnya mengubah path file default sesuai keinginan kita
Kita ubah dari /usr/share/nginx/www ubah ke /home/xwaja/public_html (ini diasumsikan xwaja merupakan user anda dan public_html tu buat folder baru)
sudo gedit /etc/nginx/sites-available/default

server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6

#root /usr/share/nginx/www;
root /home/xwaja/public_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 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;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

7. Terakhir kita tinggal melakukan restart nginx
sudo /etc/init.d/nginx restart

8. selesai deh, sekarang coba anda buat web di /home/xwaja/public_html

3 comments

mau tanya ni.... cara mengembalikan folder nginx di ubuntu atau debian gmana ? saya sengaja terhapus, tapi saat saya install lagi nginxnya g bisa muncul lagi folder itu...gmana solusinya ?

Reply

untuk mas Vapor silahkan di lihat file /etc/nginx/nginx.conf di situ kan akan terlihat letak defaulfnya html ya, kalau masih ga bisa di hapus aja dulu pakai perintah
sudo apt-get autoremove --purge nginx
kemudian di install kembali nginxnya
sudo apt-get install nginx

Reply

Posting Komentar