Current location - Training Enrollment Network - Books and materials - How to test php code locally?
How to test php code locally?
First of all, you should download the following software, which is recommended by official website. If you are just testing like me, download it in skycn.com, which is faster.

Apache/

Is a multi-threaded structured query language (SQL) database server. SQL is the most popular database language in the world. MySQL has very high execution performance, very fast running speed and is very easy to use.

I downloaded the version of Windows, and the latest version is: 5.0.4 Beta.

PhpMyAdmin has been fixed, renamed to php.ini and copied to the windows directory.

Remember to give the server read access to PHP.ini on NTFS.

Look for e:/php/ext after extension_dir.

Find the Windows extension and draw a line below it; Remove the semicolon with extension =php_***. Dll, and support this component. I removed the semicolon of extension = PHP _ gd2.dll extension = PHP _ mbstring.dll extension = PHP _ MySQL.dll.

Php5 doesn't support mysql by default, so we need to add support for it. Except extension=php_mysql.dll, there is a libmysql.dll file in the Php directory, copy it to the system32 folder of the system, and copy php.ini to the windows directory.

At this point, the PHP environment has been basically configured successfully.

Create a file named test.php in the WEB root directory with the following contents.

& lt? echo phpinfo(); ? & gt

Restart the apache service and open http://localhost/test.php with a browser.

If you can see the output information of php configuration, it will be successful.

Install mysql

Install mysql into the specified directory, and then the installer will guide you to configure it step by step. But strangely, the Mysql icon did not appear in the final taskbar.

Modify the root password of mysql database

Enter lifeline mode with cmd and enter the following command: (Note: d:\mysql is the mysql installation directory)

cd d:\mysql\bin

Mysqladmin -u root -p password 123456

Enter and appear

Enter password: (Note: This means that you enter the original password. The password is empty at the first installation, so you just need to enter it)

At this point, the password of the account root in mysql is changed to 123456, and the installation is completed.

Configure php.ini and test mysql

Find extension_dir =。 /and change it to extension_dir = e:/php/ext.

find

; extension=php_mysql.dll

"Will"; " Remove and change to

extension=php_mysql.dll

find

; session.save_path = /tmp

"Will"; " Delete the directory where the session is saved, for example

Session. Save Path = e:/PHP/ Session Temporary

Restart apache service

Create a testdb.php file in the Web root directory with the following contents:

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

$link=mysql_connect('localhost ',' root ',' 123456 ');

If (! $link) echo failed;

Otherwise the echo is successful;

MySQL _ close();

& gt

Open http://localhost/testdb.php with a browser, and it will be OK if the output is successful.

Installation configuration of phpmyadmin

Unzip phpmyadmin-v2.6.2-pl1.zip to the WEB root directory and rename the folder to phpmyadmin or other.

Open config.inc.php in the phpmyadmin directory.

find

$ CFG[' Servers '][$ I][' user ']= ' root ';

$ CFG[' Servers '][$ I][' password ']= ' 123456 ';

Fill in the user name and password respectively.