Apache Multi-Virtual host multi-version PHP (5.3+5.6+n) Coexistence Run configuration whole process

Source: Internet
Author: User
Tags install openssl intl soap lua phpinfo

Abstract: For the need to implement on the same Linux server, while running several different versions of the PHP program, this article we will use the fastcgi way to load, and the process of detailed record down for easy reference.

There are a number of common ways to configure PHP, such as CGI, fast-cgi, Apache module handle, CLI, and ISAPI.

    • CGI (Universal Gateway Interface/Common Gateway Interface)
    • Fast CGI (resident type cgi/long-live CGI)
    • CLI (command line run/Interface)
    • Module handle (Apache and other Web server running mode, php5_module)
    • ISAPI (a way to load PHP DLLs specifically for IIS) Internet Server application program Interface)

Due to the different configuration methods, will show their different advantages and disadvantages. Often used in web development is the FASTCGI and module handle this mode of loading, there are some other ways to configure the details of this article no longer mentioned, please look for relevant articles at the end of the article for review.

For the need to implement on the same Linux server, running several different versions of PHP at the same time, this article we will use the fastcgi mode loading, and the process of detailed records for your reference, in addition to the window above the configuration of the same many versions please refer to the previous published articles Apache Multi-Virtual host multi-version PHP (5.2+5.3+5.4) coexistence operation configuration throughout the process.

Get ready

Centos7.1 (similar to other versions), mod_fcgid2.3.6, httpd-2.2.31

Note: The toolkit software covered in this article will be available at the end of the article.

Installing the Service Foundation components

1. Install compilation dependent

yum install httpd-devel apr apr-devel libtool

2.PR:

tar xf apr-1.5.2.tar.bz2cd apr-1.5.2./configure --prefix=/usr/local/aprmake && make install

3.apr-util:

tar xf apr-util-1.5.4.tar.bz2cd apr-util-1.5.4./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-apr=/usr/local/apr/make && make install

4. Installing Pcre-devel

yum -y install pcre-devel

Checking for pcre-config ... false
Configure:error:pcre-config for Libpcre not found. PCRE is required and available the from http://pcre.org/--resolves errors that occur during the HTTPD compilation process and does not have to be installed beforehand.

5. Install SSL

install openssl-develyum update openssl

Checking whether to enable Mod_ssl ... Configure:error:mod_ssl have been requested but can not is built due to prerequisit e failures--resolves errors that occur during the HTTPD compilation process and does not have to be installed beforehand.

Compiling and installing httpd
./configure--prefix=/usr/ Local/apache--sysconfdir=/etc/httpd--enable-so --enable-ssl--enable-cgi--enable-rewrite- -with-zlib--with-pcre--with-apr= /usr/local/apr-< Span class= "Hljs-regexp" >-with-apr-util=/usr/local/apr-util--enable-modules=all-- Enable-mpms-shared=all--with-mpm=eventmake && make install      

Compiling and installing mod_fcgid.so-2.3.6

[root@localhost mod_fcgid-2.3.6]# APXS=/usr/local/apache/bin/apxs ./configure.apxs[root@localhost mod_fcgid-2.3.6]# make && make install

Apxs= "Assignment path is apxs file location under your httpd directory"

After the compilation and installation is completed, it will be automatically programmed into the modules inside the httpd directory.

Here you need to explain, use Apxs-i-a-c mod_fcgid.so to install the words will have some problems, resulting in httpd load conf when the termination.

Use mod_fcgid above 2.3.6 versions above, such as 2.3.9 (available on the website) tested, in httpd2.4.23, httpd2.2.31 will appear an undefined symbol error, the contents are as follows:

Undefined Symbol:set_access_info

Additional error Description:

[Root@localhost mod_fcgid-2.3.6]# make && make install
MAKEFILE:29:/rules.mk:no such file or directory
Make: * * * No rule to make target '/rules.mk '. Stop.

Similar errors occur, the quickest is to delete the current folder, re-decompression mod_fcgid or httpd after the compilation.

Configuring a virtual Host

1. Configuring the primary httpd.conf

vi /etc/httpd/httpd.conf#在DSO下增加以下内容LoadModule fcgid_module modules/mod_fcgid.so#在文件尾部增加Include "vhost/*.conf"

Such as:

## Dynamic Shared Object (DSO) support## to is able to use the functionality of a module which is built as a DSO you# The corresponding ' LoadModule ' lines at the# directives contained in it is actually available _before_ they is used.# statically compiled modules (those listed by ' httpd-l ') does not need# to is loaded here.## Example:# LoadModule Foo_module modules/mod_foo.so#LoadModule fcgid_module modules/mod_fcgid.soaddhandler fcgid-script. fcgi. php#映射fcgi执行脚本# set php_fcgi_max_requests greater than or equal to fcgidmaxrequestsperprocess, Prevents the php-cgi process from exiting fcgidinitialenv php_fcgi_max_requests before processing all requests  PHP-CGI maximum number of requests per process fcgidmaxrequestsperprocess #php-cgi Maximum number of processes fcgidmaxprocesses 3# Maximum execution time fcgidiotimeout 120FcgidIdleTimeout #限制最大请求字节 (unit B) Fcgidmaxrequestlen 2097152< Ifmodule!mpm_netware_module><ifmodule!mpm_winnt_module> Omit content .... Namevirtualhost *:Include "vhost/*.conf"          

