Apache: Basic steps for a successfull VPS

Table of contents


  1. Introduction
  2. Modules
  3. mod_userdir
  4. Practical Approach


Introduction





Today is the day to configure our acquired VPS, but before getting into it I will remind that we configured it previosly with Apache:


As a small reminder, we ended up with a welcome page based on debian's default page with a small change at the title.

"From Debian's default page to Sergi's default page."

Now that we're all on the same page, let's join together in a process of advanced Apache configuration while learning the basics.


Modules


One key thing to keep in mind with apache is his extended module offer, considering this, it's time to learn how to use them.

How could you know which one to choose? Well, google exists but if you're willing to find it on your own, try out this commands:

cd /etc/apache2/mods-available && ls -l


"..."

Now that you could've checked the available mods you'll want a list of must go's, instead of that, I'll clarify a few of the most interesting ones:


  • Mod_security:  Can protect the server from various attacks.
  • Mod_rewrite: It is used to rewrite the URLs and so that the redirection can be achieved.
  • Mod_deflate: This module is used to compress the output from the webserver before sending to the client.
  • Mod_cache: It is used for content caching.
  • Mod_proxy: Implements a proxy, gateway for Apache Server.
  • Mod_ssl: It enables encryption via the SSL and TLS with the help of Open Source SSL/TLS toolkit openSSl.

How can I activate any module?

It is quite simple, just copy the following command scheme:

a2enmod [module to activate]

Don't forget to restart apache after the activation.

Our following task will be to activate one that I didn't mention because I want to offer a better explanation.



mod_userdir


Our following task will be to activate one that I didn't mention because I want to offer a better explanation.

Keeping in mind that we will have groups of users in our VPS we will need an organised structure that allows us to have a working directory for each user in our VPS.



Userdir's module allows this by giving us the possibility to stablish a public_html folder in each user personal directory.
Important to know that to access any of this users works it is necessary to access via IP following this scheme: "IP/~username".


Practical approach


First of all, access your VPS and login as root to create a new user:



useradd  -m  -s  /bin/bash  Enrique



This command will create a user called Enrique with his own home directory that uses bash as the shell.
Once created a password is required,  so use:


passwd  Enrique


It is important to log in Enrique's user to proced with the following tasks, simply write "su Enrique".

Remember that this userdir module required a public_html folder in each user directory?

Let's get into it:

mkdir $HOME/public_html


Now it's just as simple as open a new browser window and type the related apache userdir scheme as said before:


SMALL TIP:



Change the permissions of the folder: "chmod 0755", that way the only capable of working on it is the named user.


What do you think? Will you try it? 

Thank you for reading my amateur tutorial and I hope we'll keep improving together!


Comentarios