Apache web server
Linux Reality Episode 56
www.lifehacker.com set up a home web server
Debian comes with Apache 1.3 and 2.2. In the package manager Apache 1.3 is called apache and Apache 2.2 is called apache2.
INSTALL APACHE
Install this using Synaptic or from the command line type:
#apt-get install apache
CONFIGURE APACHE
Go to the configuration file directory
#cd /etc/apache2
Create a backup of the configuration file
#cp httpd.conf httpd.conf_backup
#cp default-server.conf default-server.conf_backup
Edit the configuration file
#nano httpd.conf
In the Global Environment section
add index.htm to the DirectoyIndex line
This will make it more user friendly if you are creating web pages in windows.
save and exit
#nano default-server.conf
DocumentRoot defines where the web pages are stored. The default is
DocumentRoot /var/www
I like to keep all of my documents in my home directory to simplify backup, but you can keep yours wherever you like. For this example, lets call my Document Root
/home/docs/website
A bit further down is a line that looks like
<"Directory /var/www"> (without the quotes)
Change this to whatever you made the DocumentRoot. Leave the trailing /.
A few lines down change
AllowOverride None
to
AllowOverride All
This will allow you to put a password on your website. If you don't want a password, you don't need to change this, but I would anyway.
Save the file (cntrl+O) and exit (cntrl+X)
PASSWORD PROTECT YOUR WEBSITE
In the terminal type:
#htpasswd -c /home/user/passwords username
This will create a password file called "passwords" in the folder /home/user
Replace both the path and the filename with whatever you want to use.
Replace username with the username you want people to log into your website with.
Go to the DocumentRoot directory
$cd /home/docs/website
Create a file called .htaccess
$touch .htaccess
Open the .htaccess file for editing
$nano .htaccess
Type or copy the following into the .htaccess file
*********
AuthType Basic
AuthName "name of your website"
AuthUserFile /home/user/passwords
AuthGroupFile /dev/null
require valid-user
**********
OPEN YOUR WEBSITE TO THE WORLD
The last two things to do if you want to share your website with the world are to forward port 80 from your router to your server and get a domain name for your website. Excellent instructions on how to do this can be found at
http://lifehacker.com/software/top/geek-to-live--how-to-access-a-home-server-behind-a-routerfirewall-127276.php
http://lifehacker.com/software/web-publishing/geek-to-live--how-to-assign-a-domain-name-to-your-home-web-server-124804.php
Apache for openSUSE
No comments:
Post a Comment