gpt4 book ai didi

php - 如何在 Centos 7 中为 php 8 配置 apache?

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

我正在尝试在以下文件中为 Centos 7 中的 apache 设置正确的配置:
/etc/httpd/conf/httpd.conf
我的应用程序是 Laravel,它适用于 php 8。
我也需要一个用于第二个应用程序的子域,即 laravel。
这些是我的服务器 block :


<VirtualHost IP:80>
SuexecUserGroup "#1000" "#1000"
DocumentRoot /home/example/public
ServerName example.com
<Directory /home/example/public>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php7.2
AddHandler fcgid-script .php8.0
FCGIWrapper /home/example/php8.0.fcgi .php
FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/example/fcgi-bin/php7.2.fcgi .php7.2
FCGIWrapper /home/example/fcgi-bin/php8.0.fcgi .php8.0
</Directory>
ErrorLog /var/log/virtualmin/example.com_error_log
CustomLog /var/log/virtualmin/example.com_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
ScriptAlias /awstats/ /home/example/cgi-bin/
DirectoryIndex index.php index.php4 index.php5 index.htm index.html

<Directory /home/example/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.example.com
RewriteRule ^(?!/.well-known)(.*) https://example.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.example.com
RewriteRule ^(?!/.well-known)(.*) https://subdomain.example.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php7.2
RemoveHandler .php8.0
FcgidMaxRequestLen 1073741824
<Files awstats.pl>
AuthName "example.com statistics"
AuthType Basic
AuthUserFile /home/example/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch ^/(?!.well-known)(.*)$ http://example.com/$1
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8001
</FilesMatch>
</VirtualHost>


<VirtualHost IP:80>
SuexecUserGroup "#1000" "#1000"
DocumentRoot /home/subdomain.example/public
ServerName subdomain.example.com
<Directory /home/subdomain.example/public>
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php7.2
AddHandler fcgid-script .php8.0
FCGIWrapper /home/example/php8.0.fcgi .php
FCGIWrapper /home/example/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/example/fcgi-bin/php7.2.fcgi .php7.2
FCGIWrapper /home/example/fcgi-bin/php8.0.fcgi .php8.0
</Directory>
ErrorLog /var/log/virtualmin/example.com_error_log
CustomLog /var/log/virtualmin/example.com_access_log combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
ScriptAlias /awstats/ /home/example/cgi-bin/
DirectoryIndex index.php index.php4 index.php5 index.htm index.html

<Directory /home/subdomain.example/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.subdomain.example.com
RewriteRule ^(?!/.well-known)(.*) https://subdomain.example.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.subdomain.example.com
RewriteRule ^(?!/.well-known)(.*) https://subdomain.example.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php7.2
RemoveHandler .php8.0
FcgidMaxRequestLen 1073741824
<Files awstats.pl>
AuthName "example.com statistics"
AuthType Basic
AuthUserFile /home/example/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch ^/(?!.well-known)(.*)$ http://subdomain.example.com/$1
<FilesMatch \.php$>
SetHandler proxy:fcgi://localhost:8001
</FilesMatch>
</VirtualHost>

更改此文件后,我重新启动了 apache 服务器。
我还在 dns 管理器中设置了子域。
任何人都可以在这个问题上帮助我。加上没有子域它可以正常工作,但子域不能。

最佳答案

将此 block 添加到所有 <VirtualHost> block :

AddHandler php-fcgi .php
Action php-fcgi /php-cgi
Alias /php-cgi "/usr/bin/php-cgi -f"

关于php - 如何在 Centos 7 中为 php 8 配置 apache?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70730058/

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