Mobile app version of vmapp.org
Login or Join
Smith883

: Accessing a development LAMP server as if it were the live server by faking the URL At the moment I have my test server set-up like so http://localhost/~callum but I want to set-up a fake

@Smith883

Posted in: #Configuration #Development #Lamp #Url #Webserver

At the moment I have my test server set-up like so localhost/~callum but I want to set-up a fake url so I can link javascripts and CSS files from my PHP files. Hope this makes sense any help is much a appreciated.
I should also say I am using a public_html folder and not var/www.

EDIT: What I mean by fake url is that I want to turn my url from localhost/~callum to something like this callumstestwebsite.com/ without owning the domain so that I can continue to develop on my new laptop, I used to use windows 7 so I am getting used to ubuntu.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Smith883

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

To be able to access a local resource as if it were the main site you need to do two things:


Edit your hosts file such that your computer thinks that your domain name is served by localhost. Your hosts file should contain a line with 127.0.0.1 in it and your host name would need to be added to that line, something like: 127.0.0.1 localhost callumstestwebsite.com Use the command line sudo editor /etc/hosts to edit this file.
Configure your webserver to serve the website when a request is made for that host name. It appears that you are currently serving the site only when there is a path of /~callum but you would need to configure the webserver differently. Generally this would entail adding a virtualhost directive something like (for apache server in httpd.conf):




<VirtualHost *:80>
DocumentRoot /home/callum/public_html
ServerName callumstestwebsite.com
</VirtualHost>


In my Debian based distribution I would create a file called /etc/apache2/sites-available/callumstestwebsite with that contents (and any other needed configuration), then enable the site with the command: sudo a2ensite callumstestwebsite, then restart my webserver with sudo service apache2 restart

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme