Wednesday, May 14, 2014

Installing LAMP in CentOS (Linux Apache MySQL PHP)


Here you will find instructions on how to install Apache, MySQL and PHP on CentOS.

Installing Packages

1 Install the required packages with the following command: 

# yum install httpd php mysql mysql-server php-mysql

Downloading Packages:
(1/7): httpd-2.2.15-30.el6.centos.x86_64.rpm                            | 821 kB     00:00
(2/7): httpd-tools-2.2.15-30.el6.centos.x86_64.rpm                      |  73 kB     00:00
(3/7): mysql-5.1.73-3.el6_5.x86_64.rpm                                  | 894 kB     00:00
(4/7): mysql-server-5.1.73-3.el6_5.x86_64.rpm                           | 8.6 MB     00:00
(5/7): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                            | 134 kB     00:00
(6/7): php-5.3.3-27.el6_5.x86_64.rpm                                    | 1.1 MB     00:00
(7/7): php-mysql-5.3.3-27.el6_5.x86_64.rpm                              |  81 kB     00:00

2 Then, start the services by:

# /etc/init.d/httpd start
# /etc/init.d/mysqld start

Configuring Services 

Apache 2  

The configuration file of the Apache service is in the file /etc/httpd/conf/httpd.conf.  
The Apache documentation is available under http://httpd.apache.org/docs/.

MySQL  

You must create a root password before you can use the MySQL server in a production environment. The following code shows an example of how to do it:

# mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
The configuration file for the MySQL service is available in /etc/my.cnf.
The documentation is available at http://dev.mysql.com/doc/

 

PHP  

You can find the configuration file for PHP in /etc/php.ini.
The documentation for PHP is available at http://www.php.net/docs.php

 

Launching services 

Run the following commands to ensure that the services are started at boot time:

# chkconfig httpd on
# chkconfig mysqld on

 Hope help