gpt4 book ai didi

php - 索引 PHP 下载而不是执行它

转载 作者:行者123 更新时间:2023-12-04 19:30:41 25 4
gpt4 key购买 nike

我用 php 7.4 更新了我的服务器,但是它产生了一些问题,我的网站无法再次运行,问题在重新安装 httpd 或安装 httpd-devel 后开始不确定
我有 bitrix 管理我的网站,但是该应用程序也托管在服务器上,并且每当我尝试访问它时都不会部署它,它会下载 php 文件,我至少需要它才能再次运行
环境 :
森托斯 7
PHP7.4
httpd -v : 服务器版本: Apache/2.4.6 (CentOS)
nginx -v :nginx版本:nginx/1.16.1
我尝试使用“AddType”和“AddHandler”但没有机会
我尝试删除 htaccess 并重新创建相同的问题
我找不到 LoadModule php so 模块,即使在模块文件中,所以我没有尝试过该选项或者我不知道从哪里开始
我的网站之一的 conf 文件示例:

# Ansible managed
# site: medrec.org
<VirtualHost 127.0.0.1:8887>
ServerName medrec.org
ServerAlias www.medrec.org
ServerAdmin webmaster@localhost
DocumentRoot /home/bitrix/ext_www/medrec.org/public

ErrorLog logs/medrec_error_log
LogLevel warn
CustomLog logs/medrec_access_log combined

<IfModule mod_rewrite.c>
#Nginx should have "proxy_set_header HTTPS YES;" in location
RewriteEngine On
RewriteCond %{HTTP:HTTPS} =YES
RewriteRule .* - [E=HTTPS:on,L]
</IfModule>




<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<DirectoryMatch .*\.svn/.*>
Require all denied
</DirectoryMatch>

<DirectoryMatch .*\.git/.*>
Require all denied
</DirectoryMatch>

<DirectoryMatch .*\.hg/.*>
Require all denied
</DirectoryMatch>

<Directory /home/bitrix/ext_www/medrec.org/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Require all granted

#php_admin_value session.save_path /tmp/php_sessions/ext_www/medrec.org
#php_admin_value upload_tmp_dir /tmp/php_upload/ext_www/medrec.org
</Directory>
<Directory /home/bitrix/ext_www/medrec.org/bitrix/cache>
AllowOverride none
Require all denied
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/bitrix/managed_cache>
AllowOverride none
Require all denied
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/bitrix/local_cache>
AllowOverride none
Require all denied
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/bitrix/stack_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/medrec.org/upload>
AllowOverride none
#AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#php_value engine off
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/upload/support/not_image>
AllowOverride none
Require all denied
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/bitrix/images>
AllowOverride none
#AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#php_value engine off
</Directory>

<Directory /home/bitrix/ext_www/medrec.org/bitrix/tmp>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
#php_value engine off
</Directory>

</VirtualHost>
httpd.conf
ServerTokens OS
ServerRoot "/etc/httpd"
PidFile run/httpd.pid

# Timeout: The number of seconds before receives and sends time out.

Timeout 120

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 15

<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

# Active module

Include conf.modules.d/*.conf
<IfModule setenvif_module>
SetEnvIf X-Forwarded-Scheme https HTTPS=on
SetEnvIf X-Forwarded-Proto https HTTPS=on
</IfModule>

#
# Disabled standart config
#

#Include conf.d/*.conf

#
# BitrixEnv include configs
#

Include bx/conf/*.conf
Include bx/custom/*.conf

User bitrix
Group bitrix

ServerAdmin root@localhost

UseCanonicalName Off

DocumentRoot "/home/bitrix/www"

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<IfModule mod_userdir.c>
UserDir disable
</IfModule>

DirectoryIndex index.html
AccessFileName .htaccess

<Files ~ "^\.ht">
Require all denied
</Files>

TypesConfig /etc/mime.types
#ForceType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off
ErrorLog logs/error_log

LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log combined

ServerSignature On

<IfModule mod_dav_fs.c>
# Location of the WebDAV lock database.
DAVLockDB /var/lib/dav/lockdb
</IfModule>

<IfModule mod_autoindex.c>
IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>

AddLanguage ca .ca
(Laguages ...)

#LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
#ForceLanguagePriority Prefer Fallback

AddDefaultCharset UTF-8

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

AddHandler type-map var
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml


BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

#BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
#BrowserMatch "MS FrontPage" redirect-carefully
#BrowserMatch "^WebDrive" redirect-carefully
#BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
#BrowserMatch "^gnome-vfs/1.0" redirect-carefully
#BrowserMatch "^XML Spy" redirect-carefully
#BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
更新
conf.modules.d 中的 conf 列表
enter image description here
15-php.conf
enter image description here
模块
enter image description here

最佳答案

你的模块似乎搞砸了。
检查是否加载了 php7 模块:

# apachectl -M | grep -i php
php7_module (shared)
在您的 httpd.conf 中,通过在 conf.modules.d 目录中包含现有文件来加载 php7 模块。 libphp7-zts.so表示线程安全。
而且您的 Apache 似乎不喜欢它。
您仅使用以下行设置 MIME 类型:
AddType  application/x-httpd-php         .php
AddType application/x-httpd-php-source .phps
要处理 PHP,您需要 设置处理程序 .
所以用这个替换你的 15-php.conf 文件:
LoadModule php7_module modules/libphp7.so
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>

关于php - 索引 PHP 下载而不是执行它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66018922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com