hhvm_CentOS.sh 5.1 KB

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