[Tested very well! 】Apache+PHP+MySQL environment setup

source: http://www.cnblogs.com/Yogurshine/archive/2013/05/24/3097343.html

[Frank Note: PHP and Apache have been built before, the main purpose of this article is to link Apache and mysql]

 

One: Install Apache [Frank's Note: I decompressed and deployed the downloaded compressed package, not the installation package for the next step]

1 Download the installation package: http://mirrors.ibiblio.org/apache/httpd/binaries/win32/ This one    I used httpd-2.2.22-win32-x86-openssl-0.9.8t.msi

Or: http://mirror.cc.columbia.edu/pub/software/apache/httpd/binaries/win32/

In fact, there are different mirror points. There are all mirror points here, and you should be able to download them. http://www.apache.org/dyn/closer.cgi

2 Unzip and install, just pay attention to one place

I installed it in the C:\Program Files\Apache Software Foundation\Apache2.2 directory

Test: Enter in the browser: http://localhost/

Show It Works!

After Apache is installed, the operating system is managed in a serviced manner

2 Configuration.

The default site is placed in the C:\Program Files\Apache Software Foundation\Apache2.2\htdocs directory. Generally, it will be set to the directory where you specify the php site.

---Set the virtual directory: open C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

Add at the end

Comment out the meta default directory.

Test  http://localhost/myweb/ to   display the contents of hello.html in the folder. In fact, you can directly http://localhost/ .

---Virtual host configuration
In reality, it is impossible for us to visit a website like http://localhost/news.html, usually  http://www.sohu.com   http://www.taobao.com Website, that is, access by domain name.
(1) First enable this sentence in httpd.conf

(2)打开C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf

Add at the end:


#Configure our own virtual host <VirtualHost 127.0.0.1:80>
 DocumentRoot "C:/lei/PHP"  #Configure
 welcome page
DirectoryIndex hello.html index.html index.htm index.php
 <Directory C:/lei/PHP>    #Access
 permission settings
Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny 
     Allow from all 
    </Directory>
</VirtualHost>

(3) Modify the local hosts file

Add 127.0.0.1   www.lei.com

(4) Test: http://www.lei.com    does not write the port and the default is 80

Note that you must register the domain name in the DNS system if you want to be accessed from the external network.

---How to bind multiple domain names to one IP (virtual host)

Method 1: Realize host sharing through different ports

First develop your own website d:/myblog

Configure httpd.conf file, enable virtual host
Configure httpd-vhosts.conf

Add in hosts: 127.0.0.1   www.lei.com
                   127.0.0.1   www.guang.com

You must also add a listening port in the httpd.conf file:

#Listen 12.34.56.78:80
Listen 80
Listen 8011

Test: http://www.lei.com/
http://www.guang.com:8011/

Method 2: Distinguish different domain names by ServerName

Configure httpd-vhosts.conf:

Add 127.0.0.1 www.leilei.com
                127.0.0.1   www.guangguang.com to hosts  

Note that you cannot use both methods, otherwise the test will seem to make mistakes. [Frank's note: a large section above can be seen in the mist]

Two install PHP

1 Download the php core package (note that it is not an installation program, it is the core package, just unzip and put it in a suitable location): http://windows.php.net/downloads/releases/

Because the server uses apache, it needs to use the VC6 version (if it is an IIS server, use VC9), but the official website can't find the new version. I downloaded php-5.3.5-Win32-VC9-x86.zip from Baidu (thread-safe version ts)

2 Unzip to the specified folder: C:\Program Files\Apache Software Foundation\php-5.3.5

3 Integrate Apache and PHP

--Add three sentences in apache http.conf.

--Change the php.ini-development file to php.ini

Configure php.ini

Write the test file test.php:

<?php
 phpinfo();
?>

Test: successful

Three install MySQL [frank: the point is coming]

1 Download the installation package: It seems that the official website download now requires an oracle account to be downloaded for free. Baidu directly downloaded mysql-5.5.28-win32.zip

2 Detailed configuration after installation, a few points of attention

Set the root user password, and finally tick all four.

3 Configuration [frank: In fact, the most critical step is this step. As long as this step is done, linking Apache and MySQL is basically done! Note that php_mysql.dll has been abandoned in the latest version of php, because it is not safe, now php_mysqli.dll is fully adopted, just delete the semicolon before extension=php_mysqli.dll. There is an extension=php_pdo_mysql.dll below. It is recommended to remove the semicolon in front of it. It will be used in the future. Now it is basically object-oriented. In short, php connects to mysql is the only step. ] [Frank added a small detail, extension_dir = "D:/wamp/bin/php/php5.5.12/ext/", this ext must be followed by a slash, I think some take it, and some don’t. I can’t tell why, anyway, I didn’t bring it at first, but later I brought it and connected it]

--Enable mysql function in php.ini

4 Test program testmysql.php:

<?php
 $conn=mysql_connect("localhost","root","900219");
 if($conn){   echo "Connect to mysql database ok";  }else {   echo "Failed to connect to mysql database";  } ?>[ frank: Note here, because we are a new version of php, there is no mysql_connect, so we need to add i after l to become $conn=mysqli_connect, the rest remain unchanged, the test will succeed]




5 Test: http://localhost /testmysql.php

Four install a phpmyadmin (the site can actually manage mysql better) [frank: do not pay attention to the following content]

1 Download the installation package phpMyAdmin-4.0.1-all-languages.zip

2 Unzip and place it in the virtual directory specified above, in the browser http://localhost/phpmyadmin/index.php

Can be used directly, just enter the username and password to enter

Management interface:

Fifth, if you are interested, you can download an open source discuz and run it on the PHP environment we built. Not written here,

six. php running process sequence diagram

So far ok

Guess you like

Origin blog.csdn.net/zy17822307856/article/details/112598542