In this article, we are going to show you how to host a website on your home computer. To do this, you need the free MAMP program.
Part 1 of 6: How to Prepare to Host a Site
Step 1. Make sure your ISP allows hosting sites
Most likely, nothing will happen if the site is visited by few users, but more traffic may violate the rules of the ISP.
In most cases, the tariff plan can be upgraded to corporate (or similar), which includes hosting with high traffic
Step 2. Write the source code of the site
Create code if you haven't already.
Step 3. Install a text editor that supports PHP files
The choice of editor depends on the operating system:
- Windows - use Notepad ++.
- Mac - Download the free text editor BBEdit; to do this, go to https://www.barebones.com/products/bbedit/ and click “Free Download” on the right.
Part 2 of 6: How to Install MAMP
Step 1. Open the MAMP website
Go to https://www.mamp.info/en/downloads/ in your computer's web browser.
Do this on the computer where you want to host the server
Step 2. Download the installation file
To do this, click “MAMP & MAMP PRO 4.0.1” (for Windows) or “MAMP & MAMP PRO 5.0.1” (for Mac).
You may need to confirm the download first or select a download folder
Step 3. Wait for the installation file to download to your computer
When this happens, move on to the next step.
Step 4. Double click on the downloaded file
The MAMP installer window will open.
On your Mac, click the downloaded PKG file
Step 5. Follow the instructions on the screen
These depend on the operating system of your computer, but be sure to uncheck “Install MAMP PRO” if this option appears in the installer window.
Step 6. Wait for MAMP to install
Now configure this program.
Part 3 of 6: How to set up MAMP
Step 1. Start MAMP
To do this, click or double-click on the white elephant icon on a gray background. The MAMP toolbar will open.
On a Mac, this icon is located in the Applications folder
Step 2. Click Use next free port when prompted
In this case MAMP will skip port 80 and find another free port.
In most cases MAMP will use port 81 if port 80 is busy
Step 3. Click Yes when prompted
MAMP will start using the selected port.
Step 4. Answer affirmatively to any requests from the firewall
On a Windows machine, the firewall will prompt you to allow Apache and MySQL network access. Click "Allow" on both prompts.
Skip this step on a Mac
Part 4 of 6: How to Upload Your Site
Step 1. Copy the source code of your site
Open your site code document, select the text, and press Ctrl + C (Windows) or ⌘ Command + C (Mac).
Step 2. Click on Preferences
It's an option on the left pane of the MAMP window. A pop-up window will open.
Step 3. Click the Web Server tab
It's near the top of the pop-up window.
Step 4. Click Open
It's an option in the middle of the window. The "htdocs" folder will open.
On a Mac, click the folder-shaped icon to the right of Document Root
Step 5. Open the "index.php" file
Right click on the "index.php" file and select "Edit with Notepad ++" from the menu.
On a Mac, click the index.php file, click File, choose Open With, and click BBEdit. If that doesn't work, launch BBEdit and drag the "index.php" file into this editor window
Step 6. Replace the contents of the "index.php" file with the copied source code
Press Ctrl + A (Windows) or ⌘ Command + A (Mac) to select the entire contents of the “index.php” file, and then press Ctrl + V or ⌘ Command + V to paste the website code.
Step 7. Save the document
To do this, press Ctrl + S (Windows) or ⌘ Command + S (Mac).
Step 8. Close the document and folder
You will be returned to the MAMP settings window.
Step 9. Click on OK
It's a button at the bottom of the window. The settings are saved and the pop-up window closes.
Part 5 of 6: How to open your website
Step 1. Click Start Servers
It's an option in the right pane of the window.
Step 2. Click on Open start page
You will find this option on the left side of the window. The MAMP start page will open in your main web browser.
Step 3. Click on the My Website tab
It's an option at the top of the page. Your site will open.
Step 4. Browse your site
To do this, scroll it completely.
Step 5. Find your website address
It's in the address bar at the top of your browser; your site address should be something like "localhost: 81". This is the address you enter to access your website when the computer is connected to the current network and when MAMP is running.
Part 6 of 6: How to open a website on another computer
Step 1. Make sure your site is working
To open the site from any computer, you must have MAMP running on your computer.
You will not be able to open the site if MAMP or your computer is not working
Step 2. Assign a static IP address to your computer
In this case, the IP-address will not change, and therefore the address of your site will not change:
- Open the router's configuration page.
- Enter credentials if required.
- Find a list of computers connected to the network.
- Find your computer name.
- Select the "Reserve" or "Lock" option next to the IP address of your computer.
Step 3. Forward the Apache port on the router
To do this, open the Port Forwarding section of the router configuration page, add the port you used for Apache when configuring MAMP, and then save your changes.
To find out which port Apache is using, click Preferences in the MAMP toolbar, go to the Ports tab and look at the number on the Apache line
Step 4. Find out the public IP address of your computer
To do this, open Yandex, enter my ip and press ↵ Enter. Your computer's public IP address appears above the search results.
Step 5. Go to a computer that is connected to a different network
To prevent conflicts between the local host of your network and the public IP address, try opening your website on a different computer that is connected to a different network.
Step 6. Open your site
On the other computer, launch a web browser, enter the public IP address of your computer, enter a colon (:), enter the Apache port number, and then press ↵ Enter. Your site should open.
For example, if your computer's public IP is 123.456.78.901 and your Apache port number is 81, enter 123.456.78.901:81 and press ↵ Enter
- It is better to place your server on an old computer.
- If possible, connect your computer to the router using an Ethernet cable.