Installing Apache, PHP and MySQL
This tutorial was written by my friend, Josh, not me. He's kindly donated it to Geekery. He's swell. It's for machines running Linux. So, you Windows people can go find something else to do. To get started, open up a terminal window and su to root.

FOLLOW THESE STEPS IN ORDER - MAKE SURE YOU ARE ROOT!

  1. Download source distrobutions of the following to /usr/local/src/. :
  2. Unzip and untar MySQL : tar -zxvf mysql-dist.tar.gz
  3. Create /data/mysql and /usr/local/apache:
    1. mkdir /data
    2. mkdir /data/mysql
    3. mkdir /usr/local/apache

    NOTE: This assumes that you have the user mysql configured on your system
  4. 3) Change to MySQL dir: cd mysql-dist
  5. Run the configure script with the following options :
    • ./configure --prefix=/usr/local/mysql --localstatedir=/data/mysql
      NOTE: If you see ERROR: No curses/termcap library found find where libncurses.so.5 is installed on your system and add the following flag to your configure statement :
      --with-named-curses-libs=/usr/path/to/libncurses.so.5
  6. Make it : make
  7. Install it : make install
  8. Set up the DB : scripts/mysql_install_db
  9. Edit the /etc/rc.d/rc.local File To Auto Start MySQL: add : bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld &'
  10. Set new root password with : /usr/local/mysql/bin/mysqladmin -u root -p password 'new password'
    NOTE: When it prompts you to enter the password, just hit Enter - if you don't see an error, the password was successfully changed.
  11. Unzip and Untar Apache and PHP :
    • tar -zxvf apache-dist.tar.gz
    • tar -zxvf php-dist.tar.gz
  12. Change to the Apache directory : cd /usr/local/src/apache-dist
  13. Configure Apache for PHP: ./configure --prefix=/usr/local/apache
  14. Change to the PHP dir: cd ../php-dist
  15. Configure PHP4:./configure --with-apache=../apache-dist --with-mysql=/usr/local/mysql --enable-memory-limit=yes --enable-debug=no --enable-track-vars
  16. Make it : make
  17. Install it: make install
  18. Change back to the Apache dir : cd ../apache-dist
  19. Configure Apache with PHP : ./configure --prefix=/usr/local/apache --activate-module=src/modules/php4/libphp4.a
  20. Make it : make
  21. Install it : make install
  22. Edit the /usr/local/apache/conf/httpd.conf file :
    • Uncomment : AddType application/xhttpd-php .php
    • Add php to : DirectoryIndex index.html index.php
  23. Add the following lines to the /etc/rc.d/rc.local file to start Apache and MySQL automatically when the machine boots up: # Start MySQL Server /bin/sh -c 'cd /usr/local/mysql; ./bin/safe_mysqld &' # Start Apache /usr/local/apache/bin/httpd -f /usr/local/apache/conf/httpd.conf

INSTALLATION OF phpMyAdmin AND .htaccess

  1. Download the current version of phpMyAdmin from http://www.phpwizard.net to your pages (htdocs, www) directory : /usr/local/apache/pages
  2. Unzip and untar it: tar -zxvf phpMyAdmin-dist.tar.gz
  3. Edit the config.inc.php file to use your root name and password
  4. Copy the htpasswd script to /usr/bin : cp /usr/local/apache/bin/htpasswd /usr/bin/htpasswd
  5. Create the .htaccess file : touch .htaccess
  6. Add the following : AuthUserFile /usr/local/apache/pages/phpMyAdmin/.htpasswd AuthGroupFile /dev/null AuthName "phpMyAdmin" AuthType Basic <Limit GET POST> Require valid-user </Limit>
  7. Create the .htpasswd file :htpasswd -bc .htpasswd username password
    NOTE: Of course, you'll want to substitute your own values for username and password. They can be anything - not just system users! Use the -a flag instead of the -c flag to add users to an existing .htpasswd file.
  8. Make sure your httpd.conf file allows .htaccess file-reading. In the htaccess config section set the following : AllowOverride AuthConfig
  9. Bounce the server (to read the new httpd.conf) and you're good to go!

Questions? Comments? Send them to Josh