PHP environment configuration php5 mysql5 apache2 phpmyadmin installation and configuration _php tips

Source: Internet
Author: User
Tags install php mysql in php and mysql php code phpinfo blank page mysql command line phpmyadmin
The configuration of the PHP environment, for beginners, is absolutely annoying. Always encounter such a problem, go a lot of detours.
So today I specifically wrote this configuration document, I believe that the following steps you will be successful. The wrong place also wants each
A correct position.
More articles PHP enthusiasts station http://www.phpfans.net

This example is installed and configured under Wiondws apache2.0.55 php5.1.1 (Zip) mysql5.0.19 phpmyadmin2.7.0
The above resources can be downloaded from the site http://www.phpfans.net/download.php/download

/*
Author: I am not a fish
URL: http://www.phpfans.net
Blog: HTTP://WWW.PHPFANS.NET/SPACE/INDEX.PHP/2
Email:deng5765@163.com
*/

the installation of Apache
1-click APAHCE installation Package
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

2 below 3 items casually fill
Apache listens on port 80. If IIS uses port 80, modify the IIS port or Apache port to avoid conflict
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

3 Here the default is typical. If you want to modify the installation path, you can also choose Custom, note that the installation path can not contain Chinese
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

4 Start Installation
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

5 After the installation is complete, enter http://localhost in the browser.
If you can see this page, prove that the Apache installation is successful, you can explain the static page
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

installation of MySQL

1-click MySQL installation package
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

2 The default is typical, if you want to modify the installation path can also choose Custom.
Note: Install MySQL in the path, can not contain Chinese!
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

3 Installation Start
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

4 Skip Registration
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

5 Do you want to configure MySQL now? Can also be configured later in the Configuration Wizard of the Start menu
Here is the configuration now
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

6 Select Detailed Configuration, click Next to continue
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

7 The option below is to choose what type of MySQL is applied to, the first is the development server,
will only use as little memory as possible, the second is a normal Web server, will use a medium amount of memory,
The last one is that this server only runs the MySQL database, will occupy all the memory.
Users can choose the options according to their own needs. Only the development server is selected here, click Next to continue
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

8 The following is the choice of database uses, the first is multi-purpose use,
The database is optimized to be a good InnoDB (transaction) storage type and an efficient MyISAM (non transactional) storage type.
The second is for transaction type only, the best optimization innodb, but also support MyISAM, only MyISAM support Full-text indexing
The last is a non transactional type, suitable for simple applications, and only myisam types that do not support transactions are supported.
Generally choose the first multi-functional.
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

9 Below is the choice of INNODDB data storage location, generally default well, do not need to change
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

10 The following is the choice of MySQL allowed maximum number of connections, the first is the maximum number of 20 connections concurrency,
The second is the maximum of 500 concurrent connections, the last is a custom, you can choose according to your own needs.
Here Select the first
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

11 The following is the selection of the database listening port, the general default is 3306, if you change to another port,
When you connect to the database, you must remember the modified port, otherwise you can not connect the MySQL database,
More trouble, here do not make changes, with mysq default port: 3306
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

12 This step to set MySQL default encoding, default is Latin1, is also the standard encoding
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

13 Of course we can change it to gb2312 or GBK as needed. The encoding is introduced in version 4.1.
If you want to use the original database data, it is best to determine what the original database is encoded, if the code set here
and the original database data encoding inconsistent, in the use of the time may appear garbled. Latin1 Standard encoding is recommended
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

14 This step is whether to set MySQL as Windows Services, the general choice to set up a service,
This allows you to start and close the MySQL database from within the service. Recommendation: The following check box is also checked,
In this way, in cmd mode, you do not have to go to the MySQL bin directory to execute the command. Consult at the command line to execute the file
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

15 This step is to set MySQL's superuser password, this super user is very important,
With all the permissions on MySQL, set and keep in mind the superuser password,
Here's a check box to choose whether to allow the remote machine to connect to your MySQL server with the root user,
If there is such a demand, please tick.
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

