CentOS 5.5 + LAMP + Webmin Installation Tutorial
The goal here is to setup Apache, MySQL and PHP which is commonly referred to as a “LAMP” server. Everyone’s requirements are different but this will give you an easy way to get started. You will need a functional server with a fresh, clean installation of CentOS 5.5 to begin.
Installing Apache
You will want to utilize the yum repository for easy installation:
1 | yum install httpd httpd-devel |
Wait for the installation to complete then start up Apache:
1 | /etc/init.d/httpd start |
The location of the Apache configuration file should be located here: /etc/httpd/conf/httpd.conf
If not you can run the following command and SSH which should output the location:
1 | whereis httpd.conf |
Be sure to add the Apache daemon into start-up so it runs automatically after a reboot:
1 | chkconfig httpd on |
Installing MySQL (latest version)
Utilize the yum repository again for quick and easy installation:
1 | yum install mysql mysql-server mysql-devel |
Then run the MySQL daemon:
1 | /etc/init.d/mysqld start |
Add the MySQL daemon into start-up so it runs automatically after a reboot:
1 | chkconfig mysqld on |
If you want to make sure MySQL is running, run the following command:
1 | ps aux | grep mysql |
This step is of unnecessary but it’s just in case you run into any issues.
For security purposes, you will want to change the MySQL root password through the MySQL console:
1 | mysql |
The console should open, then run the following:
1 2 3 | mysql> USE mysql; mysql> UPDATE user SET Password=PASSWORD('<em>password</em>') WHERE user='root'; mysql> FLUSH PRIVILEGES; |
Note: be sure to change the (‘password’) to your liking.
To login into MySQL as root run:
1 | mysql -u root -p |
Once you are logged in you can create a database. I am going to use “blog” as the database name and add the user “john” with full privileges:
1 2 3 4 | mysql > create database blog mysql > GRANT ALL PRIVILEGES ON blog.* TO 'guest'@'localhost' IDENTIFIED BY 'john' WITH GRANT OPTION; mysql> USE mysql; mysql> UPDATE user SET Password=PASSWORD('password') WHERE user='john'; |
And that’s it for MySQL!
Installing PHP
Install PHP through yum with some required modules. These can be changed to meet your requirements but should be sufficient for most setups:
1 | yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml |
By restarting Apache, PHP should fire up:
1 | /etc/init.d/httpd restart |
Your “public_html” folder or “www” folder is located in the /var/www/html/ directory. To test and see if PHP is working, you will want to create a PHP file with the following code:
1 | <?php phpinfo(); ?> |
I normally call this file, phpinfo.php. You can then access the file through your IP address (eg. http://IPADDRESS/phpinfo.php)
You will want to install phpMyAdmin for easier MySQL DB management. To install simply run:
1 | yum install phpmyadmin |
Then access phpMyAdmin through the following URL: http://ip-address/phpmyadmin
Installing Webmin (Latest Version)
First download the RPM:
1 | wget http://prdownloads.sourceforge.net/webadmin/webmin-1.580-1.noarch.rpm |
Then run the following command:
1 | rpm -U webmin-1.580-1.noarch.rpm |
(latest RPM can be found here: http://www.webmin.com/rpm.html)
The rest of the install will be done automatically to the directory /usr/libexec/webmin, the administration username set to root and the password to your current root password. You should now be able to login to Webmin at the URL http://localhost:10000/. Or if accessing it remotely, replace localhost with your system’s IP address.