Apache windows create new server
Here's a step-by-step guide to creating a new Apache server on Windows:
Prerequisites:
- Windows 10 or later (64-bit)
- Apache HTTP Server 2.4 or later
- A text editor (e.g., Notepad++, Sublime Text)
Step 1: Download and Install Apache
- Go to the Apache HTTP Server download page and download the Windows version of Apache.
- Run the installer (e.g.,
Apache24-win64-x64.msi
) and follow the installation wizard. - Choose the installation location (e.g.,
C:\Apache24
) and select the components you want to install (e.g., HTTP Server, SSL/TLS Support).
Step 2: Configure Apache
- Open a text editor and create a new file called
httpd.conf
in the Apache installation directory (e.g.,C:\Apache24\conf
). - Copy the following code into the file:
# Apache configuration file
ServerName directive sets the hostname and port that the server uses
to identify itself. This can be presented to a client in response
to their HTTP request.
ServerName localhost:80
DocumentRoot directive sets the directory from which web pages
are served.
DocumentRoot "C:/Apache24/htdocs"
AllowOverride directive allows.htaccess files to override
settings in this file.
AllowOverride None
Options directive sets the options for the directory.
Options Indexes FollowSymLinks
ErrorLog directive sets the location of the error log file.
ErrorLog "logs/error.log"
CustomLog directive sets the location of the access log file.
CustomLog "logs/access.log" common
3. Save the file.
**Step 3: Create a Virtual Host**
1. Create a new file called `virtualhosts.conf` in the Apache configuration directory (e.g., `C:\Apache24\conf`).
2. Copy the following code into the file:
```bash
# Virtual hosts configuration file
<VirtualHost *:80>
ServerName example.com
DocumentRoot "C:/Apache24/htdocs/example"
</VirtualHost>
Replace example.com
with your desired domain name and C:/Apache24/htdocs/example
with the directory where your website files will be stored.
Step 4: Start Apache
- Open a Command Prompt or PowerShell as an administrator.
- Navigate to the Apache installation directory (e.g.,
C:\Apache24
). - Run the following command to start Apache:
httpd.exe
- Apache should start and you should see a message indicating that it's running.
Step 5: Test Apache
- Open a web browser and navigate to
http://localhost
orhttp://example.com
(if you created a virtual host). - You should see the Apache default page or your website's index page.
That's it! You've successfully created a new Apache server on Windows.