centos6上的VestaCP都是支持在php5.4以上版本,但是有些老网站还是php5.2写的,为了支持这些老网站,研究了下VestaCP支持php5.2的方法
1.yum groupinstall ‘Development Tools’
2. yum install \
libxml2-dev* \ libmhash-dev* \ libcurl-dev* \ libpng* \ libjpeg* \ libtidy-dev* \ libxslt-dev* \ libtool-ltdl-dev* \ mcrypt \ libmcrypt-dev* \ libXpm-dev* \ libsqlite* \ mysql-dev* \ mysql-libs \ sqlite-dev* \ freetype-dev* \ openssl-dev* \ bzip2-dev* \ unzip* \ patch \ make \ gcc*yum –enablerepo=remi,remi-test install mysql-devel
3.mkdir /opt/php-5.2.17
4. mkdir -p /usr/src/php/ && cd /usr/src/php/
5. wget -c -t0 http://museum.php.net/php5/php-5.2.17.tar.gz
6. tar zxf php-5.2.17.tar.gz
7. cd /usr/src/php/php-5.2.17/
8.wget http://php52-backports.googlecode.com/files/php52-backports-20130717.patch
9.patch -p1 < php52-backports-20130717.patch
./configure \
–prefix=/opt/php-5.2.17 \ –with-config-file-path=/opt/php-5.2.17 \ –with-libdir=lib64 \ –with-mysql \ –with-mysqli \ –with-sqlite=shared \ –with-curl \ –with-gd \ –with-openssl \ –with-pdo-mysql=shared –with-pdo-sqlite=shared \ –with-mcrypt \ –with-pear \ –with-pic \ –with-jpeg-dir \ –with-png-dir \ –with-ttf \ –with-freetype-dir \ –with-xmlrpc \ –with-xpm-dir \ –with-zlib \ –enable-bcmath \ –enable-calendar \ –enable-cli \ –enable-discard-path \ –enable-fastcgi \ –enable-ftp \ –enable-force-cgi-redirect \ –enable-gd-native-ttf \ –enable-libxml \ –enable-mbstring \ –enable-pdo=shared \ –enable-soap \ –enable-sockets \ –enable-session \ –enable-zip \ –enable-zend-multibyte
此步骤如果出现 Requires: mysql = 5.1.73-3.el6_5 这种错误,执行下面命令:
这个是编译php5.2.7的命令,如果是32位的 要换成 –with-libdir=lib
11. make && make install
12.cp /usr/src/php/php-5.2.17/php.ini-recommended /opt/php-5.2.17/lib/php.ini
13./opt/php-5.2.17/bin/php-cgi -v
14. vi /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.sh
写入如下内容:
#!/bin/bash
# Adding php wrapper user=”$1″ domain=”$2″ ip=”$3″ home_dir=”$4″ docroot=”$5″wrapper_script=”#!/bin/sh
export PHPRC=/opt/php-5.2.17/lib/ export PHP_FCGI_MAX_REQUESTS=1000 export PHP_FCGI_CHILDREN=20 exec /opt/php-5.2.17/bin/php-cgi ” wrapper_file=”$home_dir/$user/web/$domain/cgi-bin/fcgi-starter”echo “$wrapper_script” > $wrapper_file
chown $user:$user $wrapper_file chmod -f 751 $wrapper_fileexit 0
15. vi /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.tpl
写下如下内容:
<VirtualHost %ip%:%web_port%>
ServerName %domain_idn%
%alias_string% ServerAdmin %email% DocumentRoot %docroot% ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ Alias /vstats/ %home%/%user%/web/%domain%/stats/ Alias /error/ %home%/%user%/web/%domain%/document_errors/ SuexecUserGroup %user% %group% CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes CustomLog /var/log/%web_system%/domains/%domain%.log combined ErrorLog /var/log/%web_system%/domains/%domain%.error.log <Directory %docroot%> AllowOverride All Options +Includes -Indexes +ExecCGI <Files *.php> SetHandler fcgid-script </Files> FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php </Directory> <Directory %home%/%user%/web/%domain%/stats> AllowOverride All </Directory>Include %home%/%user%/conf/web/%web_system%.%domain%.conf*
</VirtualHost>
16. vi /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.stpl
写下如下内容:
<VirtualHost %ip%:%web_ssl_port%>
ServerName %domain_idn%
%alias_string% ServerAdmin %email% DocumentRoot %sdocroot% ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ Alias /vstats/ %home%/%user%/web/%domain%/stats/ Alias /error/ %home%/%user%/web/%domain%/document_errors/ SuexecUserGroup %user% %group% CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes CustomLog /var/log/%web_system%/domains/%domain%.log combined ErrorLog /var/log/%web_system%/domains/%domain%.error.log <Directory %sdocroot%> SSLRequireSSL AllowOverride All Options +Includes -Indexes +ExecCGI <Files *.php> SetHandler fcgid-script </Files> FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php </Directory> <Directory %home%/%user%/web/%domain%/stats> AllowOverride All </Directory> php_admin_value open_basedir none SSLEngine on SSLVerifyClient none SSLCertificateFile %ssl_crt% SSLCertificateKeyFile %ssl_key% %ssl_ca_str%SSLCertificateChainFile %ssl_ca%Include %home%/%user%/conf/web/s%web_system%.%domain%.conf*
</VirtualHost>
17.安装完成,执行下面命令
chmod +x /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.sh && \
chmod +x /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.tpl && \ chmod +x /usr/local/vesta/data/templates/web/httpd/phpfcgid_52.stplservice httpd restart
18.再登录vestacp的后台,添加网站。