Build LAMP Server (step by step guide)
Posted: Fri Jul 25, 2008 9:08 am
This document will walk you through the installation of what is known
as a "LAMP" Linux, Apache, MySQL and PHP system.
OS: CentOS 5.2
Apache: httpd-2.2.9.tar.gz
MySQL:mysql-5.0.51b.tar.gz
PHP:php-5.2.6.tar.gz
Method: tar-ball
Build and Install MySQL
groupadd mysql
useradd -g mysql -c "MySQL Server" mysql
cd /usr/local/src/mysql-4.1.22
chown -R root.root *
./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
make && make install
Configuring MySQL
./scripts/mysql_install_db
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
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
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
cd /usr/local/mysql/bin
ln -s /usr/local/mysql/bin/* /usr/bin/
Security Issue
Edit /etc/my.cnf and uncomment the line (delete the leading #).
skip-networking
Start MySQL
/etc/rc.d/init.d/mysql start
mysqladmin version
mysqladmin -u root password new-password #replace new-password with
your actual password of your database
Test Mysql
mysql -u root -p #provide password which you set with above command
and you will see mysql prompt
mysql>
drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;
update user set user="sqladmin" where user="root";
flush privileges;
create database foo;
drop database foo;
\q
Build and Installing APACHE
./configure --prefix=/usr/local/apache
make && make install
Build and Install PHP
./configure --with-apxs2=/usr/local/apache/bin/apxs --disable-debug --
enable-ftp --enable-inline-optimization --enable-magic-quotes --
enable-mbstring --enable-wddx=shared --enable-xml --with-gd --with-
gettext --with-mysql=/usr/local/mysql --with-regex=system --with-zlib-
dir=/usr/lib
make && make test && make install
cp php.ini-dist /usr/local/lib/php.ini
ln -s /usr/local/lib/php.ini /etc/php.ini
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
vi /etc/httpd.conf #and add these content type in apache conf file
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.htm index.html
Start Apache
ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S90httpd
/etc/rc.d/init.d/httpd start
Regards
as a "LAMP" Linux, Apache, MySQL and PHP system.
OS: CentOS 5.2
Apache: httpd-2.2.9.tar.gz
MySQL:mysql-5.0.51b.tar.gz
PHP:php-5.2.6.tar.gz
Method: tar-ball
Build and Install MySQL
groupadd mysql
useradd -g mysql -c "MySQL Server" mysql
cd /usr/local/src/mysql-4.1.22
chown -R root.root *
./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
make && make install
Configuring MySQL
./scripts/mysql_install_db
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
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
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
cd /usr/local/mysql/bin
ln -s /usr/local/mysql/bin/* /usr/bin/
Security Issue
Edit /etc/my.cnf and uncomment the line (delete the leading #).
skip-networking
Start MySQL
/etc/rc.d/init.d/mysql start
mysqladmin version
mysqladmin -u root password new-password #replace new-password with
your actual password of your database
Test Mysql
mysql -u root -p #provide password which you set with above command
and you will see mysql prompt
mysql>
drop database test;
use mysql;
delete from db;
delete from user where not (host="localhost" and user="root");
flush privileges;
update user set user="sqladmin" where user="root";
flush privileges;
create database foo;
drop database foo;
\q
Build and Installing APACHE
./configure --prefix=/usr/local/apache
make && make install
Build and Install PHP
./configure --with-apxs2=/usr/local/apache/bin/apxs --disable-debug --
enable-ftp --enable-inline-optimization --enable-magic-quotes --
enable-mbstring --enable-wddx=shared --enable-xml --with-gd --with-
gettext --with-mysql=/usr/local/mysql --with-regex=system --with-zlib-
dir=/usr/lib
make && make test && make install
cp php.ini-dist /usr/local/lib/php.ini
ln -s /usr/local/lib/php.ini /etc/php.ini
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
vi /etc/httpd.conf #and add these content type in apache conf file
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.htm index.html
Start Apache
ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S90httpd
/etc/rc.d/init.d/httpd start
Regards