How To Install Apache with MySQL and PHP on Linux CentOS

Netshop-Isp

Member
One of the first tasks a server administrator will have to perform to setup a web server is to install apache with mysql and php support (LAMP – Linux Apache Mysql Php).

In this tutorial we will use the hostname server1.example.com with the IP address 192.168.0.1. These settings might differ for you, so you replace them where appropriate.

1. Install MySQL 5

yum install mysql mysql-server


Then we need to create the system startup links for MySQL so that MySQL starts automatically whenever the system boots:

chkconfig –levels 235 mysqld on /etc/init.d/mysqld start

Then run the following commands to setup a password for the root user of mySQL database (otherwise everyone will be able to connect!):

mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword


2. Install Apache 2

yum install httpd

Now run the following command to configure Apache to start at boot time…

chkconfig –levels 235 httpd on

Now start Apache:

/etc/init.d/httpd start

Apache has been successfully installed! Go to http://192.168.0.1 and you should see the Apache2 Welcome page.

3. Install PHP5


yum install php

Now restart Apache:

/etc/init.d/httpd restart


… and you are done!

4. MySQL Support in PHP5

To get MySQL support in PHP, install the php-mysql package. We also recommend to install some other PHP5 modules as you will probably need them for your applications. You can search for available PHP5 modules like this:

yum search php


Choose the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Now restart Apache2 again:

/etc/init.d/httpd restart

… and you are done!

Now if you go to http://192.168.0.1/info.php in your browser, scroll down to the modules section again and you should now find lots of new modules there.
 
the php5 installation is not that simple, you always need to configure something else and you have to get an updated source in order to update to newest version.
 
Back
Top