1
0

hhvm_CentOS.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # http://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. Install_hhvm_CentOS()
  11. {
  12. cd $oneinstack_dir/src
  13. id -u $run_user >/dev/null 2>&1
  14. [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
  15. if [ "$CentOS_RHEL_version" == '7' ];then
  16. if [ -e /etc/yum.repos.d/epel.repo_bk ];then
  17. /bin/mv /etc/yum.repos.d/epel.repo{_bk,}
  18. elif [ ! -e /etc/yum.repos.d/epel.repo ];then
  19. cat > /etc/yum.repos.d/epel.repo << EOF
  20. [epel]
  21. name=Extra Packages for Enterprise Linux 7 - \$basearch
  22. #baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
  23. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch
  24. failovermethod=priority
  25. enabled=1
  26. gpgcheck=0
  27. EOF
  28. fi
  29. cat > /etc/yum.repos.d/hhvm.repo << EOF
  30. [hhvm]
  31. name=gleez hhvm-repo
  32. baseurl=http://mirrors.linuxeye.com/hhvm-repo/7/\$basearch/
  33. enabled=1
  34. gpgcheck=0
  35. EOF
  36. yum -y install hhvm
  37. [ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm
  38. fi
  39. if [ "$CentOS_RHEL_version" == '6' ];then
  40. if [ -e /etc/yum.repos.d/epel.repo_bk ];then
  41. /bin/mv /etc/yum.repos.d/epel.repo{_bk,}
  42. elif [ ! -e /etc/yum.repos.d/epel.repo ];then
  43. cat > /etc/yum.repos.d/epel.repo << EOF
  44. [epel]
  45. name=Extra Packages for Enterprise Linux 6 - \$basearch
  46. #baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
  47. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
  48. failovermethod=priority
  49. enabled=1
  50. gpgcheck=0
  51. EOF
  52. fi
  53. for Package in libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel libevent-devel libcurl-devel libmemcached-devel lcms2 inotify-tools
  54. do
  55. yum -y install $Package
  56. done
  57. yum -y remove libwebp boost-system boost-filesystem
  58. cat > /etc/yum.repos.d/hhvm.repo << EOF
  59. [hhvm]
  60. name=gleez hhvm-repo
  61. baseurl=http://mirrors.linuxeye.com/hhvm-repo/6/\$basearch/
  62. enabled=1
  63. gpgcheck=0
  64. EOF
  65. yum --disablerepo=epel -y install mysql mysql-devel mysql-libs
  66. yum --disablerepo=epel -y install hhvm
  67. fi
  68. userdel -r nginx;userdel -r saslauth
  69. rm -rf /var/log/hhvm
  70. mkdir /var/log/hhvm
  71. chown -R ${run_user}.${run_user} /var/log/hhvm
  72. cat > /etc/hhvm/config.hdf << EOF
  73. ResourceLimit {
  74. CoreFileSize = 0 # in bytes
  75. MaxSocket = 10000 # must be not 0, otherwise HHVM will not start
  76. SocketDefaultTimeout = 5 # in seconds
  77. MaxRSS = 0
  78. MaxRSSPollingCycle = 0 # in seconds, how often to check max memory
  79. DropCacheCycle = 0 # in seconds, how often to drop disk cache
  80. }
  81. Log {
  82. Level = Info
  83. AlwaysLogUnhandledExceptions = true
  84. RuntimeErrorReportingLevel = 8191
  85. UseLogFile = true
  86. UseSyslog = false
  87. File = /var/log/hhvm/error.log
  88. Access {
  89. * {
  90. File = /var/log/hhvm/access.log
  91. Format = %h %l %u % t \"%r\" %>s %b
  92. }
  93. }
  94. }
  95. MySQL {
  96. ReadOnly = false
  97. ConnectTimeout = 1000 # in ms
  98. ReadTimeout = 1000 # in ms
  99. SlowQueryThreshold = 1000 # in ms, log slow queries as errors
  100. KillOnTimeout = false
  101. }
  102. Mail {
  103. SendmailPath = /usr/sbin/sendmail -t -i
  104. ForceExtraParameters =
  105. }
  106. EOF
  107. cat > /etc/hhvm/server.ini << EOF
  108. ; php options
  109. pid = /var/log/hhvm/pid
  110. ; hhvm specific
  111. ;hhvm.server.port = 9001
  112. hhvm.server.file_socket = /var/log/hhvm/sock
  113. hhvm.server.type = fastcgi
  114. hhvm.server.default_document = index.php
  115. hhvm.log.use_log_file = true
  116. hhvm.log.file = /var/log/hhvm/error.log
  117. hhvm.repo.central.path = /var/log/hhvm/hhvm.hhbc
  118. EOF
  119. cat > /etc/hhvm/php.ini << EOF
  120. hhvm.mysql.socket = /tmp/mysql.sock
  121. expose_php = 0
  122. memory_limit = 400000000
  123. post_max_size = 50000000
  124. EOF
  125. if [ -e "$web_install_dir/sbin/nginx" -a -e "/usr/bin/hhvm" -a ! -e "$php_install_dir" ];then
  126. sed -i 's@/dev/shm/php-cgi.sock@/var/log/hhvm/sock@' $web_install_dir/conf/nginx.conf
  127. [ -z "`grep 'fastcgi_param SCRIPT_FILENAME' $web_install_dir/conf/nginx.conf`" ] && sed -i "s@fastcgi_index index.php;@&\n\t\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;@" $web_install_dir/conf/nginx.conf
  128. sed -i 's@include fastcgi.conf;@include fastcgi_params;@' $web_install_dir/conf/nginx.conf
  129. service nginx reload
  130. fi
  131. rm -rf /etc/ld.so.conf.d/*_64.conf
  132. ldconfig
  133. # Supervisor
  134. yum -y install python-setuptools
  135. ping pypi.python.org -c 4 >/dev/null 2>&1
  136. easy_install supervisor
  137. echo_supervisord_conf > /etc/supervisord.conf
  138. sed -i 's@pidfile=/tmp/supervisord.pid@pidfile=/var/run/supervisord.pid@' /etc/supervisord.conf
  139. [ -z "`grep 'program:hhvm' /etc/supervisord.conf`" ] && cat >> /etc/supervisord.conf << EOF
  140. [program:hhvm]
  141. command=/usr/bin/hhvm --mode server --user $run_user --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
  142. numprocs=1 ; number of processes copies to start (def 1)
  143. directory=/tmp ; directory to cwd to before exec (def no cwd)
  144. autostart=true ; start at supervisord start (default: true)
  145. autorestart=unexpected ; whether/when to restart (default: unexpected)
  146. stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
  147. EOF
  148. /bin/cp ../init.d/Supervisor-init-CentOS /etc/init.d/supervisord
  149. chmod +x /etc/init.d/supervisord
  150. chkconfig supervisord on
  151. service supervisord start
  152. cd ..
  153. }