Approachable PHP correctly configure Mysqlapache Environment

Source: Internet
Author: User
Wrote a test for MySQL PHP file as follows:

Copy the Code code as follows:


$link =mysql_connect (' localhost ', ' root ', ' root ');
if (! $link) echo "Failed!";
else echo "Success!";
Mysql_close ();
?>


Results reported error: Fatal error:call to undefined function mysql_connect (), obviously can not find MySQL corresponding library, Baidu a lot of, is what copy MySQL Lib library, Again to the system32 directory copied to Windows, too complex, in fact, the correct configuration should be in the Apache httpd.conf file to add the following settings:

Copy the Code code as follows:


LoadModule Php5_module D:/tools/php-5.3.1/php5apache2_2.dll
AddType application/x-httpd-php. php
Phpinidir d:/tools/php-5.3.1


Note that the last line is the key, tell Apache where your PHP configuration file is, or you'll have to copy the php.ini file to the Windows system directory. In general, we can use this configuration to complete the combination of Apache and PHP. In the php.ini file, you only need to modify the following areas:
# Modify the PHP extension Library directory for your actual path
Extension_dir = "D:/tools/php-5.3.1/ext"
# Remove the front;
Extension=php_mysql.dll
The final step is to add your PHP installation path to the system environment variable (note that the system environment variable, not the user environment variable) path, after the setup succeeds, the phpinfo () should be available in Apache The environment section of the path can be seen in your PHP installation directory, or the environment variable is not configured successfully (note, configure the environment variable restart under Apache).
After completing these steps will be able to connect the database correctly, but the premise is that your Apache and PHP integration is normal, and then consider this MySQL configuration, if you can not reach the effect, you may question me, hehe!
To summarize, the correct configuration steps for the integration of Apache and PHP (including MySQL) under Windows platform are as follows:
1, install Apache, and ensure that Apache can operate independently
2. Extract the ZIP packet from PHP (such as 5.2.17 or 5.3.1) to a directory, such as D:\php-5.3.1
3. At the end of the Apache httpd.conf file, add the following paragraph:

Copy the Code code as follows:


# PHP5 Support
LoadModule Php5_module D:/php-5.3.1/php5apache2_2.dll
AddType application/x-httpd-php. php
Phpinidir d:/php-5.3.1


4. Add the d:/php-5.3.1 path to the path of the operating system's environment variable (which must be a system variable rather than a user variable)
5. Rename the php.ini-dist in the PHP installation directory to php.ini and modify the following:
# Set the extension file directory for PHP
Extension_dir = "D:/php-5.3.17/ext"
# Open MySQL extension, remove the previous; Comment
Extension=php_mysql.dll
After completing the 5 steps above, your PHP will be able to be properly combined with Apache, and common such as: PHP warning:php startup:unable to load Dynamic Library ..., Fatal Error:call to und efined function mysql_connect () ... Will be gone forever! ^_^

The above describes the correct configuration of approachable PHP Mysqlapache environment, including the approachable aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.