16 Click Execute
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

17 to this step
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

18 We can start using MySQL, open the Start menu of MySQL Command line Client, enter the password
This interface appears to indicate that MySQL is installed.
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

problems that may arise:
If in step 15th, the interface you appear in is like this
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>
There are three places to enter the password, it is possible that you installed on the original basis.
You enter the original root password in the first text box, and the following two text boxes enter the new password for root.
Click Next to base and show the following image
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>
Recommend several solutions to you:
1, point Retry, try again;
2, run again settings, see the "Remove the original settings" option, select Remove, and then reset.
3. Re-install.
Reload Note: It is best to delete all the original files, if necessary, you can clear the registry,
If you don't have other MySQL-related programs on your machine. And you must remember not to keep the original My.ini file.
Also, delete the file under the original installation path and delete the Ibdata1 file under the data directory.
More articles PHP enthusiasts station http://www.phpfans.net

installation of PHP

Because PHP is a zip file (not install version), the installation is simpler
Unzip it. Rename the extracted php5.1.1-win32 to PHP5. and copy it to the C disk directory. That is, the installation path is C:\PHP5

1 Locate the Php.ini-dist or php.ini.recommended file in the PHP directory and rename it to PHP.ini
and copy it to the Windows directory of the system disk (for example, C:\Windows).

2 then copy the Php5ts.dll,libmysql.dll in the PHP directory to the directory C:\Windows\System32.
If you do not copy Libmysql.dll to System32, you may receive the following warning when you restart Apache
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

3 Copy the Php_gd2.dll,php_mysql.dll,php_mbstring.dll file under the Php5\ext directory to C:\Windows\System32
If you do not load Php_gd2.dll PHP will not be able to process the image. Not loaded Php_mysql.dll PHP will not support MySQL function library
Php_mbstring.dll supports wide characters when using phpMyAdmin later

We'll configure everything after the installation is complete.

Configure PHP and associate MySQL
The following thread replies to see
==============================

Open C:\windows\php.ini File

1 Setting the extension path
Find Extension_dir there's a line
Extension_dir = "./"
Change this row to
Extension_dir = "C:\php5\ext"
Where C:\PHP5 is your path to installing PHP. Incorrect path will fail to load DLL
(Note: some PHP versions are; extension_dir = "./" To remove the preceding semicolon)

2 Find Extension
Extension=php_mbstring.dll
Extension=php_gd2.dll
Extension=php_mysql.dl
Remove the semicolon before the top 3 items so that the Apache can load these DLLs when it starts
Of course, we've also copied these DLLs into the System32 before L

3 Set Session Save path
Find Session.save_path there's a line
; Session.save_path = "N;/path"
After this row, add a line (Note that you are joining a line, not adding to the back)
Session.save_path = "C:\WINDOWS\Temp"
Save to your temp directory, this can be saved to the Windows Temp directory under Temp

4 and it's worth noting that Short_open_tag is off by default.
In other words, PHP can not use short tags such as?> must use <?php?>
Because the short mark is easy to use, and many programs also use a short mark to write, such as Discuz
If you do not change the Short_open_tag to on will appear the symptom will be difficult to judge is the above reason, here proposes modifies
Find
Short_open_tag = Off
To
Short_open_tag = On

5 whether to display errors Display_errors
For security reasons, Display_errors also defaults to OFF
This means that when debugging, if the PHP code is wrong, only a blank page appears. The reason for the error and the number of rows are not displayed.
This will be very inconvenient to debug, the proposal according to their own needs to modify
Find
Display_errors = off (note not;-display_errors = off [security])
Change into
Display_errors = On

