Home >Backend Development >PHP Problem >What should I do if php is not parsed?

What should I do if php is not parsed?

王林
王林Original
2020-07-11 15:06:074741browse

The solution to the problem that php is not parsed is to add the corresponding php type in the configuration file. Specific methods: 1. Open the httpd.conf configuration file; 2. Add the configuration [AddType application/x-httpd-php .php].

What should I do if php is not parsed?

Problem description:

When executing the php file, it was found that the php code was not parsed and only the source code was returned.

(Recommended tutorial: php tutorial)

Test:

Test code:

<?php
    phpinfo();
?>

Running the file should return the php information page , but only the source code is returned.

The reasons and solutions are as follows:

1. Apache has not added the corresponding PHP type, so it does not support PHP script parsing.

Solution: Add the corresponding PHP type in the configuration file Type

Find the apache configuration file

Execute in the root directory:

#find / -name "httpd.conf"

Modify httpd.conf and add a line to the file:

AddType application/x-httpd-php .php

2, There is no index for php. If there is no support for this index, web pages written in php cannot be parsed.

Solution: Add the corresponding index to the configuration file

The method for finding the configuration file is the same as above , find

DirectoryIndex index.html

and change it to

DirectoryIndex index.html index.htm index.php

.

3. The firewall is turned on

Execute the following command to check the status of the firewall

#getenforce

If it is Enforcing, it means it is turned on. At this time, we can modify the enforcing in the config to disabled in the /etc/selinu directory.

4. The php5_module module is not loaded

Solution: Add the module

Add in the configuration file:

LoadModule php5_module modules/libphp5.so

Finally restart the computer.

After completion, retest again. Now you can return php information.

The above is the detailed content of What should I do if php is not parsed?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn