compile your own lamp stack with mysqli
Install LAMP with one line
One liner
sudo apt-get install lamp-server^ |
Add CURL and enable mod-rewrite
sudo apt-get install php5-curl sudo a2enmod rewrite |
To compile LAMP with mysqli and mysql
Assuming you have a fresh clean minimal install of ubuntu start by install gcc and wget
sudo apt-get gcc sudo apt-get wget |
Download apache and php and use filezilla or a similar SFTP client to upload them to the server (I was unable to find a direct link that didnt pass through a mirror), once uploaded move to the directory on the cmd line.
unpack apache
1 2 | gzip -d httpd-2_x_NN.tar.gz tar -xf httpd-2_x_NN.tar |
unpack PHP
1 2 | gzip -d php-NN.tar.gz tar -xf php-NN.tar |
Compile and install Apache
1 2 3 4 | cd httpd-2_x_NN ./configure --enable-so make sudo make install |
Compile PHP
1 2 | cd ../php-NN ./configure --with-aspxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/bin/mysql_config --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd |
This will fail with an error “error locating libxml2” fix this with:
sudo apt-get install libxml2 |
Next the error below will appear
xml2 config not found Please check your libxml2 installation |
Point your browser or ftp client at ftp://xmlsoft.org/libxml2/ and take note of the latest version for libxml2-2.6.28 and then grab it and install it from the server
1 2 3 4 5 6 | sudo wget ftp://xmlsoft.org/libxml2/libxml2-2.X.XX.tar.gz sudo tar -zxvf libxml2-2.X.XX.tar.gz cd libxml2-2.X.XX/ ./configure make sudo make install |
Try to compile PHP again:
1 | ./configure --with-aspxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/bin/mysql_config --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd |
next problem is Mysql
configure: error: Cannot find MySQL header files under /usr/bin/mysql_config |
To fix this, Install mysql:
sudo apt-get install mysql-server |
But now even though Mysql is found there are still no headers so first install php module for mysql:
sudo apt-get install php5-mysql |
and add the header library
sudo apt-get install libmysqlclient15-dev |
Now PHP should compile and install fine:
1 2 3 | ./configure --with-aspxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/bin/mysql_config --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd make make install |
Set up an ini file for PHP:
sudo cp php.ini-development /usr/local/lib/php.ini |
tell apache to load the module:
LoadModule php5_module modules/libphp5.so |
You need to re/start apache
/usr/local/apache2/bin/apachectl start |
personally I like to restart the entire server with changes this big
shutdown now -r |
Thats it!
9,576 views
This entry was posted on Thursday, June 16th, 2011 at 11:44 am and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed.