繁体   English   中英

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

[英]How to config apache for php 8 in Centos 7?

我正在尝试在以下文件中为 Centos 7 中的 apache 设置正确的配置:

/etc/httpd/conf/httpd.conf

我的应用程序是 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 管理器中设置了子域。

任何人都可以在这个问题上帮助我。 加上没有子域它可以正常工作,但子域不能。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM