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

jgovgodb  于 2022-11-07  发布在  PHP
关注(0)|答案(1)|浏览(770)

我正在尝试为Centos 7中的apache设置正确的配置,在下面的文件中:
/etc/httpd/配置文件/httpd.配置文件
我的应用程序是Laravel和它的工作与php 8.
此外,我需要一个子域的第二个应用程序也是laravel。
这些是我的服务器块:

<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管理器中设置子域。
有没有人能在这个问题上帮我。加上没有子域,它工作正常,但子域不是。

ybzsozfc

ybzsozfc1#

将此块添加到所有<VirtualHost>块中:

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

相关问题