1

I am working on a database driven website and want to test it using the LAN available to me. How do I host a website? (Static pages will also do)

I tried using php and it works on my system but not on other systems connected on the LAN. I am open to hosting pages via any language.

Note that I don't want to host a website on the internet. I am aware about the Ubuntu server edition, and I am using 12.04 LTS.

David_G
  • 358
  • 1
  • 5
  • 15

3 Answers3

2

Apache is a good choice for hosting websites over the intranet(LAN) as well as over the internet. Most of the companies use Apache for to host their websites.

Install it using the following command:

sudo apt-get install apache2

And copy your website folder to /var/www.

sudo cp /path/to/website/folder /var/www

Now head over to your browser and open the url http://localhost/websitefolder. Don't forget to replace websitefolder with the name of your website's folder in /var/www.

To access the website from a different device over the LAN, you need to find out your Local IP address.

Here's how to find it out. Type the following command in the terminal:

ifconfig

Once you know the IP address head over to http://ipaddress/websitefolder using the device's web browser.

Also, regarding the database MySQL and PHP will be an ideal choice for beginning.

Install them using the following commands:

sudo apt-get install php5 libapache2-mod-php5 mysql-server mysql-client

If you want to access the MySQL database using a web interface install phpMyAdmin alongside.

sudo apt-get install phpmyadmin

Don't forget the restart the Apache web server to make everything work perfect.

sudo /etc/init.d/apache2 restart
0

just adding more information about your question "Note that I don't want to host a website on the internet. I am aware about the Ubuntu server edition, and I am using 12.04 LTS."

i am afraid that your server using public IP addess, which is mean that your server may be accessed from outside your office.

to handle this you need to config you apache mod_access that only allow specified IP address/addresses that can access your sites.

for more information Click here to apache mod_access documentation

or you can simply add firewall rule to port that you are using for apache to get work, ussualy it use port 80

the advantages of using mod_access and firewall rule. is to prevent someone who have no auth access from accessing your sites.

0

I will add another option for you, so you're informed. If you have Python installed, you can quite easily set up a quick LAN webpage. This lives in the Terminal however, so the command must be added to "Startup Applications" or started manually every boot.

First change your directory to the web root of your website. (In this case I used my ~/Public directory)

$ cd ~/Public

Then start the server

~/Public$ python -m SimpleHTTPServer 80

In that case, I appended the server to all interfaces (0.0.0.0) on port 80, you can choose any open port. An "index.html" file will be displayed instead of "Directory Listing" if it is present.