Setting up Apache for a single site
Apache Web server should be pre-installed on your server.
By default it will serve pages from /var/www. If you only
have one web site to serve from your server then you can
simply upload files into that directory. To do this we recommend
that you use SCP (from Linux) or WinSCP
from Windows.
In addition to this you will also need to create an A-record
pointing a domain name (eg. www.yourdomain.com) at the IP
address of your server.
Setting up Apache for multiple sites
Apache Web server has a built in facility to host multiple
sites from one IP address. This is called virtual hosting.
You will first need a location to put each of the separate
web sites. If you are managing the all the sites then we
suggest that you create a directory called "www"
in /home, and put the web site directories in there:
/home/www/www.somedomain.com/
The next step is to add the virtual servers into Apache's
configuration file. You can do this manually by editing
httpd.conf directly, or via Webmin. In Webmin, go to the
"Servers" tab and then to "Apache Web server".
At the bottom of the page there is a form for creating new
virtual servers. Normally, the server name and virtual host
name would be the new domain name. The document root should
be wherever you have chosen to put the files for the new
domain, such as the example above.
Before the new domain will work you must also set an A-record
for the domain to point to your web server, as when hosting
a single site.
Setting up FTP access
First, if at all possible we would advise against using
FTP since it is quite insecure, does not work "out-of-the-box"
and cannot be used as root. Instead we would recommend that
you use SCP, or WinSCP
from Windows.
That aside, to enable FTP access to your server you need
a FTP daemon; we suggest ProFTPd. You can install ProFTPd
via apt-get:
apt-get install proftpd
By default ProFTPD will enable FTP access for all users
(except root) to their home directories, and it should not
normally require additional configuration.
If, for example, you wished to host someone's web site
on your server and give them FTP access then you would first
need to add that user. This can be done with the "adduser"
command, or from Webmin. Rather than simply putting web
files straight into their home directory we suggest that
you creat a folder called "public_html" for them:
mkdir /home/<username>/public_html/
You can then either make an Apache virtual server for their
web site that has that directory as its document root, or
you could use the /home/www/www.domain.com/ location and
sym-link it to their directory:
ln -s /home/<username>/public_html/ /home/www/www.domain.com/
If the user does not need shell access then you can simply
make the above directory their home directory and dispense
with the public_html format. To do this you should create
the user like so:
adduser --disable-login -d /home/www/www.domain.com/
Turning on CGI
CGI will be enabled by default for the /cgi-bin/ directory,
but often it is useful to have it enabled for the root html
directory. To do this you need to edit httpd.conf. First,
add "ExecCGI" to the list of "Options"
for your base directory - for example:
Options Indexes FollowSymLinks ExecCGI
Next you need to uncomment the "
AddHandler cgi-script
.cgi
" line. Finally, restart Apache and CGIs should not
work.
Note: Dont forget to set execute permissions on your CGI
scripts.
Installing PHP
On many servers PHP will be pre-installed, but if not there
are a couple of simple steps to get it working. First, to
install php with mysql support (for example) you would do
the following:
apt-get install php php-mysql
If you wish to use php with MySQL you may also need to make
a small change to /etc/php.ini. You should make sure that
the following line is in the file and uncommented:
extension mysql.so
Following any changes to /etc/php.ini you should restart
Apache.