百度开放云BCC centos6.5 hhvm 使用FileSocket协议运行 遇到Permission denied权限问题

来源:柚子科技 WordPress 主题、WordPress插件    date:2022-9-6    标签:,     WordPress主题themes插件plugins开发定制

今天在安装完成hhvm以后出现了没法访问的情况,老出现NGINX的502 bad getway,后来发现是hhvm没有启动起来。

HHVM 权限设置:

查日志发现如下错误:

[crit] 2332#0: *681 connect() to unix:/tmp/hhvm.sock failed (13: Permission denied) while connecting to upstream, client: 104.224.169.175, server: b.jiloc.com, request: “GET /p.php HTTP/1.1”, upstream: “fastcgi://unix:/tmp/hhvm.sock:”, host: “b.jiloc.com”

Permission denied 表示权限不足,我们把socket文件设置在了 /tmp 文件夹下。如果我们手动设置成777权限就可以运行了。

我们的HHVM 版本是 3.2的,网上的一些方法好像已经不能用了。

百度开放云BCC centos6.5 hhvm 使用FileSocket协议运行 遇到Permission denied权限问题

现在我们通过修改配置文件方式进行修改。

vi /etc/hhvm/server.hdf

文件内容如下:

PidFile = /var/run/hhvm.pid    Server {  #Port = 9000  # SourceRoot = /var/www/  Type=fastcgi ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# 我们这里是配合nginx,作为fastcgi启动  FileSocket = /tmp/hhvm.sock ? ? ? ? ? ?# 在这里设置socket方式,这里说一下这个值要跟nginx里的php段?fastcgi_pass后面的参数一致  DefaultDocument = index.php  }    Log {  Level = Warning  AlwaysLogUnhandledExceptions = true  RuntimeErrorReportingLevel = 8191  UseLogFile = true  UseSyslog = false  File = /var/log/hhvm/error.log  Access {  * {  File = /var/log/hhvm/access.log  Format = %h %l %u % t ”%r” %>s %b  }  }  }    Repo {  Central {  Path = /var/log/hhvm/.hhvm.hhbc  }  }    #include “/usr/share/hhvm/hdf/static.mime-types.hdf”  StaticFile {  FilesMatch {  * {  pattern = .*.(dll|exe)  headers {  * = Content-Disposition: attachment  }  }  }  Extensions : StaticMimeTypes  }    MySQL {  TypedResults = false  }

HHVM启动脚本修复:

比较奇怪的是,我安装完成以后发现/etc/init.d/hhvm 脚本出了问题,原先连正常启动都不行,我们修改后可以启动start跟停止stop了,下面贴一下代码:

cat /etc/init.d/hhvm

代码如下:

#!/bin/bash  #  # /etc/rc.d/init.d/hhvm  #  # Starts the hhvm daemon  #  # chkconfig: 345 26 74  # description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP  # processname: hhvm    ### BEGIN INIT INFO  # Provides: hhvm  # Required-Start: $local_fs  # Required-Stop: $local_fs  # Default-Start: 2 3 4 5  # Default-Stop: 0 1 6  # Short-Description: start and stop hhvm  # Description: HHVM (aka the HipHop Virtual Machine) is an open-source virtual machine designed for executing programs written in Hack and PHP  ### END INIT INFO    # Source function library.  . /etc/init.d/functions    start() {  echo -n “Starting hhvm: ”  #/usr/bin/hhvm –config /etc/hhvm/server.hdf –user apache –mode daemon  /usr/bin/hhvm –config /etc/hhvm/server.hdf –user www-data –mode daemon  touch /var/lock/subsys/hhvm  }    stop() {  echo -n “Shutting down hhvm: ”  #killproc `cat /var/run/hhvm.pid`  ps -ef | grep -e hhvm | grep -v grep | awk ‘{print $2}’ | xargs -i kill -9 {}  rm -f /var/lock/subsys/hhvm  }    case “$1” in  start)  start  ;;  stop)  stop  ;;  # status)  # if [ -f “/proc/$(cat /var/run/hhvm.pid 2>/dev/null)” ];then  # echo “hhvm is running”  # else  # echo “hhvm is not running”  # fi  # ;;  # restart)  # stop  # start  # ;;  reload|condrestart|probe|status|restart)  echo “$1 – Not supported.”  ;;  *)  echo “Usage: hhvm {start|stop|status|reload|restart[|probe]”  exit 1  ;;  esac  exit $?

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】