Use Apache Webserver to Host a Website on Your PC: Step-by-Step

Download Article
An in-depth guide to hosting a website using Apache Webserver
Download Article

If you want to host a website on your Windows PC, the Apache webserver makes it easy. While the Apache Project used to offer a Windows installer, they don't anymore. Fortunately, you can still install Apache easily by downloading the binaries from ApacheHaus. It even comes with OpenSSL, which you'll want to set up so people can visit your website securely with HTTPS. This article will teach you how to download, install, and configure Apache webserver on your Windows computer to host a webpage on your computer.

Things You Should Know

  • You can download Apache with OpenSSL from https://www.apachehaus.com/cgi-bin/download.plx.
  • To install, copy the Apache24 folder to the root of your C drive, then run C:\Apache24\bin\httpd -k install at the command prompt.
  • Once installed, you can start the Apache service and edit the httpd.conf file for your website.
Part 1
Part 1 of 3:

Installing

Download Article
  1. How.com.vn English: Step 1 Download the latest Apache binaries from Apache Haus.
    The official Apache website (https://www.apache.org/) only offers source code to download. You can use a compiled version of Apache with OpenSSL support to avoid dealing with source code.[1]
  2. How.com.vn English: Step 2 Extract the files.
    Unzip the file you downloaded from Apache Haus. This extracts a folder that begins with "httpd-2.4.55" to the current folder.
    • Inside the extracted folder, you'll find a subfolder called "Apache24," which contains the complete directory structure for your Apache installation.
    Advertisement
  3. Step 3 Copy the "Apache24" folder to the root of your C drive.
    In File Explorer, right-click the Apache24 folder and select Copy (or press Ctrl + C). Then, click This PC in the left panel, right-click the C drive, then select Paste.
    • You'll want to make sure Apache is in the root of your C drive to avoid errors. The installation directory should be C:\Apache24.
  4. How.com.vn English: Step 4 Open Command Prompt as an administrator.
    To do this, type cmd into the Windows Search bar, right-click Command Prompt, and then select Run as administrator.
  5. How.com.vn English: Step 5 Enter the binary directory.
    To do this:
    • Type cd and press the spacebar.
    • Type C:\Apache24\bin.
    • Press Enter.
  6. How.com.vn English: Step 6 Type httpd -k install and press ↵ Enter.
    After a moment, you should see a pop-up message saying that Windows firewall has blocked some features of the app.[2]
  7. How.com.vn English: Step 7 Allow Apache through the firewall.
    Check the boxes next to "Private" and "Public" networks, then click Allow access to continue. Once allowed, Apache will be installed.
    • You will see errors in the command prompt window once Apache is installed. This is just because the webserver isn’t configured for your website yet.
  8. How.com.vn English: Step 8 Start the Apache web service.
    You have two options:
    • To start Apache from Command Prompt, type httpd and press Enter.
      • To stop Apache, use httpd -k shutdown.
      • To restart Apache, use httpd -k restart.
    • Alternatively, you can use the Services panel. Type services.msc into the Windows search bar and press Enter. Then, right-click Apache2.4 and select Start.
      • To stop Apache, right-click Apache2.4 and select Stop.
      • To restart, select Restart.
      • If you want Apache to launch automatically at reboot, right-click Apache2.4, select Properties, and set "Startup type" to Automatic.
  9. How.com.vn English: Step 9 Test the installation.
    In your web browser, go to http://127.0.0.1:80 to ensure Apache is up and running.
  10. Advertisement
Part 2
Part 2 of 3:

Configuring

Download Article
  1. How.com.vn English: Step 1 Place your website files in the htdocs folder.
    By default, Apache uses the path C:\Apache24\htdocs as the source for your website files. Before your website goes live, make sure your HTML files are in that folder.
    • There's a sample index.html in that folder already—the test site you saw when you went to http://127.0.0.1:80. Overwriting that file with your own index.html will automatically replace the homepage with your own.
  2. How.com.vn English: Step 2 Open your httpd configuration file for editing.
    To configure Apache for your website, you'll need to edit the file called httpd.conf, which is in C:\Apache24\conf.
    • Go to C:\Apache24\conf in File Explorer.
    • Right-click httpd.conf.
    • Select Open with > Notepad.
  3. Step 3 Enter your IP address or hostname next to "ServerName."
    While Apache may be able to determine this information automatically, it's best to specify which hostname or IP address people will be using to access your website.
    • Scroll to the "ServerName" field. You can find it quickly by pressing Ctrl + F and searching for "ServerName."
    • If you've registered a domain name that's pointing to your computer's IP address, you'll want to enter that next to ServerName before the ":80." For example: ServerName www.wikihow.com:80.
      • If you're going to run Apache on a different port, replace "80" with your preferred port number.
    • If you don't have a registered hostname, enter your computer's IP address instead. Keep in mind that you'll need to use your public IP address if you want people outside of your network to be able to access your self-hosted website.
    • If you don't have a static IP address, you'll need to update httpd.conf every time your IP address changes. Because of this, you should only host a website on your computer if you have a static IP address.
  4. How.com.vn English: Step 4 Change the listening port (optional).
    If you want to allow people outside of your network to access your website, you may find that your ISP blocks traffic to port 80 (the default HTTP port) by default. To get around this, you can run Apache on a different port, such as port 8080. In this case, visitors to your site must add :8080 to the end of the URL to reach your website.
    • Press Ctrl + F and search for "Listen."
    • Below "Listen 80," add a new line that says Listen 8080 (or your preferred port.
    • If you don't want your website to be accessible on port 80, you can comment on the "Listen 80" line by adding a hash (#) before it or deleting it entirely.
    • If you designate another port, make sure you allow it through your firewall.
  5. How.com.vn English: Step 5 Save your changes and restart Apache.
    Click the File menu and select Save to save your changes. Any time you make changes to httpd.conf, you'll need to restart Apache. There are two ways to do this:
    • Command Prompt: Type httpd -k restart and press Enter.
    • Services.msc: Right-click the Apache2.4 service and select Restart.
  6. Advertisement
Part 3
Part 3 of 3:

Setting Up SSL

Download Article
  1. How.com.vn English: Step 1 Request an SSL certificate.
    If you want visitors to your website to be able to connect securely with SSL (https), you'll need to install an SSL certificate. The first thing you'll need to do is use the built-in OpenSSL tool to create a certificate request, which you can then submit to a certificate authority like DigiCert or Comodo.
    • Open Command Prompt, type cd C:\Apache24\bin, and press Enter.
    • Type or paste this command and press Enter, replacing "server.key" and "server.csr" with the name of your server (e.g., wikihow.key and wikihow.csr: openssl req -new -newkey rsa:2048 –sha256 -nodes -keyout server.key -out server.csr.
    • When prompted for the "Common name" or FQDN, enter your full hostname (e.g., myserver.wikihow.com).
    • When prompted to enter a challenge phrase, leave it blank.
    • Follow the prompts to enter information for your certificate, including your 2-letter country code, other region info, and your email address. This creates two new files in the bin folder—server.csr and server.key (with your server's name replacing server).
  2. How.com.vn English: Step 2 Submit your certificate request to a certificate authority (CA).
    Each authority has a different submission process, but you'll usually need to make an account and paste in your request key.
    • Right-click the server.csr file and select Open with > Notepad.
    • Copy everything inside the file by selecting it and pressing Ctrl + C.
    • Go to your preferred SSL certificate authority's submission page and paste the copied text to submit your request. When your certificate is ready, you'll receive two files via email, both ending with .crt.[3]
    • Copy the file called server.key to C:\Apache24\conf.
  3. How.com.vn English: Step 3 Copy your certificate files to the Apache24\conf folder.
    Once you receive the certificate files from your certificate authority, both ending with .crt, copy or unzip them to C:\Apache24\conf.
  4. How.com.vn English: Step 4 Open the SSL configuration file for editing.
    To do this, navigate to C:\Apache24\conf\extra, right-click httpd-ssl.conf, and select Open with > Notepad.
  5. How.com.vn English: Step 5 Update the virtual host information.
    Scroll to the "SSL Virtual Host Context" section of the file, where you'll see a "General setup for the virtual host" configuration. Replace the value of ServerName with the hostname for your website, leaving :443 intact. Also, replace the ServerAdmin value with your IP address.
  6. How.com.vn English: Step 6 Replace the sample file names with your certificate file names.
    • Replace the value of "SSLCertificateFile" with the name of the .crt file sent by the CA (the one that begins with your domain name).
    • For example, SSLCertificateFile "${SRVROOT}/conf/server.crt"
    • Replace the "SSLCetificateKeyFile" value with the name of the .key file you generated earlier.
    • You'll also need to add another directive for SSLCertificateChainFile if not present for the other .crt file sent by the CA. For example, SSLCertificateChainFile "${SRVROOT}/conf/cabundle.crt.
    • Save the file.
  7. How.com.vn English: Step 7 ...
    Restart Apache. Once Apache restarts, your certificate will be installed. You should now be able to access your site by typing https://, followed by your hostname.
    • If needed, make sure you've opened port 443 in your firewall to allow HTTPS connections.
  8. Advertisement

Community Q&A

Search
Add New Question
  • Question
    How do I add it on the internet?
    How.com.vn English: Community Answer
    Community Answer
    Port-forward port 80 on your router to your PC, get a free domain at no-ip.com, and link the domain to your IP.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      • If you mess up the httpd.conf file, don't worry—there's a backup version in C:\Apache24\conf\original. Just delete your current httpd.conf and replace it with the one in that location.
      • To uninstall Apache, run httpd.exe -k uninstall in Command Prompt.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      How.com.vn English: Nicole Levine, MFA
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for How.com.vn. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 350,238 times.
      How helpful is this?
      Co-authors: 26
      Updated: October 9, 2023
      Views: 350,238
      Thanks to all authors for creating a page that has been read 350,238 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement