Setup your linux server with apache, php and mysql to host websites a step by step tutorial

Lets suppose you got an empty dedicated server you ordered from a web hosting company and you want to start hosting websites which use php, mysql. Below are simple easy steps which you can take to setup your website in a few commands.

1. Install Apache
There are many ways to install apache on your web server the most easiest way is to use yum.

yum install apache

If you dont have yum installed use this url

2. Install Php

To install php from php.net repo you can use this article i wrote

other wise you can just use

yum install php

3. Install Mysql

To install mysql you just need to run this command
yum install mysql

Now you have installed LAMP.

Now lets configure apache so that it runs your website.

find httpd.conf or apache2.conf depending on your Os
normally they are in the /etc/ directory.

Edit the file using this command.
nano /etc/httpd/conf/httpd.conf (CentOs dir)
if you dont have nano use vi

search for VirtualHost normally this is at the end of the file.

Edit the file with your ip address and website name like this

<VirtualHost [your sever ip address]:80>
DocumentRoot /var/www/html/[your website folder]
ServerName [name of the website]
</VirtualHost>

Remember the path of the DocumentRoot depends on your Os the path i used is normally on CentOS

Next step is to search for NameVirtualHost
change that to.

NameVirtualHost [your server ip]:80

thats it just save the file and restart apache

service httpd restart

The final thing is to assign nameservers to your domain so that it points to your server. You can use different free DNS service providers like zoneedit.com
signup and configure your site with the ip address of your server and booom your site will start working.

Related posts:

  1. Apache Web Server .htaccess File not working?
  2. Mysql.so not found on a linux machine?
  3. How to install yum on linux server
  4. Nano command not working in linux?
  5. How to save and quit vi command in linux

14 Responses

03.01.10

This site looks good as it will save me a load of time crawling around for Outsourcers.

03.01.10

Just landed on this place via Google research. I love it. This post change my perceptual experience and I am getting the RSS feeds. Cheers.

03.01.10

A teacher recommended that I take a look at your site. I’m glad that I’m here.

03.01.10

Hi, nice blog. I hope you can join our monthly blogging tournament.

03.01.10

Wow, regards a bunch m8

03.01.10

After reading your post I can tell you are well-informed about your writing. Thank you.

03.01.10

hello superb little blog site ya got here :-) I work with the identical template on my own website yet somehow for whichever odd cause it would seem to load at a higher speed on this blog despite the fact that this blog contains more material. Are you using any kind of plug ins or widgets that quicken it up? Do you think you could possibly give the titles so that I would be able to use them in my own online site so twilight eclipse followers could watch twilight eclipse online trailers and clips quicker I would always be pleased – thanks in advance :)

good article, i will add my feeds.

03.01.10

Easily, the post is actually the greatest on this deserving topic. I agree with your conclusions and will thirstily look forward to your coming updates. . . . .

03.01.10

Everything has improved extremely grateful to you for the sper working in the whole program ..

03.01.10

THANKS! Wonderful job Jonny

03.01.10

hiiiiiiiiiiii

this article help in my project

this article is good

03.01.10

Most article marketers tend to be so concentrated on the article creation process that they totally overlook to promote their articles. I great way to start out is by means of social media marketing and search engine optimization.

03.01.10

This just took off here. so cool. Great stuff.

Leave Your Response

* Name, Email, Comment are Required