This minHour teaches you how to host a website on your own home network. You'll use a free program called MAMP to do so.
Preparing to Host a Website
Make sure your Internet Service Provider permits hosting.
While small-time local hosting is usually fine regardless of your Internet Service Provider’s policy, creating a website that has a significant amount of traffic from other networks may go against your ISP’s terms of use.
- In most cases, you can upgrade your Internet plan to a “Business” (or similar) account in order to enable support for larger-scale hosting.
Create your website’s source code if necessary.
If you don’t have a website document that you can use for your home page, you’ll need to create one.
Install a text editor that can handle PHP documents.
Depending on whether you use a Windows computer or a Mac, this will vary:
- Windows — Notepad++ is your best bet.
- Mac — You can download a free text editor called “BBEdit” by going to https://www.barebones.com/products/bbedit/ and clicking Free Download on the right side of the page.
Installing MAMP
Open the MAMP website.
Go to https://www.mamp.info/en/downloads/ in your computer’s web browser.
- Make sure you’re doing this on the computer on which you want to host your server.
Select a download option.
Click either for the Windows version of MAMP or for the Mac version of MAMP. The MAMP setup file will begin downloading.
- You may have to confirm the download or select a save location before the file will download.
Wait for MAMP to finish downloading.
Once the MAMP setup file has downloaded onto your computer, you can continue.
Double-click the MAMP setup file.
Doing so will open the installation window.
- On a Mac, this is a PKG file.
Follow the on-screen installation instructions.
These will mostly vary depending on your computer’s operating system, but make sure to de-select the “Install MAMP PRO” box if it’s checked during the installation process.
Wait for MAMP to finish installing.
Once MAMP has finished installing, you can proceed with configuring it.
Configuring MAMP
Open MAMP.
Click or double-click the grey elephant app icon to do so. You should see the MAMP dashboard window appear.
- On a Mac, you can find the MAMP app icon inside the Applications folder.
Click Use next free port when prompted.
This will allow MAMP to skip using port 80 in favor of using the next free port.
- In virtually all cases, MAMP will use port 81 if port 80 isn’t free.
Click Yes when prompted.
Doing so will allow MAMP to use its selected port.
Confirm any Firewall requests.
If you’re on a Windows computer, Firewall will ask for permission to let both Apache and MySQL through. Click on both prompts before you proceed.
- Skip this step on a Mac.
Uploading Your Website
Copy your website’s source code.
Open the document containing your website’s source code, highlight the document’s text, and press Ctrl+C (Windows) or ⌘ Command+C (Mac).
Click Preferences….
It’s on the left side of the MAMP window. Doing so opens a pop-up window.
Click the Web Server tab.
This option is at the top of the pop-up window.
Click Open.
It’s in the middle of the window. Doing so opens your MAMP “htdocs” folder.
- On a Mac, click the folder-shaped icon to the right of the “Document Root” heading.
Open the “index.php” file.
Right-click the “index.php” file, then click in the resulting drop-down menu.
- On a Mac, click once the “index.php” file, click File, select Open With, and click the BBEdit option. If this doesn’t work, open BBEdit, then drag the “index.php” file into its window.
Replace the “index.php” file’s contents with your source code.
Press either Ctrl+A (Windows) or ⌘ Command+A (Mac) to select all of the text in the “index.php” document, then press Ctrl+V or ⌘ Command+V to paste in your copied website source code.
Save the document.
Press Ctrl+S (Windows) or ⌘ Command+S (Mac) to do so.
Close the document and its host folder.
This should take you back to the MAMP “Preferences” pop-up window.
Click OK.
It’s at the bottom of the window. Doing so will save your settings and close the pop-up window.
Accessing Your Website
Click Start Servers.
It’s on the right side of the window.
Click Open start page.
You’ll find this option on the left side of the window. The MAMP start page will open in your default web browser.
Click the My Website tab.
It’s at the top of the page. Doing so opens your website.
Review your website.
Scroll through your website to view it in its entirety.
Check your website’s address.
You can find the website’s address in the address bar at the top of the browser; your website’s address should be something like “localhost:81”. This is the address you’ll enter to access your website when you’re on your current network while MAMP is running.
Viewing Your Website from Another Computer
Make sure your website is live.
In order for you to be able to access your website, you’ll need to have MAMP up and running on your host computer.
- You cannot connect to your website if MAMP (or your host computer) is turned off.
Set a static IP address for your host computer.
A static IP address will ensure that your computer’s IP address doesn’t change, thus making sure that your website’s address remains consistent:
- Open your router’s page.
- Log in if necessary.
- Find the list of currently connected computers.
- Find your computer’s name.
- Select the Reserve or Lock option next to your computer’s IP address.
Forward MAMP’s “Apache” port on your router
This will involve opening your router’s “Port Forwarding” section, adding the port you used for Apache when configuring MAMP, and saving your settings.
- You can see the port Apache uses by clicking Preferences… in the MAMP dashboard, clicking the Ports tab, and looking at the number next to the “Apache” heading.
Find your host computer’s public IP address.
The easiest way to do this is by opening Google, typing in what is my ip, and pressing ↵ Enter. You should see your computer’s public IP address at the top of the search results.
Use a computer on a different network.
To prevent conflicts between your network’s local host and the public IP address, try connecting to your website using a different computer than your host computer on a different network.
Go to your website.
Using a computer on a different network, open a web browser, type in the public IP address of the host computer, type a colon (:), type the Apache port number, and press ↵ Enter. This should take you to the website.
- For example, if the host computer’s public IP address is “123.456.78.901” and you’re using port 81 for Apache, you’d type in 123.456.78.901:81 and press .
Tips
- It’s best to use an older computer to host your server.
- If possible, connect your host computer to your router via an Ethernet cable.
Warnings
- Avoid hosting a server on network connections with significant bandwidth limits.