Jan 4, 2010

Basic installation: Apache 2.2x, PHP 5.3.x and MySQL 5.x on Windows XP

The Apache 2.2.x, PHP 5.3.x and MySQL 5.x installation described here is only for development purpose. The word "Basic" means that we just make the environment work, not full function.

MySQL 5.x (without installer)

  1. Go http://dev.mysql.com/downloads/mysql/, download the zip archive and extract it, and make MySQL's root directory as D:mysql.
  2. Create an option file C:Windowsmy.ini. Define 2 parameters basedir and datadir inside [mysqld] section as follows
    [mysqld]
    basedir=D:/mysql
    datadir=D:/mysql/data 
    
  3. Change into MySQL binary directory, D:mysqlbin, install MySQL as Windows service
    D:mysqlbin>mysqld --install-manual 
    Service successfully installed.
    
    Rather than MySQL automatically startup on boot, i wanna start it manually, so '--install-manual' option is used.
  4. To start MySQL, type
    D:>net start mysql 
    The MySQL service is starting.
    The MySQL service was started successfully.
    
    To stop MySQL, type
    D:>net stop mysql 
    The MySQL service is stopping.
    The MySQL service was stopped successfully.
    
    If my.ini is with wrong content or wrong location, the following error will probably happen during MySQL startup
    D:>net start mysql 
    The MySQL service is starting.
    The MySQL service could not be started.
    A system error has occurred.
    System error 1607 has occurred.
    The process terminated unexpectedly.
    

PHP 5.3.x

  1. Go http://www.php.net/downloads.php, download the latest zip package (PHP 5.3.x VC6 x86 Thread Safe is recommended), and extract to D:\php.
  2. Add PHP directory, or D:php to the environment variable PATH.
  3. In PHP directory, make a copy of php-ini-recommended and rename it as php.ini, modify as follows
    • Specify extension directory
      ...
      extension_dir = "D:phpext"
      ...
      
    • Create PHP include folder D:phpincludes, and specify the location
      ...
      include_path = ".;D:\phpincludes"
      ...
      
    • Remove the preceding comment sign ";" to activate mysql extension.
      ...
      ;extension=php_msql.dll
      extension=php_mysql.dll
      ;extension=php_oci8.dll
      ...
      

Apache 2.2.x

  1. Go http://httpd.apache.org/download.cgi, download the latest Win32 Binary package, and double click it to install. For development purpose, Network Domain, Server Name is not important, arbitrary enter them. Then select 'Typical' install, and follow the instruction to finish.
  2. To manually start/stop Apache, go services (Start | Run | type services.msc and press Ok button) and change apache2's startup type from auto to manual.
  3. To start Apache, type
    D:>net start apache2.2 
    The Apache2 service is starting.
    The Apache2 service was started successfully.
    
    To stop Apache, type

    D:>net stop apache2.22 
    The Apache2 service is stopping.
    The Apache2 service was stopped successfully.
    
  4. Edit Apache config file, C:Program FilesApache GroupApache2confhttpd.conf as follows

    • Load PHP5 module and specify php.ini location
      ...
      #LoadModule ssl_module modules/mod_ssl.so
      LoadModule php5_module "D:/php/php5apache2_2.dll"
      AddType application/x-httpd-php .php
      PHPIniDir "D:/php" 
      ...
      
    • Create a folder D:/www, specify DocumentRoot to this folder
      ...
      #DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
      DocumentRoot "D:/www" 
      ...
      #<Directory "C:/Program Files/Apache Group/Apache2/htdocs">
      <Directory "D:/www"> 
      ...
      </Directory>
      ...
      
    • Add default page index.php
      DirectoryIndex index.html index.html.var index.php 
      
  5. Restart Apache after config file editing.

No comments:

Post a Comment