Short guide to set up an apache virtual host on ubuntu 14.04

Knowing, that there are very good and detailed guides for virtual host creation, i decided to have a shortest possible how to on this topic here.
Assuming, that you have installed and running your apache in Ubuntu 14.04 Trusty Tahr, then these are the steps to create a new virtual host:

  • assure, that the directory, where your virtual host should to “live” in, exists (e.g. “/var/www/awesome.local”)
  • assure, that the permissions of your document root are set to 755
  • create an apache virtual host configuration file (copy the default config file)
    • sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/awesome.local
    • fill it with your configuration (with the editor of your choice)
  • <VirtualHost *:80>
        ServerAdmin admin@awesome.local
        ServerName awesome.local
        ServerAlias www.awesome.local
        DocumentRoot /var/www/awesome.local
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
  • enable the virtual host configuration:
    sudo a2ensite awesome.local
  • restart apache:
    sudo service apache2 restart
  • set up your local /etc/hosts:
    • open the file “etc/hosts”
    • add the line
      127.0.0.1 awesome.local www.awesome.local
  • open http://awesome.local and/or http://www.awesome.local in your browser and check, if everything went well (if you see an empty page, check, that there is something in your document root ;))

Security script: ubuntu server automatic check of services

Looking at this post on about perl i got the idea to write my own script to check if all services are running.

Here it is:
check_services.py

There are only a few things you have to do:

  • change the path to the script in the script (necessary cause we use cron)
  • put it in your crontab:
    • “crontab -e” as root
    • set your local PATH variable (look it up in the shell with “echo $PATH”)
    • * * * * * /PATH_TO_YOUR_SCRIPT/check_services.py
  • think about how you observe the logfile (maybe you want an email or a notification at login)

If you like the script, see any points i missed or have problems: let me know it and write a comment!

Ubuntu backup scripts

[toc]

Using the scripts

There are many backup scripts out there for linux. I wrote two on base of a tar with bzip2 and nice (giving you the ability to use your box while [de]compressing by setting the priority of the backups to “lowest”) in python 3.1.

Don’t use them mindless, you could damage all your recent work or worse! I don’t take responsibility for the effects of this scripts, you use them on your own response!

You have to give the “disk2file.py” a string with a description like this:

./disk2file.py 'before installing the newest updates'

and it will create a packed file called:

001__16_5_2011__before_installing_the_newest_updates.tar.bz2

with an automatic incremented number and the date.

To decompress the file use:

./file2disk.py 001__16_5_2011__before_installing_the_newest_updates.tar.bz2

You can define another directory to compress and decompress and a comma separated list of directories to exclude, here are the help outputs:

Usage: disk2file.py description_string

Options:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory=DIRECTORY
                        directory which will be saved (default='/')
  -e EXCLUDE, --exclude=EXCLUDE
                        directories to exclude (separated by comma,
                        default='['/proc', '/lost+found', '/media', '/mnt',
                        '
/sys', '/var/backup*']')
Usage: file2disk.py filename

Options:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory=DIRECTORY
                        directory where the backup will be copied
                        (default='/')

If you have ideas or hints on the scripts or even find them usefull, let me know it and write a comment.

Download

You can download them here:
disk2file.py
file2disk.py

If you have ideas or hints on the scripts or even find them usefull, let me know it and write a comment.