Installing Apache 2, MySQL 5.1, and PHP 5.2 from Source in Ubuntu 9.04 (Jaunty)
filed in In Moving to Linux, Learning by Playing, Ubuntu, Web Development on Oct.11, 2009
Here we go. I made this post based on my experience installing Apache 2, MySQL 5.1, and PHP 5.2 from apt-get and always get error when installing MySQL 5.1. Then I must install them from sources.
Before we begin, make sure you already download source of Apache 2, MySQL 5.1, and PHP 5.2.
Download Apache HTTP Server
Download MySQL Server
Download PHP
After the download completed, lets install them…
Assume this installation guide using :
Apache HTTP Server version 2.2.13
MySQL Server version 5.1.39
PHP version 5.2.11If you get different version, just replace it’s version number
![]()
This code is ready to use, you can just paste it into your terminal/console.
Install Mysql 5.1
Open terminal, and change the directory to the download folder.
Do the following command :
#!/bin/bash ###login as root : sudo su ###extract it : tar -zxvf mysql-5.1.39.tar.gz ###change to the mysql extraction directory : cd mysql-5.1.39 ###adding mysql group : groupadd mysql ###adding mysql user : useradd mysql -g mysql ###create a directory for mysql pid file : mkdir /var/run/mysqld ###change its owner to mysql : chown -R mysql.mysql /var/run/mysqld ###create a directory for mysql data : mkdir /var/mysqldata ###change its owner to mysql : chown -R mysql.mysql /var/mysqldata ###configuring mysql : ./configure --prefix=/usr/local/ --localstatedir=/var/mysqldata --with-mysqld-user=mysql --with-unix-socket-path=/var/run/mysqld/mysqld.sock --with-plugins=innobase --without-docs --without-man ###make it : make ###install it : make install ###copying mysql.server file to /etc/init.d/mysql in order to automatically starting mysql-server each computer start : cp support-files/mysql.server /etc/init.d/mysql #make it executable chmod +x /etc/init.d/mysql #make it automatic start update-rc.d mysql defaults ###starting mysql server manually : /etc/init.d/mysql start ###install default mysql database : mysql_install_db
Install Apache 2
Open terminal, and change the directory to the download folder.
Do the following command :
#!/bin/bash ###login as root : sudo su ###extract it : tar -zxvf httpd-2.2.13.tar.gz ###change to the apache extraction directory : cd httpd-2.2.13 ###configure it : ./configure --enable-so --enable-mime-magic --enable-rewrite --with-mpm=prefork ###make it : make ###install it : make install ###copying apachectl file to /etc/init.d/httpd in order to automatically starting Apache HTTP Server each computer start : cp support/apachectl /etc/init.d/httpd #make it executable chmod +x /etc/init.d/httpd #make it automatic start update-rc.d httpd defaults
Install PHP 5.2
Open terminal, and change the directory to the download folder.
Do the following command :
#!/bin/bash ###login as root : sudo su ###extract it : tar -zxvf php-5.2.11.tar.gz ###change to the PHP extraction directory : cd php-5.2.11 ###configure it : ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-gd --enable-gd-native-ttf --enable-json --enable-zip --enable-mbstring --with-mcrypt --disable-ipv6 --enable-calendar --with-config-file-path=/usr/local/etc --enable-exif --enable-magic-quotes --with-zlib --with-iconv --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-bz2 ###make it : make ###install it : make install
Finally, start Apache HTTP Server manually :
/etc/init.d/httpd start
Now, you can test your installation by typing
http://localhost/
in your favorite browser. If it displays It works!, it must be success!
Not : Place your PHP or HTML files to
/usr/local/apache2/htdocs
If you get your installation failure, don’t be hesitate to ask here.
Related posts:





November 4th, 2009 on 1:32 pm
thanks banget infonya…..