Installing Apache – Mysql – PHP in less than 5 minutes

Was just setting up a brand new Linux Centos box, and thought I would contribute with a small tutorial on how to quickly install the core components of a Web server though shell.

Now note that to get the absolute latest software version an installation through the source code is required. While this is still easy, it’s not as fast.

The commands poster here will work with the Centos and Fedora distributions. 

1.  Login as a Roor user and paste the following command line

yum -y install httpd php mysql mysql-server php-mysql

2. Make sure Mysql is running.

# mysqladmin -u root -p status

If it’s not running, you should be getting something down the lines of…

mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

To start the service simply type in the command:

/etc/init.d/mysqld start

The Output of this should be something down lines of…

Initializing MySQL database:  Installing MySQL system tables...

OK

Filling help tables...

OK

3. Protect Mysql by setting a password

mysql -u root@localhost

set password for root=password(‘yourpasswordhere’);

reload privileges;

4- Set apache and Mysql to run on startup. 

  /sbin/chkconfig httpd on

  /sbin/chkconfig --add mysqld

  /sbin/chkconfig mysqld on

  /sbin/service httpd start

  /sbin/service mysqld start

Thats it! your web server is good to go!