Jika selama ini kita terbiasa dengan Webserver Apache, nah di tulisan kali ini saya tidak menggunakan Apache sebagai webservernya, melainkan menggunakan nginx.
Silahkan baca-baca Apache vs Nginx : Web Server Performance Deathmatch untuk mengetahui sedikit perbandingan performance antara Apache dan Nginx.
Langsung saja kita praktekkan, mari…
nginx dan php..di taro di /usr/local/src/
root@slackware:~# installpkg mysql.*.tgz
*buat database & table mysql*
#mysql_install_db
*Ubah owner dari direktori data MySQL ke user dan group “mysql”*
#chown -R mysql.mysql /var/lib/mysql/
# chmod -R 755 /var/lib/mysql/
*jalankan mysql, terlebih dahulu init script nya dirubah executable:*
#chmod +x /etc/rc.d/rc.mysqld
# /etc/rc.d/rc.mysqld start
*beri password mysql untuk user root*
# mysqladmin -u root password password_anda
*akses ke mysql*
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.51b Source distribution
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql>
setelah itu buat database wordpress....
$ mysql -u root -p
Enter password:
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO “wordpressusername”@”hostname”
-> IDENTIFIED BY “password anda”;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
12. Instalasi WordPress
$ wget http://wordpress.org/latest.tar.gz
install wordpress di /home/web
$cd /home/web/
$ tar -xzvf latest.tar.gz
$cd /home/web/wordpress
$ sudo cp wp-config-sample.php wp-config.php
Edit konfigurasi wordpress sesuaikan dengan settingan database yang telah kita set sebelumnya.
# vim wp-config.php
---------------------------------------------------------------
define(’DB_NAME’, ‘wordpress’);
/** MySQL database username */
define(’DB_USER’, ‘wordpressusername’);
/** MySQL database password */
define(’DB_PASSWORD’, ‘password’);
/** MySQL hostname */
define(’DB_HOST’, ‘localhost’);
----------------------------------------------------------------
Setelah disimpan, arahkan browser Anda ke http://server_nginx/wordpress/wp-admin/install.php, jika settingan yang kita lakukan benar, maka akan tampil wizard untuk instalasi wordpress, silahkan ikuti wizard tersebut hingga finish.
Good luck dan semoga bermanfaat, amien…
ada pertanyaan??tanya langsung aja sama orangnya.....
Silahkan baca-baca Apache vs Nginx : Web Server Performance Deathmatch untuk mengetahui sedikit perbandingan performance antara Apache dan Nginx.
Langsung saja kita praktekkan, mari…
nginx dan php..di taro di /usr/local/src/
SETUP WEB SERVER ( Studi kasus) 1. Ambil source webserver (nginx) : command : # cd /usr/local/src/ # taro file nginx.tar.gz di /usr/local/src/ 2. Buat script kompilasi untuk nginx command : # pico nginx.sh File nginx.sh berisi sbb : =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #!/bin/bash ver=1.0.4>> tergantung versi nginx nya
tar -zxvf nginx-$ver.tar.gz if [ ! -d /var/tmp/fastcgi ]; then mkdir /var/tmp/fastcgi else echo "Direktori-nya sudah ada" fi if [ ! -d /var/tmp/body ]; then mkdir /var/tmp/body else echo "Direktori-nya sudah ada" fi cd nginx-$ver ./configure --prefix=/usr/local/nginx --user=nobody --group=nobody
--http-fastcgi-temp-path=/var/tmp/fastcgi
--http-client-body-temp-path=/var/tmp/body
--with-perl=/usr/bin/perl
--with-pcre
make
if [ ! -d /usr/local/nginx/vhost ]; then
mkdir /usr/local/nginx/vhost
else
echo "Direktori-nya sudah ada"
fi
make install
chmod 700 /var/tmp/body
chmod 700 /var/tmp/fastcgi
chown -R nobody:root /var/tmp/body
chown -R nobody:root /var/tmp/fastcgi
cd /usr/local/src
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
3. Install WebServer (nginx)
command :
# chmod 755 nginx.sh
# ./nginx.sh
4. Konfigurasi WebServer
- Edit nginx.conf
command :
# pico /usr/local/nginx/conf/nginx.conf
File nginx.conf berisi sbb :
----------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
user nobody nobody;
worker_processes 2;
error_log logs/error.log;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" ';
tcp_nopush off;
tcp_nodelay on;
keepalive_timeout 15;
server_tokens off;
include vhost/web.conf;
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Buat file konfigurasi untuk VirtualHost
command :
# pico /usr/local/nginx/conf/vhost/web.conf
File web.conf berisi :
--------
=-=-=--=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
server {
listen 80;
server_name www.netweb.org;
access_log /home/logs/www-netweb.log combined;
root /home/web; >>file htdocsnya# <---- ganti dengan nama folder yg sesuai
location / {
rewrite ^/(.*)/favicon.ico$ /favicon.ico last;
try_files $uri $uri/ /index.php?q=$uri&args;
} error_page 500 502 503 504 /50x.html; location /50x.html { root html; } location ~ .php$ { fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; include fastcgi_params; } location ~ /.ht { deny all; } } =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - Buat direktori untuk Data WebServer (nama direktori tergantung pada soal, misal : direktori Data WebServer adalah "/home/web" ) command : # mkdir /home/web # chown -R root:nobody /home/web - Buat direktori untuk log VirtualHost (nama direktori disesuaikan dengan nama direktori log yang ada di file konfigurasi VirtualHost) command : # mkdir /home/logs - Buat file index.php command : # pico /home/web/index.php File index.php --------- =-=-=-=-=-=-=-=-= phpinfo(); ?> =-=-=-=-=-=-=-==- - Edit file /usr/local/nginx/conf/fastcgi_params command : # pico /usr/local/nginx/conf/fastcgi_params File fastcgi_params : -------------- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param REDIRECT_STATUS 200; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 5. Start WebServer command : # killall httpd # /usr/local/nginx/sbin/nginx 6. Ambil source PHP command : #cari install php.tar.gz 7. Buat script kompilasi untuk PHP command : # pico php.sh File php.sh ----------- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #!/bin/bash ver=5.3.6 tar -zxvf php-$ver.tar.gz cd php-$ver ./configure --prefix=/usr/local/php \ --with-curl --with-mysql --with-pcre-regex \ --with-gd --with-zlib --with-openssl \ --with-gmp --with-jpeg-dir --with-mysql-sock \ --with-config-file-path=/usr/local/php/etc \ --with-fpm-user=nobody --with-fpm-group=nobody \ --enable-fpm --enable-sockets --enable-mbstring \ --enable-sysvmsg --enable-sysvshm --enable-sysvsem \ --disable-magic-quotes --disable-ipv6 sleep 2 make all make install =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 8. Install PHP command : # chmod 755 php.sh # ./php.sh 9. Konfigurasi PHP - Edit file php.ini command : # pico /usr/local/php/etc/php.ini File php.ini ------- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
copy aja sama file php.ini.production defaultnya di install php.tar.gz....lalu masukan ke /usr/local/php/etc/php.ini
atau cari konfigurasinya di mbah google...hehe
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - Edit file php-fpm.conf command : # pico /usr/local/php/etc/php-fpm.conf File php-fpm.conf ------------ =-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice emergency_restart_threshold = 5 emergency_restart_interval = 15s process_control_timeout = 5s daemonize = yes [www] listen = 127.0.0.1:9001 listen_backlog = -1 listen_allowed_clients = 127.0.0.1 listen_owner = nobody listen_group = nobody listen_mode = 0666 user = nobody group = nobody pm = static pm.max_children = 20 pm.max_requests = 2000 request_terminate_timeout = 0 request_slowlog_timeout = 0 slowlog = /usr/local/php/var/log/php-fpm.log.slow rlimit_files = 16384 rlimit_core = 0 catch_workers_output = yes env[HOSTNAME] = $HOSTNAME env[PATH] = /usr/local/bin;/usr/bin;/bin env[TMP] = /tmp env[TMPDIR] = /tmp =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - Buat script file untuk start/stop/restart/reload php-fpm command : # pico /etc/init.d/php-fpm File php-fpm ------- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #!/bin/sh prefix= /usr/local/php exec_prefix = ${prefix} php_fpm_BIN = ${exec_prefix}/sbin/php-fpm php_fpm_CONF = ${exec_prefix/etc/php-fpm.conf php_fpm_PID = ${exec_prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm" $php_fpm_BIN $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop ) echo -n "Gracefully shutting down php-fpm" if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. use force-quit" exit 1 else echo " done" fi ;; force-quit) echo -n "Terminating php-fpm" if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm" if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit 1 ;; esac =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 10. Start PHP-FPM command : # chmod 755 /etc/init.d/php-fpm # /etc/init.d/php-fpm start
coba jalanin di browser....www.netweb.org...kalau keluar php.infonya berarti ga ada error..
tapi kalau ada yang error coba di liat2 lagi yang errornya..
setelah itu coba install wordpress..lanjut gannnn
11. install mysql
sebenarnya slackwsre sudah menyediakan paket install mysql..
cek apaka mysql sudah terinstall di mesin slackware
root@slackware:~# ls /var/log/packages/ | grep mysql mysql-5.0.51b-i486-1
jika belum install paket mysql, paket mysql ada di cd / dvd distro mysql :
root@slackware:~# installpkg mysql.*.tgz
*buat database & table mysql*
#mysql_install_db
*Ubah owner dari direktori data MySQL ke user dan group “mysql”*
#chown -R mysql.mysql /var/lib/mysql/
# chmod -R 755 /var/lib/mysql/
*jalankan mysql, terlebih dahulu init script nya dirubah executable:*
#chmod +x /etc/rc.d/rc.mysqld
# /etc/rc.d/rc.mysqld start
*beri password mysql untuk user root*
# mysqladmin -u root password password_anda
*akses ke mysql*
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.0.51b Source distribution
Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.
mysql>
setelah itu buat database wordpress....
$ mysql -u root -p
Enter password:
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO “wordpressusername”@”hostname”
-> IDENTIFIED BY “password anda”;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
12. Instalasi WordPress
$ wget http://wordpress.org/latest.tar.gz
install wordpress di /home/web
$cd /home/web/
$ tar -xzvf latest.tar.gz
$cd /home/web/wordpress
$ sudo cp wp-config-sample.php wp-config.php
Edit konfigurasi wordpress sesuaikan dengan settingan database yang telah kita set sebelumnya.
# vim wp-config.php
---------------------------------------------------------------
define(’DB_NAME’, ‘wordpress’);
/** MySQL database username */
define(’DB_USER’, ‘wordpressusername’);
/** MySQL database password */
define(’DB_PASSWORD’, ‘password’);
/** MySQL hostname */
define(’DB_HOST’, ‘localhost’);
----------------------------------------------------------------
Setelah disimpan, arahkan browser Anda ke http://server_nginx/wordpress/wp-admin/install.php, jika settingan yang kita lakukan benar, maka akan tampil wizard untuk instalasi wordpress, silahkan ikuti wizard tersebut hingga finish.
Good luck dan semoga bermanfaat, amien…
ada pertanyaan??tanya langsung aja sama orangnya.....