Display plain PHP code

I am using Amazon EC2, CentOS 7 x64_86, 1GB RAM.

(1) Run command

php -v

result

PHP 7.0.24 (cli) (built: Sep 30 2017 10:10:28) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

(2) Run command

httpd -v

result

Server version: Apache/2.4.6 (CentOS)
Server built:   Oct 19 2017 20:39:16

(3) Run command

vi /etc/httpd/conf.d/welcome.conf

Result

#
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL.  To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
#<LocationMatch "^/+$">
#    Options -Indexes
#    ErrorDocument 403 /.noindex.html
#</LocationMatch>

<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>

Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png

Error

enter image description here

and

enter image description here

How to fix it?

0
задан 28 October 2017 в 12:33
1 ответ

Я не уверен, откуда у вас PHP, поскольку в CentOS 7 поставляется версия 5.4.16. В любом случае, стандартный пакет php устанавливает конфигурацию для Apache, так что файлы *. Php загружаются через интерпретатор PHP (поэтому они не просто возвращают исходный код). Вам нужно добавить что-то вроде этого в вашу конфигурацию Apache:

LoadModule php5_module modules/libphp5.so

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

Это основано на стандартной конфигурации пакета php . Если вы сами скомпилировали PHP, вам нужно будет адаптировать его под себя.

0
ответ дан 5 December 2019 в 07:17

Теги

Похожие вопросы