loading
This instructable is to show you how to install Apache, PHP, MySQL on localhost.
Also how to set it up so that you have some cool network features, such as being able to load the root directory using the computer's name (http://desktop/index.php), being able to edit files on other computers, and access different computers through different ports while using a domain or IP.

For people who are just getting into web development, this will help you a bundle. I've been using this setup (or similar) for at least 2 years. You can code sites on localhost, and once it works perfectly, upload it onto a host.

Unfortunately, I am forced to do this on a Vista machine, since my laptop with XP is already set up, and this computer gives me ACPI errors when I install XP.

Step 1: Configure Your Network Card

In order for you to be able to use this on computers outside your home network, (The internet) you will need this step.
This only work if you have a router.
Go into your control panel, Network and Sharing center. Where it says Connection, look to the far right. There should be a View Status button. Click on that.
Note down your IP address, (IPv4, if you see IPv6 too) your subnet mask, default gateway, and DNS servers.
Now press close, and in the "Local Area Connection Status" window, click on Properties.
Click on TCP/IPv4, then click on properties. Check off "Use the following IP address", and enter in all the information you just noted down.
Optionally, you can use 4.2.2.1 and 4.2.2.2 for your DNS servers. I find that they update really fast compared to other DNS servers.
This ensures your PC keeps the same local IP, and the DHCP doesn't re-assign you an IP whenever you restart.

Step 2: Configure Your Router

In your web browser, type in the Default Gateway IP from the previous step. It may ask for a password, it may not. It should be different for everybody, for me it's admin/admin - The default Linksys password. If that doesn't work, i suggest checking Google or a manual.
Once logged in, look for port forwarding. Enter in the IP address from the previous step, and a random port number. I wouldn't suggest port 21 or 80, as they are FTP and HTTP protocols default ports. You don't want random people being able to access this, so random numbers that only you know are the best. Make sure the protocol is set to both UDP and TCP.

This will be different for everybody, unless you have a WRT54G. You'll just have to search your settings for these.

Step 3: Optional: Det Up DNS Fowarding

If you have hosting somewhere with a domain, or have an inactive domain that you would like to point to your computer, you can do that. You'll be able to access it through the port you set up last step. If not, you can access it from your IP.

If you wish to access it from your IP, then you're already all set. If not, read on.

First, you'll need to figure out what your IP is. Try going to DomainTool's IP Checker
If you have an existing hosting account, you can use a domain that's on that account to access your home's apache. These instructions are if your host uses cPanel, and if you have a WHM account, otherwise, you'll have to search for DNS settings. If you're looking for a good cPanel host, I'd recomend ASO Hosting. In WHM, go to the DNS Functions category, and click on add a DNS zone. Put in your IP, and type any subdomain of a domain you have on that account.
Now, once the software is installed, you'll be able to access everything from that subdomain, using the port that you've chosen.

Alternatively, you can use FreeDNS or other DNS services.

Step 4: Get the Software

Download xampp from Apache friends.
Install it normally, and make sure to check off "Install Apache as service", and "Install MySQL as service"

When they're installed as a service, it saves you from using their control panel, and the 2 are on by default.

Make sure to allow connections through every firewall, and windows security center.

Step 5: Configure Apache

Apache now has to be configured so the web root directory is in My Documents, and it can be accessed through the appropriate port.

Start by going into your My Documents folder, and creating a new folder. Name it whatever you want. I choose web root, but there's always "www", or "public_html" if you want something different.
Open the folder, and click on the location address bar thing at the top. It should give you a definite location, for example, mine is C:\Web Root
Now, click out of there, and go up one folder. Right click on the folder you just created, and go into properties. Go into Security, then edit, then click add. Type in Everyone in the box, and press ok. Now, check off full control for Everyone, and press ok.

You'll want to copy this. Now, go to your xampp installation directory, go to apache, then go to conf.
Open httpd.conf in notepad, and find "Listen 80", (Without quotes) And add another line below that, saying Listen followed by the port number you chose in step 2.
Next, look for "DocumentRoot" (Without quotes). Delete what's in the quotes, then paste your location in them. You'll need to change any slashes to back slashes (\ should be changed to /)
Lastly, look for "<Directory "C:/xampp/htdocs">", substitute your install directory for c:/xampp
It should be around line 204. Replace what's in the quotes with your directory, once again, switching the slashes.

Now save the file.

Step 6: Restart Your Computer, and Enjoy!

Restart your computer