2. Configure the virtual host Conf

Create a virtual host configuration directory

/usr/local/apache/vhost/vi /usr/local/apache/vhost/default.confvi /usr/local/apache/vhost/php534.conf

~vhost/default.conf

<VirtualHost *:80>    ServerName default    DocumentRoot "/mnt/web/default/wwwroot"    ServerAlias php5629.hk.explame.com    ErrorLog "/mnt/web/default/log/error.log"    CustomLog "/mnt/web/default/log/access.log" common FcgidInitialEnv PHPRC "/usr/local/php/php5.6.29/" FcgidWrapper "/usr/local/php/php5.6.29/bin/php-cgi" .php #采用fcgid将不再支持 php_admin_value open_basedir .:/tmp/ 设置方式。 #设置目录访问权限,如出现上传写入问题,请设置php.ini中 upload_tmp_dir = /tmp/</VirtualHost>

~vhost/php534.conf

<VirtualHost *:80>    ServerName php534    DocumentRoot "/mnt/web/php534/wwwroot"    ServerAlias php534.hk.explame.com    ErrorLog "/mnt/web/php534/log/error.log"    CustomLog "/mnt/web/php534/log/access.log" common    FcgidInitialEnv PHPRC "/usr/local/php/php5.3.4/" FcgidWrapper "/usr/local/php/php5.3.4/bin/php-cgi" .php</VirtualHost>

Compiling and installing PHP

1. Prepare for Dependency

# c和c++编译器yum install -y gcc gcc-c++# PHP扩展依赖yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel

1. Installing PHP5.6.29

Wget-o php-5.6.29.tar.bz2 HTTP://CN2.PHP.NET/GET/PHP-5.6.29.TAR.BZ2/FROM/THIS/MIRRORTAR-XVJF php-5.6.29.tar.bz2CD Php-5.6.29./configure--prefix=/usr/LOCAL/PHP/PHP5.6.29/--WITH-LIBDIR=LIB64--ENABLE-FPM--WITH-FPM-USER=PHP-FPM--with-fpm-group=www--ENABLE-MYSQLND--WITH-MYSQL=MYSQLND--WITH-MYSQLI=MYSQLND--WITH-PDO-MYSQL=MYSQLND--enable-opcache--enable-pcntl--enable-mbstring--enable-soap--enable-zip-- Enable-calendar--enable-bcmath--enable-exif--enable-ftp--enable-intl--with-openssl-- With-zlib--with-curl--with-gd--with-zlib-dir=/usr/lib--with-png-dir=/usr/lib- -with-jpeg-dir=/usr/lib--with-gettext--with-mhash--with-ldapmake && make install  

2. Installing PHP5.3.3

wget http://museum.php.net/php5/php-5.3.4.tar.bz2tar -xvjf php-5.3.4.tar.bz2cd php-5.3.4#php5.3 额外安装yum -y install libevent libevent-dev libevent-devel./configure --prefix=/usr/local/php/php5.3.4/ --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xmlmake && make install

Other versions are configured and compiled in a similar way, at least 2 PHP versions are installed to configure multi-virtual host multi-PHP version configuration.

PHP low version in the process of installation will encounter a lot of problems, this article ignores some common, please check the network solution.

Subsequent Extensions 5.3 compilation parameters

./configure--prefix=/usr/Local/php/php5.3.28/--with-freetype-dir--with-png-dir--with-libxml-dir--with-iconv=/usr/Local--enable-xml--ENABLE-MYSQLND--WITH-MYSQL=MYSQLND--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd-- Enable-pcntl--enable-mbstring--enable-soap-- Enable-zip--enable-calendar--enable-bcmath-- Enable-exif--enable-ftp--enable-intl--with-openssl-< Span class= "Ruby" >-with-zlib--with-curl--with-gd-- With-zlib-dir=/usr/lib--with-png-dir=/ Usr/lib--with-jpeg-dir=/usr/lib--with-gettext- -with-mhash--with-ldap         

Error resolution encountered at compile time:

Undefined reference to symbol ' [email protected] @CXXABI_1.3 '

Https://www.cnblogs.com/ttiandeng/p/7867226.html

Test result php5.6.29

Loading the default phpinfo, the average speed is around 1s.

Output normal characters, average speed is around 95ms.

php5.3.4

Loading the default phpinfo, the average speed is around 500ms, which is 5.6 faster than the previous one.

Output normal characters, average speed is around 100ms.

PHP5.6 in this process loaded more than PHP5.3 more modules, and on the speed above the overall or improved a lot of actual project testing, please do your own research.

Knot

The final available version of the test is

Centos7.1 + mod_fcgid-2.3.6 + httpd-2.2.31 + php*

This article is the measured content, only personal views, if in doubt, please leave a message at the end of the text. Thank you!

Related articles:

PHP run mode http://blog.csdn.net/hguisu/article/details/7386882

Apache Mirror Station http://mirrors.cnnic.cn/apache/httpd/

PHP Historical Version http://php.net/releases/

mod_fcgid-2.3.6 ftp://ftp.ucsb.edu/pub/mirrors/apache/httpd/mod_fcgid/mod_fcgid-2.3.6.tar.bz2

https://my.oschina.net/u/2366984/blog/809833

Apache Multi-Virtual host multi-version PHP (5.3+5.6+n) Coexistence Run configuration whole process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.