I'm having a challenge with Apache virtual host configuration on MAC.
For my setup, I've added 127.0.0.1 test.wp
to my /private/etc/host
file and included it by uncommenting the Include etc/extra/httpd-vhosts.conf
line in the lampp/etc/httpd.conf
file.
I've also edited my lampp/etc/extra/httpd-vhost.conf
file with the virtual host configuration below;
<VirtualHost *:80>
ServerName test.wp
DocumentRoot "/opt/lampp/htdocs/test.wp"
<Directory "/opt/lampp/htdocs/test.wp">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
When I visit http://test.wp
when siteurl
and home
are both defined as http://test.wp
I see It works!
instead of the WordPress site.
On the other hand, when I define both siteurl
and home
as http://test.wp:8080
, I'm able to access the WordPress site at that address.
How can I serve WordPress site at http://test.wp
on the default port 80?
TL; DR
The DocumentRoot
of a Apache virtual host listening on port 80
is pointing to a directory where the It works!
content is served (most likely in your default Apache configuration).
You may want to locate and edit it to map onto the directory of your WordPress site.
Alternatively, you may comment it and define your own virtual host in a dedicated configuration file then include it your main httpd.conf
file.
You need to ensure the following:
/opt/lampp/htdocs/test.wp
directory.The snippet below illustrates the requirement above;
# Content of your /opt/lampp/htdocs/test.wp directory
/opt/lampp/htdocs/test.wp/
├── wp-admin/
│ └── [wp-admin directory contents]
├── wp-content/
│ └── [wp-content directory contents]
├── wp-includes/
│ └── [wp-includes directory contents]
├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-cron.php
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php
Apache listens on port 80
only (for your required purpose) with your virtual host configuration as shared in your post above.
Check your Apache configuration files (default and specifics alike) and comment all virtual host configurations you do not need.
Define your WordPress siteurl
and home
URLs as http://test.wp
.
Edit your hosts file as illustrated below;
127.0.0.1 localhost
127.0.0.1 test.wp