[英]PHP not running in VirtualHost on Apache
我必须从旧服务器(Plesk 14; CentOS 5; Apache 2.2; PHP 5.3.5)
迁移到新服务器(Plesk Onyx 17; CentOS 7.3; Apache 2.4; PHP 7)
除了自定义虚拟主机之外,其他所有东西都可以正常工作。
在旧服务器上,在我的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>
如果我没有php_admin_flag engine on
和AddHandler
,它将以文本格式下载php文件。
在新服务器上,我尝试了完全相同的方法,它只是下载了php文件。
我还尝试在<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
值得一提的是,在此Plesk上有多个PHP版本。 当我执行php -v
我得到PHP 5.3.5 (cli)
但是当我在页面中使用phpinfo()
,我得到“ PHP版本7.0.18”。
我的猜测是,这与此有关。
在Plesk的“管理”面板上,它说run PHP 7 as FPS Application
这是phpinfo()
的快照https://pste.eu/p/BGpI.html
知道会是什么吗?
嗨Miro,
您是否考虑过从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.
=>主页>工具和设置> Apache Web服务器>(选项)MPM模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.