How To Install LAMP
LAMP is an acronym which stands for Linux, Apache, MySQL and PHP. The letter P also stands for Perl and Python programming languages. LAMP is a free software stack which powers, primarily, web servers. Most GNU/Linux distributions bundle these packages in the install media and repositories. Let us take a look at how to install LAMP using Fedora. I will restrict the P in LAMP to PHP only for this article. Perl and Python fans, bear with me.
While installing Fedora you can choose to install "Web Sever" which contains these packages. You can install them later also. Let me walk you through the actual steps to get LAMP working on your computer. I assume you are running Fedora 8 on your computer.
1. Launch the terminal by clicking
Applications>System Tools>Terminal2. Switch to super user mode. You will require the root password.
su -3. Check if Apache HTTP Server is installed already
rpm -q httpdIf you see the package name httpd-x.x.x-x, Apache web server is already installed on your computer. If it is not you can install it using the yum command. We will discuss how to install it in a few moments.
4. Check if PHP and MySQL are installed already
rpm -q php If PHP is installed, you will see the package name on the screen. Otherwise the shell returns the prompt without any message. Similarly check if MySQL is installed.
rpm -q mysql 5. Installing the necessary packages using yum
yum install httpd php php-pdo php-mysql php-gd mysql mysql-server The yum package management tool resolves dependencies and displays the packages that are available for installation with their version numbers, architectures and repository details. You can choose to say yes or no when it asks for your confirmation to proceed. If you choose yes, yum downloads the necessary packages and installs it for you. You can sit back and relax for a while until all the packages are installed on your computer. If some of the packages are already installed on your computer, yum skips them and downloads only the missing packages.
6. Starting the services: You must start the services to make use of them.
service mysqld start
service httpd start7. You can set these services to start when your computer starts using the
chkconfig command.
chkconfig httpd on
chkconfig mysqld onTo print the list of services with the runlevel information type:
chkconfig --list Runlevel 5 is the technical name for graphical multiuser mode and runlevel 3 for command line multi user mode on Red Hat like systems. Check if mysqld and httpd are set to runlevel 3 and 5. Alternatively you can use the graphical tool ntsysv to start or stop services at system start-up.
ntsysv --level 5
ntsysv --level 3PHP runs as an Apache HTTP server module. PHP starts when httpd starts.
8. Verifying LAMP installation: In your web browser address bar type http://localhost/ and hit the return key. If you see the Fedora test page you have done everything correctly. Pat on your back.
The default DocumentRoot is /var/www/html directory. Place your HTML and PHP scripts in /var/www/html directory and view them in action at http://localhost from your web browser. You can change the DocumentRoot and even run multiple websites simultaneously using name-based virtual hosts.
The phpinfo() function in the PHP scripting language is very useful and prints important information about the LAMP stack. Open a text editor and copy the below code and paste it.
<?php
phpinfo();
?>Save the file as phpinfo.php in the /var/www/html directory. View it from the web browser by typing http://localhost/phpinfo.php.
By default MySQL's root password is set to blank. Connect to the local MySQL server using the MySQL client and change it immediately.
mysql -u root -pThe screen looks something like
[root@localhost test]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 60
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>In the MySQL client(where you see mysql> before the blinking cursor), use the below SQL to change the root password.
SET PASSWORD FOR 'root'@'localhost' = password('newpassword');9. Installing optional packages: There are many software tools available to make your life easier with LAMP. There are GUI tools available to mange MySQL server, databases, http server and many more. I have listed couple of them below
- phpMyAdmin to manage MySQL databases from the web browser. You can install phpMyAdmin by using yum
yum install phpmyadmin
Once you install phpMyAdmin you can access it by typing localhost/phpMyAdmin in your web browser. yum install system-config-httpd
Go ahead and build great applications on your LAMP stack. Feel free to use the forums to discuss it further. You may also post comments to this post.









bash: ******: command not found
Hi :)
thank you for a great tutorial!
I do have a problem though, some commands won't work: service, chkconfig, ntsysv. I get a message like this:
bash: ntsysv: command not found
I was able to start those 2 through GUI by going to Services and it seems to be working fine (I got the fedora test page).
Re: bash: ******: command not found
You're welcome.
You have to install the packages in order to use them. Here's how you do it.
yum install ntsysvyum install chkconfig
yum install initscripts
Or all the packages at once.
yum install ntsysv chkconfig initscriptsAfter installing these packages try the commands.
You might want to check out the basic yum tutorial too.
With warm regards,
Sudheer
yum phpmyadmin
I can't get the yum install phpmyadmin to work correctly. It says:
No Match for argument: phpmyadmin
Nothing to do
any suggestions
Hi Jason, Let's see what the
Hi Jason,
Let's see what the problem is.
Try
yum search phpmyadminand report back what happens.
With warm regards,
Sudheer
Great Article, easy and
Great Article, easy and success.
Thanks.
You're welcome. With warm
You're welcome.
With warm regards,
Sudheer
good writeup
good writeup
Hi there, Thanks. I will
Hi there,
Thanks. I will look forward to hear from you again.
With warm regards,
Sudheer
Post new comment