Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache virtual host 404 not found

I just started learning php and I am trying to host locally my own php website by using XAMPP.

I wanted to create virtual host with:

URL: myphpwebsite.local

Port: 8088

But when I attempted to access this website through the browser I got a:

Not Found HTTP Error 404. The requested resource is not found.

Does anyone know what the problem is?

My httpd-vhosts.conf

NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
  DocumentRoot "C:/xampp/htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost myphpwebsite.local>
    DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
    ServerName myphpwebsite.local
    ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
    CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined

   <Directory "C:/Microsoft/Workspace/myphpwebsite">
    Order allow,deny
    Allow from all
   </Directory>
</VirtualHost>

And my C:\Windows\System32\drivers\etc\hosts file:

127.0.0.1       localhost
127.0.0.1 myphpwebsite.local

Any help would be appreciated!

like image 812
Axvil Avatar asked Jul 26 '26 21:07

Axvil


2 Answers

  1. make sure there's file/htaccess/index or whatever in directory you want to open, 404 may comes from that ;)

  2. try using one below, eventually replace your port:

     <VirtualHost *:80>
         DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
         ServerName myphpwebsite.local
      </VirtualHost>
    
  3. the question is your Apache running/serving on port 8088? For example my xamp is running on 80 and 443...

  4. xamp control panel is very handy, it has nice logs button that will open your log files to show you php and apache errors etc. check it out.

Try going with default port, if it works it means that you need to play with ports if you really want to.

just a quick tip, .com is shorter than .local and if you're using chrome and it works like mine then most of the time something.local will redirect you to google search (and I like my search there, you can switch it off ;))

like image 62
Tom St Avatar answered Jul 28 '26 12:07

Tom St


I don't know if I am much help, but using WAMP, here are my settings. I am listening on port 80, I use 8080 for my tomcat server.

hosts file

127.0.0.1  local.mysite.com

httpd-vhosts.conf

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

....

<Directory "c:/wamp/www">
    Options Indexes MultiViews FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "c:/wamp/www"
</VirtualHost>

<Directory "c:/wamp/www/path/to/site/root">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<VirtualHost *:80>
    ServerName local.mysite.com
    DocumentRoot "c:/wamp/www/path/to/site/root"

    ServerAdmin [email protected]

    ProxyPreserveHost Off
    RewriteEngine On
    AllowEncodedSlashes NoDecode
    #AllowEncodedSlashes On

    ErrorLog "c:/wamp/www/path/to/logs/error.log"
    CustomLog "c:/wamp/www/path/to/logs/access.log" common
</VirtualHost>

....

Then I can access my local site like this: http://local.mysite.com

Hope this helps...

like image 44
Damon Avatar answered Jul 28 '26 11:07

Damon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!