Build LAMP Server (step by step guide)
-
- Battalion Havaldaar Major
- Posts: 269
- Joined: Sat Dec 13, 2003 3:58 pm
- Location: Faisalabad
- Contact:
Build LAMP Server (step by step guide)
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
Nafees Ahmed
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
LAMP on Ubuntu
Here is the One for Ubuntu Server
Installing Apache2
1. Open up the Terminal (Applications > Accessories > Terminal).
2. Copy/Paste the following line of code into Terminal and then press enter:
3. The Terminal will then ask you for you're password, type it and then press enter.
Testing Apache2
To make sure everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
You should see a folder entitled apache2-default/. Open it and you will see a message saying "It works!" , congrats to you!
Installing PHP5
In this part we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories > Terminal).
Step 2. Copy/Paste the following line into Terminal and press enter:
Step 3. In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:
Testing PHP5
To ensure there are no issues with PHP let's give it a quick test run.
Step 1. In the terminal copy/paste the following line:
This will open up a file called phptest.php.
Step 2. Copy/Paste this line into the phptest file
Step 3. Save and close the file.
Step 4. Now open you're web browser and type the following into the web address:
Congrats you have now installed both Apache and PHP!
Installing MySQL5
To finish this guide up we will install MySQL. (Note - Out of Apache and PHP, MySQL is the most difficult to set up. I will provide some great resources for anyone having trouble at the end of this guide.)
Step 1. Once again open up the amazing Terminal and then copy/paste this line:
Step 2. This is where things may start to get tricky. Begin by typing the following into Terminal:
Enter in the password that you setup during the apt-get install process.
Step 3. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:
After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
Step 4. Once the text editor opens the php.ini file, go to the bottom of the file and add in the following line:
This will allow you to use MySQL within your PHP scripts.
Now just restart Apache and you are all set!
Installing Apache2
1. Open up the Terminal (Applications > Accessories > Terminal).
2. Copy/Paste the following line of code into Terminal and then press enter:
Code: Select all
sudo apt-get install apache2
Testing Apache2
To make sure everything installed correctly we will now test Apache to ensure it is working properly.
1. Open up any web browser and then enter the following into the web address:
Code: Select all
http://localhost/
Installing PHP5
In this part we will install PHP 5.
Step 1. Again open up the Terminal (Applications > Accessories > Terminal).
Step 2. Copy/Paste the following line into Terminal and press enter:
Code: Select all
sudo apt-get install php5 libapache2-mod-php5
Code: Select all
sudo /etc/init.d/apache2 restart
To ensure there are no issues with PHP let's give it a quick test run.
Step 1. In the terminal copy/paste the following line:
Code: Select all
sudo gedit /var/www/testphp.php
Step 2. Copy/Paste this line into the phptest file
Code: Select all
<?php
phpinfo();
?>
Step 4. Now open you're web browser and type the following into the web address:
Code: Select all
http://localhost/testphp.php
Installing MySQL5
To finish this guide up we will install MySQL. (Note - Out of Apache and PHP, MySQL is the most difficult to set up. I will provide some great resources for anyone having trouble at the end of this guide.)
Step 1. Once again open up the amazing Terminal and then copy/paste this line:
Code: Select all
sudo apt-get install mysql-server
Code: Select all
mysql -u root -p
Step 3. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:
Code: Select all
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
Code: Select all
gksudo gedit /etc/php5/apache2/php.ini
Code: Select all
extension=mysql.so
Now just restart Apache and you are all set!
Code: Select all
sudo /etc/init.d/apache2 restart
Last edited by x2oxen on Mon Aug 18, 2008 10:39 am, edited 1 time in total.
AOA,
Good work... Its worth an appreciation.
Good work... Its worth an appreciation.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
-
- Battalion Havaldaar Major
- Posts: 269
- Joined: Sat Dec 13, 2003 3:58 pm
- Location: Faisalabad
- Contact:
thanks for appreciation
Nafees Ahmed
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
php step 2 is broken.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
-
- Battalion Havaldaar Major
- Posts: 269
- Joined: Sat Dec 13, 2003 3:58 pm
- Location: Faisalabad
- Contact:
from mine post ?
Nafees Ahmed
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
is there a step 2 in your post?
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
-
- Battalion Havaldaar Major
- Posts: 269
- Joined: Sat Dec 13, 2003 3:58 pm
- Location: Faisalabad
- Contact:
yes, but i did not mention 

Nafees Ahmed
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
Cell: +92.300.8653568
UAN: 041-111432432
Nexlinx Faisalabad
www.nexlinx.net.pk
nafees29@gmail.com
This is what my aptitude search showed up.
root@proxy:~# aptitude search php5
p libapache2-mod-php5 ---------server-side, HTML-embedded scripting language (apache 2 module)
p libgv-php5---------Php5 bindings for graphviz
p php5---------server-side, HTML-embedded scripting language (meta-package)
p php5-apache2-mod-bt---------PHP bindings for mod_bt
Its working fine for me!
root@proxy:~# aptitude search php5
p libapache2-mod-php5 ---------server-side, HTML-embedded scripting language (apache 2 module)
p libgv-php5---------Php5 bindings for graphviz
p php5---------server-side, HTML-embedded scripting language (meta-package)
p php5-apache2-mod-bt---------PHP bindings for mod_bt
Its working fine for me!
the phptest step is broken.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
-
- Site Admin
- Posts: 5132
- Joined: Fri May 02, 2003 10:24 am
- Location: Karachi
- Contact:
Re:
Dear x2oxen,
Salam,
Agreed with lambda, you need to add some thing like this.
Best Regards.
Salam,
Agreed with lambda, you need to add some thing like this.
Code: Select all
<?php
phpinfo();
?>
Farrukh Ahmed