1

At the moment I have my test server set-up like so http://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 http://localhost/~callum to something like this http://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.

3
  • What do you think a 'fake' URL would look like? Commented Sep 25, 2013 at 7:50
  • Presumably you want to setup a URL like http://example.com in local DNS?
    – MrWhite
    Commented Sep 25, 2013 at 7:58
  • What I mean by 'fake_url' is that I want to turn my domain to something like www.callumstestwebsite.com/ instead of localhost/~callum so that I can link my css and JavaScript files. Sorry for not posting sooner I was at school.
    – Callum
    Commented Sep 25, 2013 at 14:20

1 Answer 1

2

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

  1. 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.

  2. 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

3
  • Thank you, that is what I meant. Sorry for those who posted earlier I was still half a sleep before I went to school.
    – Callum
    Commented Sep 25, 2013 at 14:35
  • if possible could you give me the command lines?
    – Callum
    Commented Sep 25, 2013 at 15:00
  • I've added several command lines that I would use for my distribution (Ubuntu, debian based). Different distributions do apache configuration differently, so your milage may vary. Commented Sep 25, 2013 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.