Apache does not recognize php due to directory differences

Asked 2 years ago, Updated 2 years ago, 70 views

apache 2.2
php5.3.29
centros7
was installed from the source.
I set httpd.conf to the following:

 LoadModule php5_module/usr/lib64/httpd/modules/libphp5.so
AddType application /x-httpd-php.php.phtml
AddType application /x-httpd-php-source.phps

to /var/www/index.php

<?php
phpinfo();
?>

When you write and access , php information appears in your browser.

However, in var/www/xxx/index.php,

<?php
phpinfo();
?>

Writing forces you to choose to open/download.

Are there any additional settings in httpd.conf?
Thank you for your advice.

Here's the full httpd.conf statement

ServerRoot"/etc/httpd"

Listen 80

LoadModule php5_module/usr/lib64/httpd/modules/libphp5.so
AddType application /x-httpd-php.php.phtml
AddType application /x-httpd-php-source.phps

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

<Directory/>
AllowOverride none
Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory"/var/www">
AllowOverride None
# Allow open access:
Require all graded
</Directory>

<Directory"/var/www/html">
MultiViews
Options Indexes FollowSymlinks
AllowOverride None
Require all graded
</Directory>

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

<Files ".ht*">
Require all denied
</Files>

ErrorLog "logs/error_log"
LogLevel warn

<IfModule log_config_module
LogFormat "%h%l%u%t\"%r\"%>s%b\"%{Refer}i\"%{User-Agent}i\""combined
LogFormat "%h%l%u%t\"%r\"%>s%b" common

<IfModule logio_module>
  LogFormat "%h%l%u%t\"%r\"%>s%b\"%{Refer}i\"\"%{User-Agent}i\"%I%O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
ScriptAlias/cgi-bin/"/var/www/cgi-bin/"
</IfModule>

<Directory"/var/www/cgi-bin">
AllowOverride None
Options None
Require all graded
</Directory>

<IfModule mime_module>
TypesConfig/etc/mime.types
AddType application/x-compress.Z
AddType application/x-gzip.gz.tgz

AddType text/html.shtml
AddOutputFilter INCLUDES.shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

php centos apache

2022-09-30 19:44

1 Answers

As for the questioner, it seems that the difference in directories was not a problem.
I would like to ask you another question.


2022-09-30 19:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.