Difference between revisions of "Hosting a website"

From Amahi Wiki
Jump to: navigation, search
(I was very confussed whe I tried this tutorial so I add to it to clarify for noobs like me. Added how to find your conf file and what the file should look like when you're done)
Line 7: Line 7:
 
* Forward a port to your HDA ip address, either for plain insecure http: 80, for https, 443 (advanced users can use other ports). Some routers call this or require a "virtual server"
 
* Forward a port to your HDA ip address, either for plain insecure http: 80, for https, 443 (advanced users can use other ports). Some routers call this or require a "virtual server"
 
* Chose a domain name that you own (or your free username.yourhda.com that comes with Amahi). This is how the app will be accessed outside
 
* Chose a domain name that you own (or your free username.yourhda.com that comes with Amahi). This is how the app will be accessed outside
* Chose the app you want to make accessible outside, let's say, '''yourweabppname'''
+
* Chose the app you want to make accessible outside, let's say, '''yourwebappname'''
  
What you need to do (as root) is edit the config file for the app:
+
What you need to do (as root) is find for apps conf file then edit the conf file for the app:
  
     nano /etc/httpd/conf.d
+
     ls /etc/httpd/conf.d
    10*-'''yourweabppname'''.conf
 
  
Then add this (immediately after the ServerName directive):
+
Find your app .conf file. It will look like 10##-yourwebappname.conf
 +
 
 +
    nano /etc/httpd/conf.d/10##-'''yourwebappname'''.conf
 +
 
 +
Your conf file should look something like this at the top of the page:
 +
 
 +
<VirtualHost *:80>
 +
 
 +
        ServerName app
 +
        ServerAlias app.YourDomain.lan
 +
 
 +
Add this (immediately after the ServerName directive):
  
 
     ServerAlias username.yourhda.com
 
     ServerAlias username.yourhda.com
 +
 +
So it looks like this:
 +
 +
<VirtualHost *:80>
 +
 +
        ServerName app
 +
        ServerAlias app.YourDomain.lan
 +
        ServerAlias username.yourhda.com
  
 
You can add more server aliases if you want to access the app under those names. Then save the file, quit the editor (nano in this case) and restart the server:
 
You can add more server aliases if you want to access the app under those names. Then save the file, quit the editor (nano in this case) and restart the server:

Revision as of 01:37, 21 February 2010

You want to run a web server in your Amahi server and make it visible from the web outside your home.

FIRST: making anything visible outside your network can open security issues, so you are doing this at your own risk. Some apps are more secure than others, but there is nothing ultimately secure. Best is to use the VPN to login back home."

With that out of the way, to host your own web site you need the following:

  • Forward a port to your HDA ip address, either for plain insecure http: 80, for https, 443 (advanced users can use other ports). Some routers call this or require a "virtual server"
  • Chose a domain name that you own (or your free username.yourhda.com that comes with Amahi). This is how the app will be accessed outside
  • Chose the app you want to make accessible outside, let's say, yourwebappname

What you need to do (as root) is find for apps conf file then edit the conf file for the app:

    ls /etc/httpd/conf.d

Find your app .conf file. It will look like 10##-yourwebappname.conf

    nano /etc/httpd/conf.d/10##-yourwebappname.conf

Your conf file should look something like this at the top of the page:

<VirtualHost *:80>

       ServerName app
       ServerAlias app.YourDomain.lan

Add this (immediately after the ServerName directive):

    ServerAlias username.yourhda.com

So it looks like this:

<VirtualHost *:80>

       ServerName app
       ServerAlias app.YourDomain.lan
       ServerAlias username.yourhda.com

You can add more server aliases if you want to access the app under those names. Then save the file, quit the editor (nano in this case) and restart the server:

    service httpd reload


FAQs

  • Q: Do i need to do anything for username.yourhda.com to work?
     No. That comes free and automatically set up with your Amahi HDA
  • Q: What if i want to do it for a .html or .php file?
     You can do this by creating a Webapp of your own. In the apps tab,
     select Webapps and create a new one.
     What you do is, create a web app, and put the files into the root
     directory of the webap, something like this directory:
         /var/hda/web-apps/yourwebappname/html
     this directory belongs to apache. you will have to change the
     ownership to your user (recommended) or otherwise add things as root.
  • Q: How do I change the ownership?
     You can do this by going to the command screen:
        su -
        {password}
        chown {user} /var/hda/web-apps/