Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, April 17, 2007

Install Apache, MySQL, PHP, phpMyAdmin, and Tomcat on Windows

LAMP is a widely used web server infrastructure. For some reasons, I need to install latest Apache, MySQL, PHP on Windows, and integrate Tomcat with Apache. (There are reasons for integrating and not integrating them together; interested readers can read this.)

Here are some quick tips of how I made it:

Install Apache, MySQL, PHP, PHPMyAdmin

Download
· Apache 2.2.4: http://mirror.olnevhost.net/pub/apache/httpd/binaries/win32/apache_2.2.4-win32-x86-no_ssl.msi
· MySQL 5.0.37: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.37-win32.zip/from/http:/mysql.he.net/
· PHP 5.2.1: http://www.php.net/get/php-5.2.1-win32-installer.msi/from/a/mirror
· PHPMyAdmin 2.10.0.2: http://superb-west.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.10.0.2-all-languages.tar.gz

Install Apache
1. Refer to instructions on http://www.webmasterstop.com/48-1.html
2. Change the installation directory to C:\Apache
3. Test the installation by typing http://localhost/ in the URL field of your web browser, you should see “It works!” on the page.

Install MySQL
1. Refer to instructions on http://www.webmasterstop.com/48-2.html
2. Change the installation directory to C:\MySQL

Install PHP
1. Refer to instructions on http://www.webmasterstop.com/48-3.html
2. Change the installation directory to C:\PHP
3. Choose “Apache 2.2.x Module” on Web Server Setup page
4. Fill in Apache Configuration Directory with “C:\Apache\conf\”
5. Select APC, GD2, Multi-Byte String, and MySQL under Extensions on Choose Items to Install page
6. Modify Apache’s configuration file C:\Apache\conf\httpd.conf, search for <IfModule dir_module>, add index.php to DirectoryIndex item
7. Create phpinfo.php in C:\Apache\htdocs with only one line code: <?php phpinfo(); ?>, restart Apache server, type http://localhost/phpinfo.php in your web browser, you should see a php configuration page

Install PHPMyAdmin
1. Refer to instructions on http://www.webmasterstop.com/48-4.html
2. Extract the directory to C:\Apache\htdocs, rename it to phpMyAdmin
3. In C:\Apache\htdocs\phpMyAdmin, copy config.sample.inc.php to config.inc.php
4. Copy libmysql.dll (in C:\PHP) and php_mysql.dll (in C:\PHP\ext) to C:\Apache\bin
5. Type http://localhost/phpMyAdmin in your browser, you should be able to login and browse the database

Install Java and Tomcat, Integrate Tomcat with Apache

Download
· JRE & JDK 6u1: http://java.sun.com/javase/downloads/index.jsp
· Tomcat 6.0.10: http://www.reverse.net/pub/apache/tomcat/tomcat-6/v6.0.10/bin/apache-tomcat-6.0.10.exe
· JK-apache-2.2.4: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.22/mod_jk-apache-2.2.4.so

Install Java
1. Run the installation file
2. Change the installation directory to C:\Java\jdk and C:\Java\jre
3. Set JAVA_HOME to C:\Java\jre, add C:\Java\jre\bin to PATH

Install Tomcat
1. Run the installation file
2. Change the installation directory to C:\Tomcat
3. Start the service, enter http://localhost:8080/ in your browser, you should see Tomcat page

Integrate Tomcat with Apache
1. Copy mod_jk-apache-2.2.4.so to C:\Apache\modules
2. Create file workers.properties in C:\Tomcat\conf, like

workers.tomcat_home=C:\Tomcat
workers.java_home=C:\Java\jre
ps=\
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

3. Configure Apache, add index.jsp to DirectoryIndex, add the following lines to httpd.conf

LoadModule jk_module modules/mod_jk-apache-2.2.4.so
<IfModule jk_module>
JkWorkersFile "C:\\Tomcat\\conf\\workers.properties"
JkLogFile "C:\\Tomcat\\logs\\mod_jk2.log"
JkLogLevel info
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
</IfModule>

4. Open C:\Tomcat\conf\server.xml, insert the following line between <host> and </host>
<context crosscontext="true" reloadable="true" debug="0" docbase="C:\Apache\htdocs" path="">
5. Restart Apache and Tomcat
6. Access http://localhost/ and http://localhost:8080/, you should see the same page
7. Create test.php (just one line: <?php echo “Welcome to PHP World!”; ?>) and test.jsp (one line also: <% out.println(“Welcome to JSP World!”); %>) in C:\Apache\htdocs, access http://localhost/test.php and http://localhost/test.jsp, you should see different welcome messages.