4

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?

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
Kintamasis
  • 265
  • 6
  • 27
  • 1
    When you set site URL to http://test.wp:8080/ and it works, then you must have server running on port 8080. Verify at what port does the server runs. Then change it accordingly. Another thing, does the test.wp is the folder under which all the wordpress files resided, or there is another subfolder. – Sagar Bahadur Tamang Jun 15 '20 at 03:19
  • Give your local ip instead of the * in – Akshay Shah Jun 16 '20 at 04:45
  • @SagarBahadurTamang on XAMPP ports - localhost:8080 -> 80 (Over SSH) is enabled. What ports should be enabled? And yes in test.wp folder all wordpress files. – Kintamasis Jun 16 '20 at 17:33
  • @AShah if I write ip instead of * - webpage is not opening at all – Kintamasis Jun 16 '20 at 17:40
  • Looks like the XAMPP is listening on 8080, and 80 (default http port) is served by another server. Is it possible that another webserver (like Apache) is listening on your localhosts' port 80? – ΔO 'delta zero' Jun 21 '20 at 14:20

1 Answers1

1

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:

  1. Your WordPress project should reside within your /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
  1. Apache listens on port 80 only (for your required purpose) with your virtual host configuration as shared in your post above.

  2. Check your Apache configuration files (default and specifics alike) and comment all virtual host configurations you do not need.

  3. Define your WordPress siteurl and home URLs as http://test.wp.

  4. Edit your hosts file as illustrated below;

127.0.0.1       localhost
127.0.0.1       test.wp
nyedidikeke
  • 6,899
  • 7
  • 44
  • 59