linux mint 17安裝Nginx,MariaDB,HHVM操作筆記

nginx安裝:

1.匯入repo的驗證金鑰
wget -c http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
2.加入軟體套件庫
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
3.開始安裝:
apt-get update
apt-get install nginx

mariadb安裝:

1.匯入repo的驗證key
sudo apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
2.加入軟體套件庫
sudo add-apt-repository ‘deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu trusty main’
3.開始安裝
sudo apt-get update
sudo apt-get install mariadb-server
mysql_secure_installation

hhvm安裝:

1.加入驗證key
sudo apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
2.加入套件庫
sudo add-apt-repository “deb http://dl.hhvm.com/ubuntu trusty main”
3.開始安裝
sudo apt-get update
sudo apt-get install hhvm

先停止服務運作
sudo service hhvm stop
sudo service nginx stop

修改hhvm目錄權限為nginx
rm -rf /var/run/hhvm
mkdir /var/run/hhvm
mkdir /var/cache/hhvm
mkdir /var/log/hhvm
chown -R nginx.nginx /var/run/hhvm
chown -R nginx.nginx /var/log/hhvm
chown -R nginx.nginx /var/cache/hhvm

設定fastcgi
打開檔案:vi /etc/nginx/hhvm.conf
改為:fastcgi_pass unix:/var/run/hhvm/sock;

打開檔案:vi /etc/hhvm/server.ini
註釋掉hhvm.server.port = 9000
新增:hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.mysql.socket = /run/mysqld/mysqld.sock

nginx設定
打開vi /etc/nginx/conf.d/default.conf
在server_name下一行新增
root /usr/share/nginx/html;
並刪除location /下的相同行
在index後面新增index.php

#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
include hhvm.conf;

打開vi /etc/init.d/hhvm

找到:

RUN_AS_USER=”www-data”
RUN_AS_GROUP=”www-data”
改為以下內容,由於nginx預設由nginx會員啟動,所以hhvm也由nginx會員啟動,可避免權限問題.

RUN_AS_USER=”nginx”
RUN_AS_GROUP=”nginx”

userdel -r www-data #刪除hhvm安裝時建立的www-data會員.

chown -R nginx.nginx /usr/share/nginx/html

最後啟動服務
sudo service hhvm start
sudo service nginx start

在/usr/share/nginx/html底下新增phpinfo.php
測試一下 應該就能運作

最後再按照官網教學進行設定檔修改與優化

建議使用圖形界面的更新管理員或是軟體中心加入套件庫與金鑰能避免問題

注意:
本篇教學同樣適用於ubuntu 14.04 64位元系統
操作指令完全一樣