lnmp 2 分钟
apache使用php-fpm配置多版本
需求
有时候我们需要在同一台服务器配置多个php版本利于开发测试,我们可以直接使用他人做好的包直接安装配置,以deepin示例。
步骤
首先加入多版本php源
sudo apt-get -y install apt-transport-https lsb-release ca-certificates sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' sudo apt-get update安装
apache和多版本php-fpmsudo apt-get install apache2 php5.6-fpm php7.0-fpm php7.1-fpm打开apache
headers和proxy_fcgi模块sudo a2enmod headers proxy_fcgiapache和php-fpm建议运行用户配置成当前登录账号,避免出现权限问题配置虚拟域名
<VirtualHost *:80> ServerName m1.mycoolcell.local ServerAlias m1.mycoolcell.local ServerAdmin webmaster@localhost DocumentRoot /home/dyl/website/mycoolcell_m1 SetEnv MAGE_RUN_CODE wholesale SetEnv MAGE_RUN_TYPE website <FilesMatch "\.php$"> <If "-f %{REQUEST_FILENAME}"> SetHandler "proxy:unix:/run/php/php5.6-fpm.sock|fcgi://localhost/" </If> </FilesMatch> ErrorLog ${APACHE_LOG_DIR}/m1.mycoolcell.local.error.log CustomLog ${APACHE_LOG_DIR}/m1.mycoolcell.local.access.log combined </VirtualHost>
```
如果需要其他版本,将上面的
php5.6-fpm.sock配置成php7.1-fpm.sock即可。