Apache2+php4+mysql Configuration

Source: Internet
Author: User
Tags add install php iis connect mysql php and mysql database phpmyadmin
Apache|mysql|apache|mysql 1, install PHP: will download the PHP compressed file decompression, folder renamed to PHP copied to the C-packing directory.


2, open just unzip the PHP directory, you will find a file called "Php.ini-dist", this is the PHP configuration file, you need to rename it "PHP.ini", and then copy to the System directory winnt.

Modify PHP.ini It's important to note that
270 lines error_reporting = E_all & ~e_notice
277 Lines display_errors = On
Another: 365 line register_globals default off, change to on means open global variable, later programming convenience.
; Cgi.force_redirect = 1 changed to Cgi.force_redirect = 0 This is forced to not run in CGI mode

3, the PHP installation directory under the "Php4ts.dll" must be copied to the Windows system system32 directory

4, DLLs and extensions all the files in the catalogue to System32.




APACHE2 Installation
First stop your IIS or PWS service.
1 Run your downloaded Apache2 installation files, install Apache, installation process will prompt you to enter the host name, administrator mailbox, such as mailbox, this information after you install can be modified, so can be assured of input.
(* For future convenience, it is highly recommended that you change the installation path here to "x:" (Note x is your hard drive) or other names that conform to the 8.3 file name format, and you do not have to add quotes to the Apache installation path each time you enter it. When the system is successfully installed, a directory named "Apache2" is automatically created here, that is, the path to the actual Apache system files after installation will be the "x:apache2" directory. *)

After installation, under Apache2confhttpd.conf to find serveradmin, you can modify the administrator mailbox, (near 199 lines), 213 lines is servername I changed to localhost
Later I put the program in the Apache2 Htdocs under the subdirectory Zimulu, with http://localhost:81/zimulu/xxx.php test.

2 Editor Apache2/conf/httpd.conf

120 line Listen 80 to 81 port, because when your win2k is reset, IIS will take up 80 ports to avoid collisions, so Apache uses 81 ports.
The next 134-170 lines are the parts that load the module. In this section, add the following two sentences:
LoadModule Php4_module C:/php/sapi/php4apache2.dll
Note: If your PHP directory is not c:/php, please write it in the actual.
AddType application/x-httpd-php. php. php3. PhP4
(it is said that it can be added to the 768-line AddType Application/x-tar. tgz, but I did it once, but I didn't get it later.) Meaning: Load the PhP4 module, where the 2nd sentence if only AddType application/ x-httpd-php. PHP can only parse files for PHP extensions, and PHP3 extension programs cannot parse them.

Note: We are generally modular to run PHP, so just so, and some articles say so add:
scriptalias/php/"c:/php/"
AddType application/x-httpd-php. php
Action application/x-httpd-php "/php/php.exe"
Or
LoadModule Php4_module C:/php/sapi/php4apache2.dll
AddType application/x-httpd-php. PhP4
scriptalias/php4/"c:/php/"
Action application/x-httpd-php4 "/php4/php.exe"
AddType application/x-httpd-php4. php
PHP is actually running in a CGI way, not necessarily.


Find DirectoryIndex * This line can be modified to add the default filename:
DirectoryIndex index.php default.php index.htm index.html default.htm
Otherwise, index.php will not be recognized automatically.


Make IT Support Chinese

The best solution is to modify the conf/httpd.conf file in Apache to find Adddefaultcharset iso-8859-1
and change it into
#AddDefaultCharset iso-8859-1
Adddefaultcharset GB2312
Note the number of files that are made using Dreamweaver:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
In fact, this often leads to files in Chinese into garbled!! because: http.conf 355 lines DefaultType Text/plain instead of text/html, so manually modified to Text/plain is displayed in Chinese.

3 Start---run----cmd
C:apache2/bin>
Enter Apache-k Install
Enter Apache-k start
4 Access http://localhost:81 Display Apache Welcome page (Congratulations, Apache2 installation successful)
Write one of the simplest PHP programs
<?php
Phpinfo ();
?>
, named info.php deposit Apache2/htdocs, and then the address bar typing http://localhost:81/info.php should display the relevant information about PHP and apache2, so that you can finally start the PHP learning Trip (le).
(What you do not want to put the program under the Apache2/htdocs, then go back to httpd.conf find DocumentRoot "X:/apache/htdocs" to change the X:/apache/htdocs to your favorite directory name. )

Just PHP is not enough, a lot of larger programs are used to get the database, so we started:

installation of MySQL

As most of the information tells you, MySQL is easy to install successfully, installation is simple, but debugging difficult. MySQL after the successful installation, into the Mysql/bin double-click Winmysqladmin, the first run needs to enter a username password, such as my virtual space database username ABC, the password is XYZ, so I entered the ABC XYZ; In order to be a good local program can be directly ftp. But ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Paradise ~~~~~ Paradise, less than 5 minutes (cooked rice seems to take 10 minutes) I was: I have a program
<?php

$db _conn=mysql_connect ("localhost", "abc", "xyz") or Die ("Can ' t connect!!");

?>



In the virtual space to run well, to the local is not connected to the database!! Change the phpmyadmin2.5.4 name into p254, enter the Config.inc open, modify the 80th, 81 lines
$cfg [' Servers '] [$i] [' user '] = ' abc ';
$cfg [' Servers '] [$i] [' password '] = ' xyz ';
The $cfg[' Servers ' [$i] [' only_db '] = ' in the 83rd line, and if you type the database name Dbone, you will see only this phpMyAdmin database in Dbone, and the rest will not be visible.
The Address bar type http://localhost:81/p254 (preferably off the firewall, even if you use the Ministry of Public Security score 95 points of that) but I saw that:
phpMyAdmin tried to connect to the MySQL server, but the server refused to connect. You should check the host, username, and password in the config.inc.php and determine that this information is consistent with the information given by the administrator of the MySQL server.

And I'm going to change the contents of Confgi.inc.
$cfg [' Servers '] [$i] [' user '] = ' root ';
$cfg [' Servers '] [$i] [' password '] = ';
You can connect successfully!!

In the face of this situation, I refer to the last installation mysql3.23.55 experience, into the Winnt to find My.ini, modify the bottom 2 lines
User=abc
Password=xyz

Or not, so began to cranky, a good one to modify: PHP.ini in the project on MySQL, change, bad use; Config.inc under the $i = 1 o'clock
$cfg [' Servers '] [$i] [' User ']
$cfg [' Servers '] [$i] [' Password ']
Also changed, (in fact, it is used for multiple MySQL run when the management used, stand-alone only run a MySQL simply do not need to change). Halo ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ on a pass csdn, the defendant deleted the My.ini, after the automatic regeneration My.ini, compared to the sample to do ~ ~ ~ Double Winmysqladmin, and sure enough to enter username and password. However, the re-enter, still does not work!! So head a hot trick, rewrite config.inc with root and empty password into the phpMyAdmin, into the MySQL database user table, directly inserted as a UK15F1 username password is o1s3f2g7, the result ~ ~ ~ ~ It's still not good to use!!!. (Note: This problem has not been committed with MySQL 3.x, possibly a mysql4.x bug) The final solution is to use the command line C:mysql/bin/mysql



Related Article

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.