I'm trying set proper configuration for apache in Centos 7 in below file:
/etc/httpd/conf/httpd.conf
My application is Laravel and it works with php 8.
Also I need a subdomain for second application too which is laravel.
These are my server 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>
After changing this file I restarted apache server.
Also I set subdomain in dns manager.
Can anyone help me in this subject. Plus With no subdomain it work fine but subdomain not.
Add this block to all of <VirtualHost>
blocks:
AddHandler php-fcgi .php
Action php-fcgi /php-cgi
Alias /php-cgi "/usr/bin/php-cgi -f"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.