简体   繁体   English

LAMP服务器上的多个php-fpm版本

[英]Multiple php-fpm versions on LAMP Server

(With the tutorial and afterwards with the help of Thomas Christlieb) (在本教程中,然后在Thomas Christlieb的帮助下)

The configuration used right now is the following : 现在使用的配置如下:

System runs on an "old" HP EliteBook, 
which should run as test server before going live + backup server
SystemOS : Linux Mint 18.3 (based on Ubuntu 16.04)
Access to Site via Windows PC in same Network

To install the LAMP Server + fpm modules, I followed this steps : 要安装LAMP Server + fpm模块,我遵循以下步骤:

  1. sudo apt-get install apache2 apache2-utils mysql-server phpmyadmin
  2. sudo a2dismod php7.2 (which was installed with phpmyadmin)
  3. sudo add-apt-repository ppa:ondrej/php
  4. sudo apt-get update && sudo apt-get upgrade
  5. sudo apt-get install libapache2-mod-fastcgi libapache2-mod-fcgid
  6. sudo apt-get install php5.6-fpm php5.6 php5.6-mcrypt php5.6-mbstring php5.6-mysql php5.6-zip php5.6-gd php5.6-xml
  7. sudo apt-get install php7.0-fpm php7.0 php7.0-mcrypt php7.0-mbstring php7.0-mysql php7.0-zip php7.0-gd php7.0-xml
  8. sudo a2enmod actions
  9. sudo a2enmod fastcgi
  10. sudo a2enmod fcgid
  11. sudo a2enmod rewrite
  12. sudo a2enmod suexec
  13. sudo a2enmod include (a2enmod's just to check if they are already enabled) sudo a2enmod include (a2enmod仅用于检查它们是否已启用)
  14. sudo service apache2 restart (to restart the server so everything will be loaded correctly) sudo service apache2 restart (重新启动服务器,以便将所有内容正确加载)
  15. created 2 files in /etc/apache2/sites-available , one php56.conf , one php70.conf /etc/apache2/sites-available创建了2个文件,一个php56.conf ,一个php70.conf
  16. created 2 directorys in /var/www/html , one PHP 5.6, one PHP 7.0 /var/www/html创建了2个目录,一个PHP 5.6,一个PHP 7.0
  17. sudo a2dissite 000-default (disable default site) sudo a2dissite 000-default (禁用默认站点)
  18. sudo a2ensite php56 php70 (enable PHP 5.6 & PHP 7.0 site) sudo a2ensite php56 php70 (启用PHP 5.6和PHP 7.0站点)
  19. sudo service apache2 restart
  20. /etc/apache2/sites-available/php56.conf : /etc/apache2/sites-available/php56.conf:

     <IfModule mod_fastcgi.c> AddHandler php56-fcgi-www .php Action php56-fcgi-www /php56-fcgi-www Alias /php56-fcgi-www /usr/lib/cgi-bin/php56-fcgi-www FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi-www -socket /run/php/php5.6-fpm.sock -pass-header Authorization <Directory "usr/lib/cgi-bin"> Require all granted </Directory> </IfModule> <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName php56 DocumentRoot /var/www/html/php56 <Directory "/var/www/html/php56"> Options Indexes FollowSymLinks MultiViews AllowOverride All SetHandler php56-fcgi-www </Directory> ErrorLog $(APACHE_LOG_DIR)/error.log CustomLog $(APACHE_LOG_DIR)/access.log combined </VirtualHost> 
  21. /etc/apache2/sites-available/php70.conf : /etc/apache2/sites-available/php70.conf:

     <IfModule mod_fastcgi.c> AddHandler php70-fcgi-www .php Action php70-fcgi-www /php70-fcgi-www Alias /php70-fcgi-www /usr/lib/cgi-bin/php70-fcgi-www FastCgiExternalServer /usr/lib/cgi-bin/php70-fcgi-www -socket /run/php/php7.0-fpm.sock -pass-header Authorization <Directory "usr/lib/cgi-bin"> Require all granted </Directory> </IfModule> <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName php70 DocumentRoot /var/www/html/php70 <Directory "/var/www/html/php70"> Options Indexes FollowSymLinks MultiViews AllowOverride All SetHandler php70-fcgi-www </Directory> ErrorLog $(APACHE_LOG_DIR)/error.log CustomLog $(APACHE_LOG_DIR)/access.log combined </VirtualHost> 
  22. In both PHP 5.6 & PHP 7.0 Directories I created a file info.php 在PHP 5.6和PHP 7.0目录中,我都创建了一个文件info.php

     <?php phpinfo() ?> 
  23. sudo service apache2 restart (to reload the changed configuration) sudo service apache2 restart (重新加载更改的配置)


So now the LAMP Server is installed with php5.6-fpm & php7.0-fpm but now my first problem occurs. 因此,现在LAMP Server已安装了php5.6-fpmphp7.0-fpm但现在出现了我的第一个问题。

When I open PHP 7.0 Site in Web browser it shows me the correct phpinfo() which tells me : 当我在网络浏览器中打开PHP 7.0网站时,它向我显示了正确的phpinfo() ,它告诉我:

PHP Version 7.0.27-1 + ubuntu16.04.1 + deb.sury.org + 1 Server API FPM/FastCGI Loaded Configuration File /etc/php/7.0/fpm/php.ini ... PHP版本7.0.27-1 + ubuntu16.04.1 + deb.sury.org + 1服务器API FPM / FastCGI加载的配置文件/etc/php/7.0/fpm/php.ini ...


But when I open the PHP 5.6 site in web browser it shows me the exact same phpinfo() output. 但是,当我在Web浏览器中打开PHP 5.6网站时,它向我显示了完全相同的phpinfo()输出。 So I tried disabling the PHP 7.0 site to check whether or not my PHP 5.6 config might be corrupt. 因此,我尝试禁用PHP 7.0站点以检查我的PHP 5.6配置是否损坏。

sudo a2dissite php70
sudo service apache2 reload

Now when I open PHP 5.6 (same for PHP 7.0) it shows me the phpinfo for PHP Version 5.6 like this : 现在,当我打开PHP 5.6(与PHP 7.0相同)时,它向我显示了PHP版本5.6的phpinfo ,如下所示:

PHP Version 5.6.33-3 + ubuntu16.04.1 + deb.sury.org + 1 Server API FPM/FastCGI Loaded Configuration File /etc/php/5.6/fpm/php.ini ... PHP版本5.6.33-3 + ubuntu16.04.1 + deb.sury.org + 1服务器API FPM / FastCGI加载的配置文件/etc/php/5.6/fpm/php.ini ...


From there on I asked Thomas Christlieb for help and with his instructions I made the following : 从那以后,我向托马斯·克里斯特利布(Thomas Christlieb)寻求帮助,并在他的指示下做了以下几点:

  1. a2dissite php56 php70 (to disable both site configuration files) a2dissite php56 php70 (同时禁用两个站点配置文件)
  2. a2ensite 000-default (to enable the default configuration file again) a2ensite 000-default (再次启用默认配置文件)
  3. Made the following modifications to '/etc/apache2/sites-available/000-default.conf' 对'/etc/apache2/sites-available/000-default.conf'进行了以下修改

     <IfModule mod_fastcgi.c> AddHandler php56-fcgi-www .php Action php56-fcgi-www /php56-fcgi-www Alias /php56-fcgi-www /usr/lib/cgi-bin/php56-fcgi-www FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi-www -socket /run/php5.6-fpm.sock -pass-header Authorization <Directory "/usr/lib/cgi-bin"> Require all granted </Directory> AddHandler php70-fcgi-www .php Action php70-fcgi-www /php70-fcgi-www Alias /php70-fcgi-www /usr/lib/cgi-bin/php70-fcgi-www FastCgiExternalServer /usr/lib/cgi-bin/php70-fcgi-www -socket /run/php7.0-fpm.sock -pass-header Authorization <Directory "/usr/lib/cgi-bin"> Require all granted </Directory> </IfModule> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory "/var/www/html/php70"> Options Indexes FollowSymLinks MultiViews AllowOverride All SetHandler php70-fcgi-www </Directory> <Directory "/var/www/html/php56"> Options Indexes FollowSymLinks MultiViews AllowOverride All SetHandler php56-fcgi-www </Directory> </VirtualHost> 
  4. sudo service apache2 restart (to reload the new configuration) sudo service apache2 restart (重新加载新配置)

So but now when I open both sites, I get the exact same error Message 'Internal Server Error', but those two messages are in a different font, which I suppose could mean that it should work like this, because otherwise they should be exactly the same, or am I wrong? 因此,但是现在当我打开两个站点时,都收到完全相同的错误消息“内部服务器错误”,但是这两条消息的字体不同,我想这可能意味着它应该像这样工作,因为否则它们应该完全一样一样,还是我错了?

I googled around a lot, also looked up on here, but the this problem wasn't really present as I don't use docker nor Nginx in my configuration. 我在附近搜索了很多东西,也在这里查找,但是这个问题实际上并没有出现,因为我在配置中没有使用docker或Nginx。 Maybe someone already had a problem like this and could tell me how to resolve the last step that I am missing. 也许有人已经遇到了这样的问题,可以告诉我如何解决我所缺少的最后一步。


Access.log Information Access.log信息


...
100.100.100.11 - - [20/Feb/2018:08:26:14 +0100] "GET /php56/info.php HTTP/1.1" 500 805 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0"
100.100.100.11 - - [20/Feb/2018:08:37:35 +0100] "GET /php56/info.php HTTP/1.1" 500 805 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0"
...

Error.log Information Error.log信息


...
[Tue Feb 20 09:30:08.166199 2018] [fastcgi:error] [pid 27475] (2)No such file or directory: [client 100.100.100.11:52772] FastCGI: failed to connect to server "/usr/lib/cgi-bin/php56-fcgi-www": connect() failed
[Tue Feb 20 09:30:08.166574 2018] [fastcgi:error] [pid 27475] [client 100.100.100.11:52772] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php56-fcgi-www"
...

This is what I noticed now while looking trough the Error.log but I don't know why it says so. 这是我现在在浏览Error.log注意到的,但我不知道为什么会这样。 I checked the status of php5.6-fpm , php7.0-fpm , apache2 , they are all 3 active (running) so I can't help myself anymore and need help. 我检查了php5.6-fpmphp7.0-fpmapache2 ,它们都处于活动状态3(正在运行),所以我php7.0-fpm帮助自己,需要帮助。

So no more need for an answer, Thomas Christlieb found the problem now. 因此,Thomas Christlieb不再需要答案,现在发现了问题。

In my 000-default.conf the FastCgiExternalServer i had a wrong path inside. 在我的000-default.conf中,FastCgiExternalServer的内部路径错误。

He changed /run/php5.6-fpm.sock to /run/php/php5.6-fpm.sock 他将/run/php5.6-fpm.sock更改为/run/php/php5.6-fpm.sock

and /run/php7.0-fpm.sock to /run/php/php7.0-fpm.sock 和/run/php7.0-fpm.sock到/run/php/php7.0-fpm.sock

and now everything works just fine as it should. 现在一切正常。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM