Configure Apache, MySQL, and PHP manually in Windows

Source: Internet
Author: User
Tags mysql gui mysql gui tools
Lamp (short for Linux, Apache, MySQL, PHP/perl/Python) is now popular. It is also similar in windows, such as Wamp (Apache, MySQL, PHP on Windows ). This article describes how to manually configure Apache, MySQL, and PHP in a Windows environment. All of them are decompressed and directly modify the configuration file. Of course, you can also download the version of the Installation File for automatic installation. You can even download a collection of these software versions (wampserver, XAMPP) for one-step installation. Here, we will extract and install the software, which seems to be a bit redundant. However, this will allow us to understand the installation process of these software and detect problems in time, so that we can quickly configure a software when it is updated. 1. Software DownloadApache HTTP Server 2.2.6 (for Windows)

MySQL mysql-noinstall-5.0.45-win32.zip mysqlguitools (MySQL administrator, MySQL querybrowser and MySQL migrationtoolkit) (mainly to use MySQL administrator to start and close MySQL)
PHP php-5.2.5-Win32.zip phpMyAdmin 2.11.2.2Ii. install Apache HTTP ServerThe downloaded file is an MSI file. You can directly double-click it to install the interface. You need to enter some data to complete the installation. This method is not used here, but it is recommended to install it like this. Next we will talk about another method for installation, unzip the MSI file, and modify the configuration file. 1. Run the msiexec/A apache_2.2.6-win32-x86-no_ssl.msi, then select "Install", and finally "finish" to unzip the installation file. /A indicates that you can specify the decompression path for network installation. For example, if you decompress the package on the F disk, a folder such as F:/program files/Apache Software Foundation/apache2.2 is generated, and F: /system32/redist/MS/system/msvcrt. DLL. 2. Move the apache2.2 folder to the appropriate directory. Of course, the folder can be left empty. Here, I put it in the D:/Java directory and rename it Apache folder. As for the msvcrt. dll file, it seems that it is not required in XP, but it is useless and deleted. 3. Now configure Apache. Move all the files in CONF/default in the D:/Java/Apache directory to the conf directory. 4. Create a logs folder in Apache. 5. Change the httpd-win.conf file in the conf directory to httpd. conf, and modify the parameters in httpd. conf as follows:

  • Line 3: serverroot "D:/Java/Apache", specifying the Apache directory
  • Port on which the listen 80 and httpd listeners are located.
  • Row 133rd, serveradmin javamxj@gmail.com, contact the site's email address. (It can be left unchanged)
  • Row 142nd, servername 127.0.0.1: 80, host name. If there is no host name or the domain name is not registered, it is written as 127.0.0.1.
  • Line 3: DocumentRoot "htdocs", pointing to the "D:/Java/Apache/htdocs" directory. Configure the most critical line and set the location of the webpage file, that is, the publishing directory of the webpage.
  • Lines 177th to 205 and <directory "htdocs"> are all permission settings for the website directory configured above.
  • Line 2: directoryindex index.html. What is the default homepage when a website directory is opened (not modified ).
6. Add Apache as a Windows service in the Command Prompt window, switch to the D:/Java/Apache/bin directory, and enter: Httpd-K install, If successful Management tools> servicesSee Apache2.2Service. If you do not want to start the service, run it. Startup TypeBy AutomaticChange Manual. To remove the apache service: Httpd-K uninstall7. Start and Stop Apache httpd startup Httpd-K start, Stop Httpd-K stopOr Httpd-K shutdown, Restart Httpd-K restart. Or start Net start apache2.2, Stop Net stop apache2.2It is best to set the Directory D:/Java/Apache/bin Apachemonitor.exeCreate a shortcut on the desktop and run it directly to start and stop Apache httpd. 8. Start Apache and enter http: // localhost/in the browser. The it works page is displayed! Okay, it's successful. Note: This is the default listening port 80. If other software is listening to port 80, it will conflict. You can refer to Step 5 to modify the default listening port, for example, to 8080, then, enter http: // localhost: 8080 in the browser. 3. Install PhP5:1. decompress php-5.2.5-win32.zip to the d:/Java/PHP Directory, enter the D:/Java/PHP Directory, and find PHP. ini-Dist file, renamed as PHP. INI, it is best to copy and rename again. 2. edit httpd of Apache. CONF file (in the conf subdirectory under the Apache installation directory), add the following section at the end, and save. # ***************** PHP configuration *****************  # Load PHP 5:
Loadmodule php5_module "D:/Java/PHP/php5apache2_2.dll"
Addtype application/X-httpd-PHP. php
 
# Configure the php. ini path
Phpinidir "D:/Java/PHP"
3. Create a new info. php file with the following content and put it in the htdocs folder under Apache. <? PHP
Phpinfo ();
?>
4. Start Apache and enter http: // localhost/info. php In the browser. If the page appears, it will succeed. Note:
  • The installation directory of PHP should not use a path with spaces in the middle (for example, C:/program files/PHP is not good). If you do this, some Web servers will crash.
  • Httpd. conf cannot load php5apache2. dll. It must be writtenPhp5apache2_2.dll
