安裝多個php,安裝多個微信

本文目錄一覽:

如何在本地搭建多個PHP環境

1.

比較簡單的就是一件安裝包了,有

WampServer

、PhpStudy等

2.

搭建一個php環境就夠了,多個是幾個意思,完全沒必要,即使你搭建了多個,到時啟動時,服務器、數據庫啟動不了,因為端口被佔用,除非修改端口,不然本地也只能啟動一個php環境

Centos 7 安裝多版本 php

php各版本地址:

其中:

–prefix 安裝目錄可以不和我一樣,可換成自己的安裝目錄

–with-config-file-path 存放php.ini的位置

查看更多配置信息:

或者在官網查看

如果安裝了多個版本的php可以臨時改變php的命令行:

安裝完畢

windows服務器里可以安裝多版本php嗎

可以安裝多各版本的PHP。 需要注意的:在同一IIS服務器上同時安裝多個版本的PHP,必須按照php.net文檔IIS 5.1和IIS 6.0及IIS 7.0和更高版本中描述的步驟手動安裝。不要使用PHP的Windows安裝程序,因為它不支持並行安裝。 華普在線小李為你解答

一台機器可以裝兩個PHP么,版本不同

可以的,只要你會配置,可以裝N個,也可以多個不同PHP版本同時運行,

如果你自己不會配置,建議使用PHPWAMP8.1.8.8綠色集成環境。

支持自定義,官方提供700個php版本隨你切換,一鍵切換很方便,多個php版本可以共存,能同時運行多個不同PHP版本,而且還能實現apache、iis等服務器共存去除非80端口。

如何在linux下安裝多個不同版本的PHP

Linux (測試環境 Ubuntu 12.04 Server X86_64)

1. 安裝編譯工具及所需類庫

$ sudo apt-get install build-essential gcc g++ autoconf libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev bzip2 libbz2-dev openssl libssl-dev curl libcurl4-openssl-dev libpcre3 libpcre3-dev libevent-1.4-2 libevent-dev libmcrypt4 libmcrypt-dev mcrypt libltdl-dev libldap2-dev libsasl2-dev libmhash-dev libc-client2007e libc-client2007e-dev

2. 安裝MySQL

$ sudo apt-get install mysql-server libmysqlclient-dev

3. 安裝PHP

Linux下多版本PHP共存需要自己手工編譯安裝。

下載PHP源文件到/opt/src目錄

$ mkdir /opt/src

$ cd /opt/src

$ wget -O php-5.2.17.tar.bz2

$ wget -O php-5.3.28.tar.bz2

$ wget -O php-5.4.29.tar.bz2

$ wget -O php-5.5.14.tar.bz2

創建PHP各版本安裝目錄

$ mkdir -p /opt/php/{5217,5328,5429,5514}

安裝PHP 5.2.17

$ cd /opt/src

$ tar -xvjf php-5.2.17.tar.bz2

$ cd php-5.2.17

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so

$ sudo ln -s /usr/lib/x86_64-linux-gnu/libkrb5.so /usr/lib/libkrb5.so

$ wget -O debian_patches_disable_SSLv2_for_openssl_1_0_0.patch “;patch=debian_patches…”

$ patch -p1 debian_patches_disable_SSLv2_for_openssl_1_0_0.patch

$ ./configure –prefix=/opt/php/5217 –with-config-file-scan-dir=/opt/php/5217/etc/php.d –with-mysql –with-pdo-mysql –with-mysqli –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –enable-ftp –disable-debug –disable-ipv6 –disable-short-tags –enable-calendar –with-mime-magic –with-imap –with-imap-ssl –with-kerberos

$ make

$ sudo make install

$ cp php.ini-recommended /opt/php/5217/lib/php.ini

安裝PHP 5.3.28

$ cd /opt/src

$ tar -xvjf php-5.3.28.tar.bz2

$ cd php-5.3.28

$ ./configure –prefix=/opt/php/5328 –with-config-file-scan-dir=/opt/php/5328/etc/php.d –with-mysql –with-pdo-mysql –with-mysqli –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –enable-ftp –disable-debug –disable-ipv6 –disable-short-tags –enable-calendar –with-imap –with-imap-ssl –with-kerberos

$ make

$ sudo make install

$ cp php.ini-development /opt/php/5328/lib/php.ini

安裝PHP 5.4.29

$ cd /opt/src