You can now access your server in several ways
http://localhost/ (Local PC only)
http://computer name (Local network only)
http://your local ip (Local network only)
http://your external ip : yourport
http://your domain : yourport

I had to use bold, otherwise instructables automatically makes it a link.
You can use php, and mysql in any file that you put in the web root folder.
<p>I like to design a website but i dont know how to do.. so i tried using wordpress my website: <a href="http://www.millionaire-matchdating.com/millionaire-match" rel="nofollow">MillionaireMatch</a></p>
I like phppgadmin for managing postresql databases also. Alittle talk about certificates or a link would have been nice.
I have a question that would probably be quite easy for you to answer...<br /> <br /> I just want to be able to access my database using any of the computer on my local network, yet I&nbsp;seem to be having some difficulty in doing that. Currently, I&nbsp;have the server and database working perfectly on my computer, and am easily able to access it through <a href="http://localhost" rel="nofollow">http://localhost</a>. How can I&nbsp;allow local machines to access it as well?
Depending on the router, you can put your hostnames and ipaddresses in your router to let it act like a local dns server. Worst case scenario, you can put the hostnames and ipaddresses (s/b static) in your hosts file. Thatis what I do till I have time to set up something fancier.
&nbsp;Local machines should be able to see it through your local ip address, or your computer name. &nbsp;To check your local IP, just do an ipconfig.&nbsp;
cvxdes, iahev run into a dilema. I have been running a forum site from my home server, and I have that site running because of the apache built in to xampp. I was wondering how I would set up my server so that it can host the site and being able to send emails because when you try to send emails through the forums, it won't send because I don't have a mail server. also, I'm hoping i can keep all this on one computer/server becuase that is all I have room for. I tried using the Mercury mail server built into xampp, but it then messed up my apache server, and was showing some weird mercury mail page instead of my site.
You need to configure PHP with a mail server. It's in php.ini, somewhere.
Depends on what platform you have and tt is not just a php file mod. I do not know about mswindows, but on linux postfix is the usual candidate. Add dovecot for imap/pop3 support, and then squirrelmail if you want a web interface.
yeah, i have messed with php.ini already, and even tried using my isp's mail server, but it still doesn't work. and the fact that xampp only provides a fake sendmail doesn't help either, lol.
Mentioning how to set password access with .htaccess and the command to ask spiders not to index your site would be a nice additive to this instructable. Well done.
Hey... really nice Instructable. Thank you. Just a thought. The speed of a Name Server update is influenced only by the TTL setting on your domain name set up In theory. Another thought is firewalls. You guys may have to make a hole in your Firewall, if you are running one. My other thought, is JSAS. I use a product called JSAS Joomla Stand Alone Server. It is a 2 click install with no configuration necessary. This allows you to use Joomla which is a wonderful web environment - a database driven web portal. It provided both versions of Joomla within the app. It has PHP, MySql Apache and Joomla built in, but you dont need to go under the bonnet. It can also run any web site or web based app you want. I love it and use it at work. (I'm a Webby) The info you provided will help people a lot. Well Done !
A very good instructable! = )<br/>Just one question:<br/><br/><strong>http://your external ip : yourport</strong><br/><strong>http://your domain : yourport</strong><br/><br/>means that I could go to my friend's house or my school and view my website from there off my home server right?<br/><br/>If so, then congratulations, you found the solution I've been looking for when it comes to hosting my own websites for free.<br/>You can see that I made an attempt at this a few months ago when I wrote an article on the Apache softare. Just type in <strong>Apache</strong> in the search bar of Instructables if you feel like taking a look at what I wrote. Unfortunately, I could only see my website on my local network at home, not anywhere else.<br/><br/>Once again, thank you for providing us with valuable information! = )<br/><br/><em>Scriptking1</em><br/>
Yes. You'll have to port forward port 80, and you'll need need to get an account at a free DNS site. Or if you can remember your ip.. then you can just go to that. If you want any help with it, send me a message. I can help you out on msn or aim.
Ok, thank you!<br/>That is so cool! = )<br/>Finally I can host my own website.<br/>Thanks. I'll PM you my Hotmail account if I need help. Although I'll have to wait until June when I get my computer privilages back from my parents.<br/><br/><em>Scriptking1</em><br/>
Cool. I was going to do one of these for a series of PHP tutorials that I have planned. With XAMPP you don't need to configure your card and router unless you want to access it from other computers or the Internet.

About This Instructable

16,914views

24favorites

License:

More by cvxdes:How to install a web development enviornment on localhost How to hide a key, effectivley Pneumatic Snowball Cannon 
Add instructable to: