[英]PHP not running in VirtualHost on Apache
I had to migrate from an old server (Plesk 14; CentOS 5; Apache 2.2; PHP 5.3.5)
to a new one (Plesk Onyx 17; CentOS 7.3; Apache 2.4; PHP 7)
我必须从旧服务器
(Plesk 14; CentOS 5; Apache 2.2; PHP 5.3.5)
迁移到新服务器(Plesk Onyx 17; CentOS 7.3; Apache 2.4; PHP 7)
Everything works fine with the exception of the custom Virtual Hosts. 除了自定义虚拟主机之外,其他所有东西都可以正常工作。
On the old server, in my etc/httpd/conf/httpd.conf
I had the following and it was working: 在旧服务器上,在我的
etc/httpd/conf/httpd.conf
我有以下内容,并且可以正常工作:
<VirtualHost XX.XX.XX.XX:80>
DocumentRoot /var/www/vhosts/mycompany.com/httpdocs/myproject
ServerName myproject.com
ServerAlias www.myproject.com
<Directory /var/www/vhosts/mycompany.com/httpdocs/myproject>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php5.c>
php_admin_flag safe_mode off
php_admin_value upload_tmp_dir "/tmp"
php_admin_value session.save_path "/tmp"
</IfModule>
php_admin_flag engine on
AddHandler php5-script .php
</Directory>
</VirtualHost>
If I didn't have the php_admin_flag engine on
and the AddHandler
it would just download the php file as text. 如果我没有
php_admin_flag engine on
和AddHandler
,它将以文本格式下载php文件。
On the new server I tried the exact same and it just downloads the php file. 在新服务器上,我尝试了完全相同的方法,它只是下载了php文件。
I also tried adding the following in <Directory>
with no success: 我还尝试在
<Directory>
添加以下内容,但没有成功:
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
#Error: Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
php_admin_flag engine on
# Invalid command 'php_admin_flag', perhaps misspelled or defined by a module not included in the server configuration
AddType text/html .php
#I used this to make sure AddType works. It does - PHP displayed as HTML
AddType application/x-httpd-php .php
#Downloads the file as text
AddHandler application/x-httpd-php .php
#Downloads the file as text
AddType php5-script .php
#Shows php as plain text
Something worth mentioning is that on this Plesk there are multiple PHP versions. 值得一提的是,在此Plesk上有多个PHP版本。 When I do
php -v
I get PHP 5.3.5 (cli)
but when I use phpinfo()
in a page I get "PHP Version 7.0.18". 当我执行
php -v
我得到PHP 5.3.5 (cli)
但是当我在页面中使用phpinfo()
,我得到“ PHP版本7.0.18”。
My guess is that it has something to do with that. 我的猜测是,这与此有关。
On the Admin panel in Plesk it says run PHP 7 as FPS Application
在Plesk的“管理”面板上,它说
run PHP 7 as FPS Application
Here's a snapshot of the phpinfo()
https://pste.eu/p/BGpI.html 这是
phpinfo()
的快照https://pste.eu/p/BGpI.html
Any idea what could it be? 知道会是什么吗?
Hi Miro, 嗨Miro,
did you consider to SWITCH from MPM-EVENT to MPM-PREFORK, in order to be able to USE the libapache2 - PHP - module ? 您是否考虑过从MPM-EVENT切换到MPM-PREFORK,以便能够使用libapache2-PHP模块?
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
#Error: Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
=> HOME > Tools & Settings > Apache Web Server > ( option ) MPM mode =>主页>工具和设置> Apache Web服务器>(选项)MPM模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.