Let's talk about the solution for WAMP unable to run PHP files

PHPz
Release: 2023-04-11 09:58:02
Original
1068 people have browsed it

WAMP (Windows Apache MySQL PHP) is an integrated WEB development environment that runs under the Windows platform. It can easily build a local WEB server and provide a development and testing environment. However, sometimes when using WAMP, we will encounter the problem of being unable to run PHP files. This article will introduce how to solve the problem that WAMP cannot run PHP files.

Problem phenomenon

When we enter "http://localhost/test.php" in the browser, the browser will prompt to download and save the test.php file instead of executing the file as shown below. This means that WAMP cannot run PHP files.

Solution

1. Check the PHP version

WAMP contains multiple versions of PHP. First, you need to make sure that you are currently using the correct version. You can select the "PHP" column in WAMP's system tray to view the installed PHP version. If the current version is not the latest version, you can update to the latest version.

2. Check the PHP.ini configuration file

In WAMP, PHP configuration information is stored in the php.ini file. If the PHP module is not enabled in the configuration file, it may also cause the PHP file to fail to run. Therefore, you need to check whether the following options in the php.ini file are configured correctly:

extension_dir = "C:\wamp64\bin\php\php7.4.16\ext\"
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll

Among them, extension_dir needs to be set to the absolute path of the ext directory of the corresponding version of PHP, and extension needs to enable the corresponding PHP module.

Note: PHP7.0 and later versions have canceled php_mysql.dll. If you want to use the MySQL database, you need to start php_mysqli and php_pdo_mysql.

3. Check the Apache configuration file

In WAMP, the Apache configuration file is saved in the httpd.conf file. In this file, make sure that the following statements are not commented out:

LoadModule php7_module "C:/wamp64/bin/php/php7.4.16/php7apache2_4.dll"

AddHandler application/x -httpd-php .php
AddHandler application/x-httpd-php-source .phps

4. Restart the WAMP service

If the PHP or Apache configuration file is changed while WAMP is running , you should restart the WAMP service. You can select "Stop all services" in the WAMP system tray and then restart the WAMP service.

Summary

Through the above steps, you should be able to solve the problem of WAMP being unable to run PHP files. Apart from this, there are some other possible solutions, such as checking system environment variables, browser cache, etc. If none of the above solutions solve the problem, you can seek help in relevant forums or the official WAMP website.

The above is the detailed content of Let's talk about the solution for WAMP unable to run PHP files. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template