4. Install MySQL1. Decompress mysql5 to D:/Java directory, there should be a mysql-5.0.45-win32 folder, for convenience, I rename this folder to MySQL, under this directory, create a new my. ini file. The content is as follows: [Winmysqladmin]
Server = D:/Java/MySQL/bin/mysqld-nt.exe

[Mysqld]
Basedir = D:/Java/MySQL
Datadir = D:/Java/MySQL/Data
The above "server" points to the MySQL execution main program, "basedir" points to the MySQL installation directory, and "datadir" points to the MySQL data storage directory. If your installation directory is not described above, change to your own. 2. Install MySQL to switch the system service to the bin directory under the MySQL installation directory. Enter the following command:
D:/Java/MySQL/bin/ Mysqld-NT -- install MySQL -- defaults-file = D:/Java/MySQL/My. iniMySQL is the service name and is installed as a system service. For example, after the installation is successful, you can run the Net start mysqlcommand in DOS to change it to mysqld-nt.exe-install mysql5, the command should be net start mysql5. In addition, you also need to load the my. ini file when installing the system service. Uninstall Service Mysqld-NT -- remove MySQL3. Start MySQL
The command is in the DOS prompt, or start -- run
   Net start MySQL
   Net stop MySQLIt is easier to use mysqlsystemtraymonitor.exe In the MySQL GUI tools 5.0directory. 4. Modify the root initial password (change the password to javamxj ): Mysqladmin-u root-P password javamxjPrompt: Enter Password:. Because the initial password of root is empty, press Enter. if the password to be modified is not empty, enter password: Enter the old password when prompted. note: javamxj is the new password. You can set it as needed, but remember the password. 5. Check that MySQL has been started. Switch to the bin directory under the MySQL installation directory and enter the following command: D:/Java/MySQL/bin/ Mysql-uroot-pjavamxjThe above root is the user name, And javamxj is the new password just modified. If the welcome message is displayed, OK. 5. Use MySql in PhP51. Open the php. ini file and modify extension_dir in row 486:
Extension_dir = "D:/Java/PHP/EXT"
Delete the" ;"To load php_mysql.dll and php_mysqli.dll
  Extension = php_mysql.dll Extension = php_mysqli.dll2. In PathAdd Environment Variables D:/Java/PHP;In order to load the DLL files in this directory (it may need to be restarted to take effect), or copy these files to the Windows system32 directory. If there is no problem, you can see the mysqli and MySQL modules in http: // localhost/info. php. 6. EncodingIn order to solve the garbled problem once and for all, it is recommended that all kinds of encoding are set as UTF-8. 1. First modify the my. ini file as follows: [winmysqladmin]
Server = D:/Java/MySQL/bin/mysqld-nt.exe

[Mysqld]
Basedir = D:/Java/MySQL
Datadir = D:/Java/MySQL/Data

Default-character-set = utf8
Character_set_server = utf8
Init_connect = 'set names utf8'
  [Client]
Default-character-set = utf8
2. The php file also uses UTF-8 encoding, and in the PHP File Header for database operations, add the following statement: Header ("Content-Type: text/html; charset = UTF-8 ");In this way, Chinese characters can be properly displayed. 7. Install phpMyAdmin1. In the PHP environment, it is very convenient to use phpMyAdmin to operate MySQL. Select a multi-language zip version from the above download link. First, extract the downloaded phpMyAdmin file to a phpMyAdmin directory (you can change the name), and then move the directory to a virtual directory of Apache, for example, under the Apache/htdocs directory. Start Apache and enter http: // localhost/PHPmyAdmin/index. php in the browser. 2. You also need to modify the configuration file and set the login mode. In the phpMyAdmin directory, there is a file "config. sample. Inc. php". Copy and rename it config. Inc. php. You need to modify the 29th rows: $ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker ';'Auth _ type '? Set the login method. There are three options: HTTP, cookie, and config. The HTTP method is used to authenticate the user name and password input box when accessing the client. The cookie method is to allow the user name and password to be entered for authentication through page access; the config method is to directly obtain the username and password from the configuration file and connect to the database. 3. If you use HTTP, you only need to replace the above "cookie" with "HTTP. 4. If the cookie method is used, you need to modify the 17th rows $ Cfg ['blowfish _ secret'] =''You can enter any data in single quotes to encrypt the user name and password stored in the cookie. When I use IE to browse, an error occurs, as shown below. In the language column, select "Chinese-Chinese Simplified (UTF-8. This problem does not occur when you use Firefox for browsing. 5. if you need to modify rows 37th and 38 in config mode, remove the previous "//" and fill in the correct username and password, as shown below: $ cfg ['servers'] [$ I] ['controluser'] = 'root ';
$ Cfg ['servers'] [$ I] ['controlpass'] = 'javamxj '; however, I have not succeeded in this method and a database connection error is prompted. Among them, the config method has the lowest security level and the cookie method has the highest level. However, Cookies cannot be disabled. HTTP is often used in free homepage space. Summary 1. When you modify the parameters, the corresponding installation directory must be decompressed. 2. After Apche and MySQL are added as system services, the Startup type is automatic, that is, the startup. If you do not want this, you can start it manually. 3. The default port of Apache is 80. If there are other servers installed, such as IIS, which may conflict with each other, you can set it to another port. When browsing the page, add a port to the website. 4. The above software is downloaded from the official website. If the speed is slow, you can select another image site from the official website.

 

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.