Home >php教程 >php手册 >Environment configuration of apache+mysql+php

Environment configuration of apache+mysql+php

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-11-30 23:59:311019browse

1 Preparation before configuration

1 First set the environment variables (for win7)

win10

2 Configure apache

I used EditPlus to open httpd.conf

LoadModule php5_module "c:/wamp/php/php5apache2_2.dll"

dll is lowercase LL, not uppercase II. They are the same in Editplus

Note: You must restart apache every time you change the apache configuration file

Instructions

//LoadModule checks whether it is loaded

// php5_module module name in httpd.conf

// "c:/wamp/php/php5apache2_2.dll" module path

Check

Check if the module can parse php files:

1 The root directory of the default website C:wampapachehtdocs

2 Create a new test.php in the root directory of the default website

Enter the following code:

Enter 127.0.0.1/1.php or localhost/1.php in the browser to get the following results

Add in Editplus

AddType application/-x-httpd-php .php

Instructions

AddType checks whether it can be parsed

Add file extension .php

Restart apache and see the result

If there is an error in the configuration file, what to do:

In win10 system, press win+x to select administrator mode

3 Configure database

It has been configured during the installation process. Please see the previous blog post for details. Password 123456

Four Configure php

1.Prerequisite preparation

Show file extension

win7

win10

2 Start configuration

PHP5 configuration settings (php.ini):

Change php.ini-development to php.ini --->OK.

Explanation: The comment in php.ini is “;”

Look at the picture

Open php.ini to start configuration

Case: Verify whether the database is connected

//mysql_connect('database server','database username (default is root)','database password (set by yourself during configuration)')
$link = mysql_connect('localhost',' root','1234');
if ($link) {
echo "Database connection successful";
}else{
echo "Database connection failed";
}
?>

Run results

It took me a long time to find it because when I configured the apache environment, I didn’t check whether I could connect to the database

So you also need to configure the database in the apache configuration file

PhpIniDir "c:/wamp/php"

Instructions

PhpIniDir checks whether the database is connected

"c:/wamp/php" Specify the php.ini path in the apache main configuration file.

Look at the picture

Restart apache to see the results

I just verified that the above situation will also occur if the extension path of php is not set in the main configuration file of php

That’s it, there is no setting

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