Ubuntu 14.10系统安装 Nginx + MySQL + HHVM + phpMyAdmin环境

作者:袖梨 2022-06-30

注:如果使用非root权限,请在命令前面加上 sudo;


# 更新并升级
apt-get update && apt-get upgrade
# 安装 Nginx
apt-get install nginx -y
# 安装 Mysql
apt-get install mysql-server-5.6 -y
# 安装 HHVM
apt-get install hhvm -y
# 安装 PhpMyAdmin
apt-get install phpmyadmin -y
# 安装 进程守护
apt-get install ps-watcher -y
# 安装 FastCGI 配置脚本
/usr/share/hhvm/install_fastcgi.sh
# 自动配置 phpmyadmin
/usr/sbin/pma-configure .
/usr/sbin/pma-secure
# 通过:域名/phpmyadmin 访问
ln -s /usr/share/phpmyadmin /usr/share/nginx/html
# 将 hhvm 加入开机启动
update-rc.d hhvm defaults


# 编辑加入或替换 hhvm.conf


nano /etc/nginx/hhvm.conf
location ~ .(hh|php)$ {
    fastcgi_keep_conn on;
    #fastcgi_pass   127.0.0.1:9000;
    fastcgi_pass   unix:/var/run/hhvm/sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}


# 编辑加入或替换 php.ini


nano /etc/hhvm/php.ini
; php options
session.save_handler = files
session.save_path = /var/lib/php5
session.gc_maxlifetime = 1440

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false

hhvm.enable_zend_compat = true

max_execution_time = 300
max_input_time = 60
post_max_size = 10M
upload_max_filesize = 10M
memory_limit = 512M
expose_php = 0


# 编辑加入或替换 server.ini


nano /etc/hhvm/server.ini
; php options

pid = /var/run/hhvm/pid

; hhvm specific

; hhvm.server.port = 9000
hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc


# 编辑加入或替换 ps-watcher.conf


nano /etc/ps-watcher.conf
[hhvm]
occurs = none
action = service hhvm restart
# 启用 ps-watcher
sed -i -e 's/# startup=1/startup=1/g' /etc/default/ps-watcher


# 编辑加入或替换 hhvm


nano /etc/init.d/hhvm
RUN_AS_USER="www"
RUN_AS_GROUP="www"


# 编辑加入或替换 nginx.conf


nano /etc/nginx/nginx.conf
user www www;
worker_processes auto;


# 增加 www 用户和用户组


groupadd www;
useradd -m -s /sbin/nologin -g www www;


# 更改所有者为 www


chown -R www.www /var/log/nginx
chown -R www.www /var/run/hhvm
chown -R www.www /var/log/hhvm
chown -R www.www /var/lib/phpmyadmin
chown -R www.www /usr/share/phpmyadmin
chown -R www.www /etc/phpmyadmin/


# 删除用户


userdel -r nginx
userdel -r www-data


# 启动


service nginx restart
service mysql restart
service hhvm restart
service ps-watcher restart

相关文章

精彩推荐