Home > Article > Backend Development > What is the reason why php is not parsed under Linux? How to deal with it?
When using a Linux system to deploy web applications, many people will encounter a very strange problem: the PHP file cannot be downloaded, but the PHP code is directly displayed. This kind of problem usually occurs in some older Linux systems, in which the PHP version is lower, or the PHP file processing module is not installed correctly.
On the one hand, the occurrence of this problem will affect the normal operation of the Web application, and on the other hand, it also involves the security issues of the Web application. Therefore, we need to solve this problem to ensure the normal operation of the system and the security of the application.
Here are some solutions:
In Linux systems, PHP is usually installed through the package manager, Such as yum or apt-get. If PHP did not install correctly, reinstall PHP and make sure all dependencies are installed as well.
The Web server needs to correctly configure the PHP interpreter so that it can run PHP code normally. For Apache servers, PHP can be configured by editing the httpd.conf file. Open the httpd.conf file and add the following code at the end of the file:
<IfModule php5_module> AddHandler application/x-httpd-php .php AddType application/x-httpd-php .php .html AddType application/x-httpd-php-source .phps </IfModule>
This configuration will tell the Apache server to parse .php files into PHP script files and set the file type to application/x-httpd-php.
In Linux systems, the PHP module needs to be manually enabled to work correctly. You can check whether the PHP module is enabled by executing the following command:
php -m
If the required module is not listed, edit the php.ini file and enable the corresponding module, for example:
extension=mysql.so
When using a Linux system, ensure that the PHP file has sufficient permissions to run correctly. File permissions can be checked using the following command:
ls -l filename.php
If the file permissions are incorrect, use the following command to change the permissions:
chmod 644 filename.php
This will set the correct read and write permissions for the PHP file to ensure The file works fine.
Summary
The above are several methods to solve the problem of PHP file download not parsing under Linux. These methods can help us solve this problem. When using a Linux system, we need to ensure that the system is running properly, especially the security of web applications. To do this, we need to keep our systems and applications up to date and know how to fix common problems so we can resolve them quickly.
The above is the detailed content of What is the reason why php is not parsed under Linux? How to deal with it?. For more information, please follow other related articles on the PHP Chinese website!