Masuk ke console ssh:
download bitvise kalau di windows, kemudian masuk ke console :
sudo apt-get update
sudo apt-get upgrade
Install NGINX
Petunjuk instalasi Nginx sendiri ada di http://nginx.org/en/linux_packages.html#stable tergantung dari platform OS anda. Untuk Install NGINX versi terbaru, misal yang saya pakai adalah Debian Wheezy, ada harus menambah repository linux.
Oke langsung aja kita tambah repository di linux anda dengan menambah di file /etc/apt/sources.list
nano /etc/apt/sources.list
Kemudian tambahkan 2 line di repo anda
deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx
Jangan lupa ctr+x dan save. Kemudian kita update repo dan install nginx dengan perintah:
wget http://nginx.org/packages/keys/nginx_signing.key
cat nginx_signing.key | sudo apt-key add -
apt-get update
apt-get install nginx
Noted :
service nginx reloadservice nginx restartservice nginx stopfile konfigurasi ada di : /etc/nginx
INSTALL HHVM
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
echo deb http://dl.hhvm.com/debian wheezy main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm
echo "date.timezone = Asia/Jakarta" >> /etc/hhvm/php.ini
Noted :
service hhvm restartservice hhvm stopfile konfigurasi ada di : /etc/hhvmphp.iniserver.ini
INSTALL MYSQL MARIADB
Install mariadb latest update, bisa masuk ke https://downloads.mariadb.org/mariadb/repositories/ Disitu anda bisa memilih sesuai dengan OS platform anda. Sebagai contoh saya memakai Debian 7, dengan repo yang ada di biznet.net.id
sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mariadb.biz.net.id//repo/10.0/debian wheezy main'
sudo apt-get update
sudo apt-get install mariadb-server
Noted :
service mysql restartservice mysql stopfile konfigurasi ada di : /etc/mysql/my.cnf
INSTALL COMPOSER
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
install projects using yii2, untuk test composer (optional):
composer global require "fxp/composer-asset-plugin:1.0.0"
composer create-project sintret/yii2-basic --prefer-dist /usr/share/nginx/www/projects
SETTING SFTP
Untuk menambah user baru di sftp cukup dengan mengetik adduser
adduser user_baru
sftp user_baru@localhost
kita akan buat group baru dengan nama www, dimana user yang akan kita create tersebut diatas bisa mengakses di direktory www kita untuk kebutuhan file transfer dengan menggunakan sftp.
Match group www
ChrootDirectory /usr/share/nginx
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Restart ssh anda :
service ssh restart
Kemudian kita akan addgroup user tersebut ke group yang akan kita buat, dengan contoh nama group nya adalah www.
addgroup --system www
usermod -G www user_baru
chown root:root /usr/share/nginx
chmod 755 /usr/share/nginx
Untuk akses sftp bisa dicoba dengan menggunakan filezilla atau yang lainnya
SETTING MYSQL
Supaya mysql bisa diremote dari luar, maka buka file my.cnf dan rubah harus bind-address = 0.0.0.0
bind-address = 0.0.0.0
nano /etc/mysql/my.cnf
kemudian kita coba create user di mysql dan grant
masuk ke mysql :
mysql -u root -p
GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'your password here';
create user mysql
CREATE USER 'your_user'@'%' IDENTIFIED BY 'your_password';
GRANT ALL ON *.* TO your_user@'%' IDENTIFIED BY 'your_password';
setelah di grant maka mysql kita bisa remote dari luar.
SETTING HHVM
Setting php.ini ada di file /etc/hhvm/php.ini, untuk error log ada di /var/log/hhvm
setting php.ini untuk munculkan jika ada error :
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
;error_reporting = E_ALL
display_errors = 1
html_errors = true
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
hhvm.error_handling.call_user_handler_on_fatals = true
hhvm.error_handling.max_loop_count = 0
hhvm.error_handling.no_infinite_recursion_detection = true
hhvm.error_handling.throw_bad_type_exceptions = true
hhvm.error_handling.throw_too_many_arguments = true
hhvm.error_handling.warn_too_many_arguments = true
hhvm.error_handling.throw_missing_arguments = true
hhvm.error_handling.throw_invalid_arguments = true
hhvm.error_handling.enable_hip_hop_errors = true
hhvm.error_handling.notice_frequency = 1
hhvm.error_handling.warning_frequency = 1
hhvm.error_handling.throw_exception_on_bad_method_call = 1
hhvm.debug.full_backtrace = true
hhvm.debug.server_stack_trace = true
hhvm.debug.server_error_message = true
hhvm.debug.translate_source = true
date.timezone = Asia/Jakarta
SETTING NGINX
optimize nginx, silahkan buka http://tweaked.io/guide/nginx/
buka file di /etc/nginx/nginx.conf
untuk worker process biasanya sudah di default sesuai dengan core cpu anda.
untuk mengetahuinya cukup dengan :
grep ^processor /proc/cpuinfo | wc -l
user nginx;
# One worker per CPU-core.
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 8096;
multi_accept on;
use epoll;
}
http {
# Basic Settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 240;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
#log
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# Gzip Settings
gzip on;
gzip_disable "msie6";
gzip_static on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 9;
gzip_min_length 1000;
#gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/javascript application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
}
Untuk multi_accept on sebenernya wajib kita set, ini berfungsi untuk melakukan banyak transaksi dalam satu waktu (ini yang saya baca dari tutorial ).
Gzip compression level
Jangan lupa :
chmod -R 755 /usr/share/nginx/www atau chmod -R 755 /usr/share/nginx/www di direktory root anda
Note:
kalau anda terbiasa dengan apache dan kemudian beralih ke nginx, ada tool buat conver .htaceess, anda bisa masuk ke link http://winginx.com/en/htaccess
Kalau mau tambah project/location bisa ditambah lagi di file default ini.
CREATE SWAP FILE
ini berfungsi untuk membantu kinerja memory yang terpasang, biasanya kalau anda ingin menggunakan composer dan memory anda pas2an maka anda wajib melakukan swap file.
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
===and then edit graphic magic===
sudo apt-get install graphicsmagick
/usr/share/nginx/www/projects
edit your config db.php and change your dbname:
in config/db.php
kemudian pake console masih di folder projects anda :
./yii migrate
./yii insert/init
./yii migrate --migrationPath=@yii/rbac/migrations
./yii rbac/init
setting di /etc/sites-availble/default, add line :
location /projects {
alias /usr/share/nginx/www/projects/web;
rewrite ^/projects/(.*)$ /projects/web/index.php?$args;
}
# the images need a seperate entry as we dont want to concatenate that with index.php
location ~ ^/projects/(.+\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|eot|woff|ttf|svg|xls|xlsx))$ {
access_log off;
expires 360d;
rewrite ^/projects/(.+)$ /projects/web/$1 break;
try_files $uri =404;
}
restart nginx
service nginx reload
service nginx restart
service hhvm restart