Git Product home page Git Product logo

easydebianwebserver's Introduction

Note: this project has moved to https://github.com/onnozel/easywebserver. The version in this repository isn't maintained anymore.

Easy Debian Webserver

You want a reasonably secure webserver based on Debian? Well, you are in luck! This shell script does exactly that.

Reason

I have to install and configure webservers far too often, but everytime it's the same steps over and over again and that is... boring. Please note that this script is made for my use case and that it may or may not fit your requirements. It won't be the ideal script for everyone. That being said, I think this script will work well for the majority of the basic Debian users like me. If it doesn't, feel free to suggest improvements or changes!

Also, if you have any questions, suggestions or comments, let me know!

What does it do?

Quite a lot actually! The most important things:

  • Installs basic software needed for a complete webserver.
  • Creates a user account with correctly set ssh, sudo and folder permissions.
  • Creates a backup account with automated daily backups to its home folder.
  • Installs and configures a basic firewall.
  • Hardens the webserver, SSH, SSL/TLS and MySQL.
  • Configures automatic security updates.

For a complete rundown on all the stuff in the script, check the List of all actions.

Software

Then you might wonder what software will be installed. Below is a short list, check the wiki for the long list. Please note that some software is optional, these preferences can be changed in the USER VARIABLES section in the top of the script.

  • The Apache webserver
  • PHP + some extentions (optional)
  • MariaDB (optional)
  • Let's Encrypt's Certbot for certificates
  • Uncomplicated Firewall (UFW)
  • Some commonly used software like apt-transport-https, unattended-upgrades, (un)zip, dnsutils, curl etc.

Requirements

  • A clean installation of Debian 8 Jessie or Debian 9 Stretch.
  • You must be able to run the script as root.
  • The system you are installing this on must have a functioning internet connection and DNS.
  • Some free disk space for the packages.

That's all :-).

How to run the script?

Note: connecting with SSH makes pasting things like the SSH public key a lot easier.

  1. Become root if you are not already.
    su root
  2. Change directory to a folder to your liking.
    cd /tmp
  3. Download the file with git, direct link (example below) or copy the content from github and paste in nano/vim.
    wget https://raw.githubusercontent.com/sveeke/EasyDebianWebserver/master/EasyDebianWebserver.sh
  4. Give proper permissions to the script.
    chmod 700 EasyDebianWebserver.sh
  5. Execute the script and follow the instructions in it.
    ./EasyDebianWebserver.sh

Help and support

Check the wiki if you have questions or need help. If you still have questions you can post them at Issues'.

Plans for the future

I would like to incorporate some extra hardening like the Inversoft's hardening guide. Some of it is already in the script, but there are still some usefull improvements to be made. This means adding things like:

  • libpam-cracklib for strong passwords
  • google authenticator for 2FA
  • monit for monitoring logins and changes
  • Automatically encrypting backups

easydebianwebserver's People

Contributors

sveeke avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jurhillebrink

easydebianwebserver's Issues

Backup user

While using your script I was prompted to create a backup user. I thought it was smart to name this user backup (not knowing Debian already has a default user named backup). Maby you can prompt the user not to use backup as a username? Thanks! :)

MariaDB does not ask for password in stretch

MariaDB does not seem to ask for a password when installing the package. Maybe it's because it's still in unstable, but either way this should be fixed in the script so that mariaDB has a strong password on the root account.

Options:

  • Generate password for user
  • Let user choose password in the beginning of the script (user variables)

Questions

Here you can leave any random questions you might have regarding the EasyDebianWebserver script.

Automatic restore of backup during script

It would be awesome if you could give the script backups of earlier hosted sites and it would automatically restore them. So for example it would first ask you how many sites you previously had and then ask you to show it where the backups are.

Add notice in backup script

Apache needs to be restarted daily because of key material. Add notice in backup cronjob or backup script (or both) that when the script isn't used, one should create a new cronjob that restarts apache daily.

Change lay-out of dates in backup file names

Current lay-out: backup-daily-2016-10-10_04-00-58.tar.gz. The underscore might be confusing and is not consistent. Some options:

  • backup-daily-2016-10-10-04-00-58.tar.gz (rather clear and simple, but long)
  • backup-daily-20161010040058.tar.gz (short but not very clear / somewhat confusing).
  • backup-daily-20161010-040058.tar.gz
  • backup-daily-161010-040058.tar.gz

Harden apache in the script

security.conf

ServerTokens Prod
ServerSignature Off

security-headers.conf

Header set X-XSS-Protection "1; mode=block" Header always set Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-Content-Type-Options "nosniff" Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  • a2enmod headers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.