Date: 10.11.2018
This document explains how to install a debian web server from scratch. It was intended to be done for an exam in Centre Profesionnel du Nord Vaudois (CPNV, Switzerland).
The final webserver has those features:
- Each user has one or more website
- Each user has a ssh access (so he can use scp)
- Each user has his own database (accessible by phpmyadmin)
- Browse www.debian.org in your browser
- Click on Getting Debian in the navbar
- Click on Download an installation image
- And click on the amd64 link
The section below will explain you some principles if you want to make your server production oriented Pay attention that we don't take any responsibility about any security flaw that could occur by following all our instructions. For more secure solutions go to More reliable solutions section.
If you only want to use the configuration for personal use or a only few websites, you can freely go to the next Debian Installation section.
Knowing how much RAM your server should have is not easy to quantify because it depends on many factors.
It depends on the:
- Minimum memory required by the system
- Type of site hosted (showcase website, e-commerce, web application, intranet / extranet aso..)
- Number of hosted websites
- Resources that websites take by default
- Visitors on websites at a moment T
- Many other parameters like cache aso ...
To get an idea about a real (little) server having 4 websites on it (1 is dynamic and the 3 others are showcases website) here is what we have:
htop, screenshot taken approximatively at 23:00 on the 10.11.2018 after rebooting the server
We notice:
- Approximatively 1000MB (~50%) are used. This comes frome the OS itself and the running processes
- The clamav process (antivirus) takes a lot of memory itself (~28%)
Even if those facts are not enough, we can say that it is therefore important to take into account all factors (minimum memory required by the server, type of wesite, number of websites, visitors ..).
The best solution is to test it in production and see how it reacts. If needed websites can also be moved to other server.
- Choose - install
- Language - English
- Region - Other->Europe->United Kingdom
- Default language settings - United Kingdom - en_GB.UTF-8
- Key map settings - United Kingdom
- Host name - SharedHosting
- Domain name - let it blank
- Root password - ROOT_PASSWORD
- New user - USER
- New user password - PASSWORD
partition disk - Separate /home, /var, /tmp partitions and use LVM
Use network mirror - yes -> United Kindom -> ftp.uk.debian.org
http proxy info - let it blank
- Uncheck all and just keep Only SSH server and standard system utilities
- yes -> /dev/sda
A ready-to-use script has been created for the project:
- Follow the link above (github)
- Create the file basicinstall.sh with root rights on your server (
nano basicinstall.sh
) - Paste the code in it and save it
- Make the basicinstall.sh runnable with
chmod +x basicinstall.sh
- Run it with
./basicinstall.sh
What the script does:
- Install dependencies
- Nginx
- Mariadb
- Php-fpm
- Phpmyadmin
- Create a folder
/var/www/default
structured like this:/var/www/default
createuser.sh
--> Script that should be used to create new user/websiteindex.php
--> A default page copied to each new user folder when newly createdwww.conf
--> Default php-fpm configuration file that will be copied and modified per each user
- Structure the web folders as follow:
/var/www/
user1/
website1user1.com
website2user1.gov
- ...
user2/
website1user2.ch
user3/
website1user3.org
- Create a redirection to phpmyadmin by putting /phpmyadmin after his domain name
userX:
userXwebsite.com/phpmyadmin
- Make user website folders accessible by ssh