Setting up an Apache webserver

By | April 16, 2006

I’ve recently been posting about ways to trick a search engine and what not to do when building a website. Today I realized that though this is good information its completely useless unless you have somewhere to play with it. It can be a huge step to buy your first domain and hosting solution.

So today I’m going to share with you how to set up your own webserver, well the basics anyway. This way you’ll be able to get your feet wet without it costing you to much money. Just one note for those Linux lovers, this article won’t be for you.
Beginning simple
So lets begin shan’t we. First you’ll need to get some software to set up your server. You basically have two options. You can either download a complete package like WAMP or install everything manually. Since I think WAMP is to basic and leaves me with to little to configure I won’t explain that. If you just want a simple testing server then read the installation guide over at the WAMP site.

Ready to start then you’ll need to download the following software:

Have all the files now don’t you. Well just store them somewhere in case you need to reinstall the entire webserver at a later stage.

Installing  Apache & PHP
This should be the simplest steps you will ever have to take. First we are going to install the Apache server, as this will be needed for all the other installations. These are the steps you should take (note they are based on 2.0.55):

  • Click the next button
  • Select ‘I accept’ and click next twice
  • Fill out the domain name, server name and e-mail
    • Domain name: fill out something funny or you DynDNS or no-ip.com address
    • Server name: well you can make something silly up can’t you
    • Administrator: uhm, as long as it sounds like an e-mail address you should be fine
    • Choose the for all users mode. (You may also choose the other but then only you will have access and only you can start it)
  • Select the typical installation and set the installation root
  • Press ‘Install’ and you’re all done with this for now

Next step in your little webserver is installing PHP, why you may ask. Well most websites require PHP to run as it is currently the most popular dynamic scripting language available. So lets walk through the installation (again I choose the lates version):

  • Hit next and ‘I Agree’
  • Select ‘Standard’ and press next
  • Change the folder to our selected path and add ‘PHP’ to that, just so we don’t install it in the webroot
  • You can leave the SMTP and from field as they are if your not planning on using build-in mailing features. Otherwise fill in your SMTP server and e-mail address. (SMTP is of your ISP so check those papers for it)
  • Select ‘Apache’ from the list and keep hitting next until the installer is done.

Before we are going to continue with installing the MySQL server it is time to tell Apache that PHP is installed and how to handle any PHP files. I’m including this part as it did not install fully automatic for me, so it might not for you.  So locate the file httpd.conf and open it, the file should be in ‘c:webserverApache2conf’. Add the following lines to enable PHP for your webserver:

ScriptAlias /php/ ‘c:/webserver/php/’                       # Set the path /php to translate to ‘c:/webserver/php/
AddType application/x-httpd-php .php                    # Add that all files ending on .php will be seen as the given type
Action application/x-httpd-php ‘/php/php-cgi.exe’    # Add the handler that will deal with the .php files

Now you’re all done to be able to build your own little website in PHP and test or host it on your Apache server. Do not that any changes made to httpd.conf require you to restart Apache. This can be done by selecting the Apache icon in the iconbar of the taskbar.

Setting up MySQL
Noticed we didn’t install MySQL yet. Well get ready your about to! Just follow the following simple steps:

  • Hit next and select custom
  • Change the installation directory to your webserver root
  • Press next and install (Get ready to wait like forever, the installer is damn slow)
  • Select ‘Skip sign-up’ and press next
  • Press next again, we are now going to configure MySQL
    • Hit next, select detailed and hit next again (its getting so boooring. I know!)
    • You can now choose developer or server (i prefer developer as it uses less resources)
    • Leave it on multifunctional, this is the most used and usable one for websites
    • Keep the path the same, unless you really want databases to be stored elsewhere.
    • Keep hitting next until you reach the ‘Modify Security Settings’ dialog
    • Set the root password, oh and remember it, unless you like re-installing MySQL everytime you need to change something.
    • Hit execute and wait

You would have been done now if the guys at PHP weren’t as lazy as they were. They choose to exclude MySQL support in PHP 5. So if you choose that like I did you will need to download the entire zip file for the PHP 5.1.2. This is such a stupid choice of them, but heay what can I do. You are looking for two files, namely ‘libmysql.dll’ and ‘php_mysql.dll’. Copy them in the windows root or in the php root, whatever you like.

Lookup the line: ‘;extension=php_mysql.dll’ and remove the ‘;’ from it. This will enable the MySQL interface of PHP. Try to load a PHP page, if you get any warnings about the file ‘php_mysql.dll’ then you either did not copy them in the windows root or forgot one of the two.

Ok that’s it for now. Next time I’ll write something about configuring the Apache server a bit more and how to set up MySQL with proper authorization and user management. Hope to see you all then.

3 thoughts on “Setting up an Apache webserver

  1. Jongerius Post author

    I’ve seen some people interested in seeing where the default pages are located and the default html root. So for those this added comment is.

    The default document root is (windows):
    [instal_dir]htdocs

    This can be changed in hpttd.conf by modifying line to whatever you like:
    DocumentRoot “[instal_dir]/htdocs”

    Another option is setting up virtual hosts. But this is something for the follow up post.

    Reply
  2. Master reseller hosting

    Interesting post,I really like your writing style its a lot better than most bloggers!

    Reply

Leave a Reply