Monday, August 06, 2007

How to set Lamp in Linux

How to set LAMP?
in ur Box

Lamp means linux apache and mysql .. First u need to check above all packages are installed in ur box . if ur using rpm packages use the commands in u terminal
Type:
1.rpm -qa | grep -i apache
2.rpm -qa | grep -i httpd
3.rpm -qa | grep -i php
4.rpm -qa | grep -i mysql

To remove the rpm generator package
rpm -e

go to /usr/local/src
download all package using wget,yum,yast

wget http://www.php.net/distributions/php-4.4.6.tar.gz
wget http://apache.oregonstate.edu/httpd/apache_1.3.37.tar.gz
Unpack all the packages
tar zxf php-4.4.6.tar.gz
tar zxf apache_1.3.37.tar.gz
tar zxf mysql-4.1.22.tar.gz
So nest ur director in /usr/local/src
/usr/local/src/php-4.4.6
/usr/local/src/apache_1.3.37
/usr/local/src/mysql-4.1.22
Nest step we need to create group and owner
groupadd mysql
useradd -g mysql -c "MySQL Server" mysql --->./configure --help | less
To install mysql with apache and php
cd /usr/local/src/mysql-4.1.22

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

Use make && make install to install the package in ur box
Create a ownership in mysql
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data

Copy the default configuration file for the expected size of the database (small, medium, large, huge)
cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig

Now create a startup script, which enables MySQL auto-start each time your server is restarted.
cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
/sbin/chkconfig --level 3 mysql on

Start the mysql
/etc/rc.d/init.d/mysql start
Create new password for root
mysqladmin -u root password new-password
Build apache
cd /usr/local/src/apache_1.3.37

make clean

./configure \
--prefix=/usr/local/apache \
--enable-shared=max \
--enable-module=rewrite \
--enable-module=so

make && make install

To install php
cd /usr/local/src/php-4.4.6

./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

I like to keep my config files all together in /etc. I set up a symbolic link like this:

ln -s /usr/local/lib/php.ini /etc/php.ini

Link the configuartion files
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
add in httpd.conf
AddType application/x-httpd-php .php .foo
AddType application/x-httpd-php-source .phps .phtmls
start apache /etc/init.d/apache start or apachectl start

No comments:

Post a Comment

Powered By Blogger