Home / guides   Print version

RedHat LAMP (Linux, Apache, MySQL, PHP) install tutorial

Publish date 16/12/2008

This is a tutorial to install LAMP: Linux, Apache, MySQL and PHP on RedHat.

This is writen for RedHat using YUM. But can be installled on any system that uses YUM as a package manager, Like Fedora and CentOS.
YUM is a tool for installing, updating, and removing packages and their dependencies on RPM-based systems.

Before you install make sure you are logged in as root.

Install

The installation can be done with one command:

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.

Starting

You can start the servers with:

service mysqld start
service httpd start
You can set these services to start at boot using the chkconfig command:
chkconfig httpd on
chkconfig mysqld on

Config

Apache

The default DocumentRoot is /var/www/html/ directory.
The config files can be found in /etc/httpd/conf/ and /etc/httpd/conf.d/

MySQL

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 -p
SET PASSWORD FOR 'root'@'localhost' = password('newpassword');
You might want to create extra users for different task or databases. This can be done with GRANT in MySQL:
mysql -u root -p
GRANT select,insert,update,delete,create,drop ON database.* TO 'username'@'localhost' IDENTIFIED BY 'password'
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';

Test

Create a php-file in the www-dir and test it.

echo "<?php phpinfo(); ?>" > /var/www/html/test.php
Then redirect you browser to the server. ip-address/test.php
You should see a list of php-setting.

 

TOP