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):
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):
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:\webserver\Apache2\conf’. 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:
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 Responses to “Setting up an Apache webserver”
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.
Hi
You are The Best!!!
G’night
Interesting post,I really like your writing style its a lot better than most bloggers!
Leave a Reply