In the previous week I had configured LAMP in our server. Being a person who had worked in php for some months, actually I was not much aware of setting this in Linux. On my php days I was only using the easy windows bundle “phptriad” for coding… Being a man who is not much familiar with Linux, this installation was not much easy for me. The one main problem occurred is with the compatibility issue of the latest PHP and MySQL downloads.
1. Remove previous RPM Versions of the Applications
rpm -qa | grep -i apache
rpm -qa | grep -i httpd
rpm -qa | grep -i php
rpm -qa | grep -i mysql
2. Get the Source Code for all Applications from their respective sites
3. Unpack the Source Code
tar zxf php-x.x.x.tar.gz
tar zxf apache_x.x.xx.tar.gz
tar zxf mysql-x.x.xx.tar.gz
This should leave you with the following directories:
/usr/local/src/php-4.4.2
/usr/local/src/apache_1.3.34
/usr/local/src/mysql-4.0.26
4. Build and Install MySQL
cd /usr/local/src/mysql-x.x.xx
chown -R root.root *
make clean
./configure \
–prefix=/usr/local/mysql \
–localstatedir=/usr/local/mysql/data \
–disable-maintainer-mode \
–with-mysqld-user=mysql \
–with-unix-socket-path=/tmp/mysql.sock \
–without-comment \
–without-debug \
–without-bench
then make && make install
5. Build and Install Apache (with DSO support)
cd /usr/local/src/apache_1.3.34
make clean
./configure \
–prefix=/usr/local/apache \
–enable-shared=max \
–enable-module=rewrite \
–enable-module=so
make && make install
6. Build and Install PHP
cd /usr/local/src/php-x.x.x
./configure \
–with-apxs=/usr/local/apache/bin/apxs \
–disable-debug \
–enable-ftp \
–enable-inline-optimization \
–enable-magic-quotes \
–enable-mbstring \
–enable-mm=shared \
–enable-safe-mode \
–enable-track-vars \
–enable-trans-sid \
–enable-wddx=shared \
–enable-xml \
–with-dom \
–with-gd \
–with-gettext \
–with-mysql=/usr/local/mysql \
–with-regex=system \
–with-xml \
–with-zlib-dir=/usr/lib
make && make install
cp php.ini-dist /usr/local/lib/php.ini
ln -s /usr/local/lib/php.ini /etc/php.ini
7. Edit the Apache Configuration File (httpd.conf)
To ensure your PHP files are properly interpreted, and not just downloaded as text files , add these lines to the respective location in the httpd.conf file. We can find the location by searching “AddType”.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-tar .tgz
AddType application/x-httpd-php .php .foo
AddType application/x-httpd-php-source .phps .phtmls
AddType application/x-httpd-php .php .htm .html
8. Commands to start, stop or restart apache
To start apache : /usr/local/apache/bin/apachectl start
To stop apache : /usr/local/apache/bin/apachectl stop
To restart apache : /usr/local/apache/bin/apachectl restart
Source: here
Technorati tags: Linux, LAMP, PHP, Apache, MySQL
One thought on “Building a LAMP server in Linux”