$ tar -xvjf php-5.4.29.tar.bz2

$ cd php-5.4.29

$ ./configure –prefix=/opt/php/5429 –with-config-file-scan-dir=/opt/php/5429/etc/php.d –with-mysql –with-pdo-mysql –with-mysqli –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –enable-ftp –disable-debug –disable-ipv6 –disable-short-tags –enable-calendar –with-imap –with-imap-ssl –with-kerberos

$ make

$ sudo make install

$ cp php.ini-development /opt/php/5429/lib/php.ini

安裝PHP 5.5.14

$ cd /opt/src

$ tar -xvjf php-5.5.14.tar.bz2

$ cd php-5.5.14

$ ./configure –prefix=/opt/php/5514 –with-config-file-scan-dir=/opt/php/5514/etc/php.d –with-mysql –with-pdo-mysql –with-mysqli –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –enable-ftp –disable-debug –disable-ipv6 –disable-short-tags –enable-calendar –with-imap –with-imap-ssl –with-kerberos

$ make

$ sudo make install

$ cp php.ini-development /opt/php/5514/lib/php.ini

4. 安裝Apache

$ sudo apt-get install apache2

啟用相應模塊

$ a2enmod headers

$ a2enmod expires

$ a2enmod actions

$ a2enmod rewrite

5. 配置Apache

$ sudo vi /etc/apache2/httpd.conf

追加如下腳本映射和虛擬主機配置,原理同Windows的配置說明。

ServerName localhost

AddType application/x-httpd-php .php

ScriptAlias /php-5217/ “/opt/php/5217/bin/”

ScriptAlias /php-5328/ “/opt/php/5328/bin/”

ScriptAlias /php-5429/ “/opt/php/5429/bin/”

ScriptAlias /php-5514/ “/opt/php/5514/bin/”

Directory /var/www/sites

Options Indexes FollowSymLinks Includes ExecCGI

DirectoryIndex index.php index.html

AllowOverride All

Order allow,deny

Allow from all

/Directory

Directory /var/www/sites/5217

Action application/x-httpd-php “/php-5217/php-cgi”

/Directory

Directory /var/www/sites/5328

Action application/x-httpd-php “/php-5328/php-cgi”

/Directory

Directory /var/www/sites/5429

Action application/x-httpd-php “/php-5429/php-cgi”

/Directory

Directory /var/www/sites/5514

Action application/x-httpd-php “/php-5514/php-cgi”

/Directory

# Virtualhosts

VirtualHost *:80

ServerAdmin webmaster@php5217.local

DocumentRoot “/var/www/sites/5217/test.local”

ServerName php5217.local

ErrorLog “/var/log/apache2/php5217.local-error.log”

CustomLog “/var/log/apache2/php5217.local-access.log” common

/VirtualHost

VirtualHost *:80

ServerAdmin webmaster@php5328.local

DocumentRoot “/var/www/sites/5328/test.local”

ServerName php5328.local

ErrorLog “/var/log/apache2/php5328.local-error.log”

CustomLog “/var/log/apache2/php5328.local-access.log” common

/VirtualHost

VirtualHost *:80

ServerAdmin webmaster@php5429.local

DocumentRoot “/var/www/sites/5429/test.local”

ServerName php5429.local

ErrorLog “/var/log/apache2/php5429.local-error.log”

CustomLog “/var/log/apache2/php5429.local-access.log” common

/VirtualHost

VirtualHost *:80

ServerAdmin webmaster@php5514.local

DocumentRoot “/var/www/sites/5514/test.local”

ServerName php5514.local

ErrorLog “/var/log/apache2/php5514.local-error.log”

CustomLog “/var/log/apache2/php5514.local-access.log” common

/VirtualHost

保存配置後,創建各站點的DocumentRoot目錄,再往每個目錄放置一個phpinfo的測試文件,完成後重啟Apache服務器並在本地hosts文件加入域名解析,現在就可以訪問各站點來測試多版本PHP共存了。

好了,基本的多版本PHP共存解決方案已經完成,如果還需要添加其他的PHP類庫支持,後續自己再調用對應php目錄下的pecl, php_config等腳本編譯安裝就可以了。

原創文章,作者:PEWU,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/141790.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
PEWU的頭像PEWU
上一篇 2024-10-08 18:05
下一篇 2024-10-09 09:52

相關推薦

發表回復

登錄後才能評論