2

I am trying to set up a virtual host so that I can run my .php file from Eclipse as a web page.

I follow the instructions from this discussion:

Make XAMPP/Apache serve file outside of htdocs

Scroll down to virtual hosts and the instruction is basically

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
    ServerName firstEclipseProject.localhost
    ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
    <Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
        Order allow,deny
        Allow from all
    </Directory>    
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf

Then I change the hosts file at /private/etc/hosts and at the bottom, I added

127.0.0.1 firstEclipseProject.localhost #firstEclipseProject

So, I think I am doing it right up to this point because when I fire my browser and point to firsteclipseproject.localhost, it redirects me to

firsteclipseproject.localhost/XAMPP/ 

which is the main XAMPP web page. It does not return an object/page not found which means the redirecting is somewhat working.

So, in /Users/Oky/Documents/eclipse/firstEclipseProject/ I created a php file called HelloWorld.php but when I point to firsteclipseproject.localhost/HelloWorld.php, it says object not found! I also tried firsteclipseproject.localhost/XAMPP/HelloWorld.php and it fails.

Any help is appreciated! Thanks!!!

Community
  • 1
  • 1
oky_sabeni
  • 7,672
  • 15
  • 65
  • 89

2 Answers2

0

I would suggest you leave the root directory the way it is and instead setup an Alias to your eclipse directory.

Eric Coffin
  • 156
  • 4
  • 1
    "This can be helpful if you're trying to replicate a production environment where you're developing a site that will sit on the root of a domain name. You can, for example, point to files with absolute paths that will carry over to the server: whereas in an environment using aliases or subdirectories, you'd need keep track of exactly where the "images" directory was relative to the current file." Thanks for the suggestion but I am trying to avoid aliases and simulate it like it is in production environment – oky_sabeni Feb 01 '11 at 15:04
0

Did you restart apache after making config changes?

Maerlyn
  • 33,687
  • 18
  • 94
  • 85