6 register_globals
It defaults to off for security reasons
When Register_globals=off, the next program should be received with $_post[' user_name ' and $_post[' User_pass ')
When Register_globals=on, the next program can accept values directly using $user_name and $user_pass.
For more detailed instructions please refer to
Http://www.phpfans.net/bbs/archiver/?tid-234.htm
Recommend to modify according to your own needs

7 PHP5 jet lag problem
<?php echo Date ("y-m-d h:i:s");? > Time difference eight hours
Why, then? The PHP5 series has new time zone settings, the default is GMT, and China's East 8 area is exactly 8 hours
Find Date.timezone there's a line
;d Ate.timezone =
Remove, change
Date.timezone = PRC
of which Prc:people ' s Republic of China,
For more detailed solutions please refer to this forum's
Http://www.phpfans.net/bbs/archiver/?tid-60.html
More articles PHP enthusiasts station http://www.phpfans.net

Apache Consolidated PHP

1 Open the Apache configuration document from the Start menu, as shown in
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

2 Modifying the site root directory
Find DocumentRoot there's a line
DocumentRoot "C:/Program Files/apache group/apache2/htdos"
This is the root of your site, you can modify it, or you can use the default. If you change, you have to modify the following, or you may have 403 errors
Find this should is changed to whatever your set DocumentRoot to
There are two lines under it
<directory "C:/Program files/apache Group/apache2/htdocs" >
Change the top two C:/Program Files/apache group/apache2/htdos to the directory you want.

3 Find DirectoryIndex index.html Index.html.var
Modified into
DirectoryIndex index.html Index.html.var index.php
So index.php can act as the default page.

4 Modular installation of PHP in Apache
Find # LoadModule Foo_module modules/mod_foo.so
Join a row after this row
LoadModule Php5_module C:/php5/php5apache2.dll

Where C:/php5/php5apache2.dll is the appropriate path for you to install PHP.
Be careful not to confuse Php5apache2.dll with Php5apache.dll. Php5apache.dll only applies to Apache version 1.
Note:The Php5apache2.dll in the PHP5 compression package only applies to the apache2.0.* version, and if the above version is 2.2.*, there may be
"Cannot load C:/php/php5apache2.dll into server:the specified module could not is found."
Or:
"The requested operation has failed"
. The solution to this problem can be referred to in this forum
Http://www.phpfans.net/bbs/viewt ... &extra=page%3d1

5 Find AddType application/x-gzip. gz. tgz
Join a row after this row
AddType application/x-httpd-php. php
So Apache can explain PHP files.
The configuration is basically done here.

########Restart Apache#########

Create a phpinfo.php file under the site root

<?php
Phpinfo ();
?>

Open in Browser
http://localhost/phpinfo.php
If the following information appears, PHP is already configured
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

Next Test the PHP and MySQL database association
Create a test.php file under the site root
CODE:
[Copy to clipboard]
<?php
$link=mysql_connect("localhost","root","12345");  //12345改成你的mysql密码
if(!$link) echo "失败!";
else echo "成功!";
mysql_close();
?> 
Open http://localhost/test.php in Browser
If the output succeeds, it is done.

Install phpMyAdmin

Download get phpmyadmin-2.7.0.zip, unzip it to your site root directory and rename it to phpMyAdmin,
Find and open config.defaut.php (some versions are config.inc.php or libraries/config.default.php)
Make the following modifications:

1 Find password like the next two lines
$cfg [' Servers '] [$i] [' user '] = ' root ';
$cfg [' Servers '] [$i] [' password '] = ';

Fill in your MySQL password to $cfg[' Servers ' [$i] [' password '] = '; Single quotes Inside

2 Search $cfg [' Pmaabsoluteuri '], set it to phpMyAdmin directory path, such as: http://localhost/phpMyAdmin/;

The following two items are modified according to the encoding you want (if the database encoding is not very familiar to the recommendations do not modify)
3 Search $cfg [' Defaultlang '], set it to zh-gb2312;
4 Search $cfg [' Defaultcharset '], set it to gb2312;

Open the browser, enter: Http://localhost/phpMyAdmin/,Apache and MySQL have been started,
If the following page appears, the phpMyAdmin installation is complete and you can use the
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>

phpMyAdmin the specific function, please slowly familiar, here no longer repeat.

==============================
More articles PHP enthusiasts station http://www.phpfans.net

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.