Laravel and Docker

Laravel is a PHP framework that makes building a web application faster (once you climb the mountain to learn it!)

Docker is the hosting environment that brings your ‘development’ and ‘production’ environments closer together.

Laradock is the glue holding them together.

Getting started with Laravel for Linux System Administrators

I recently had a go at learning Laravel.

I’m already very familiar with Linux servers as I ran a web hosting business. Yet all the Getting started documents seemed to assume I was unfamiliar and lead me down the path of using Vagrant on my Windows desktop

To use Laravel on a Linux web hosting account, all you actually need is composer. This is a PHP dependency manager, not unlike Yum or Apt-get you would use to manage packages on your server.

You can install composer with the standard package management. From there create a new Laravel project with

composer require laravel/laravel

in the folder where you would like it created.

This creates a file called composer.json. This file describes the requirements of the build. You just created one that ‘requires’ the laravel/laravel package. Composer will then check its packages¬†and install the laravel package and all its dependencies.

Once thats done you have a very basic laravel website ready to go. Place it behind an apache web server and you should see the logo of laravel.

Anouther important piece is the artisan file. This command line PHP script performs a few important functions such managing the associated database for the laravel site in an intelligent way.

Services

Hansen IT Solutions can provide a range of services.

Website development and ongoing maintenance

Search engine optimisation

Social media integration and management

SMB Desktop networking design, services and support

Internet connectivity

VoIP Telephony including PABX systems and integration

Custom programming services

Adding slave DNS servers for Plesk

There is a nice and simple extension for Plesk that allows you to setup slave DNS zones from Plesk domains automatically.

If your adding this to an existing server though its a little hit and miss if it will add existing domains. The instructions say you can do this via ‘Apply DNS template’ but this did not work for me. Adding new domains worked fine though.

I ended up writing this script and it worked great.

add-slave.sh
#!/bin/bash
/usr/sbin/rndc -c /usr/local/psa/var/modules/slave-dns-manager/slave_*SLAVEIP*>.conf addzone $1 '{ type slave; file "db.'$1'"; masters { *MASTERIP*; }; };'

Replace *MASTERIP* and *SLAVEIP* with your own server IPs.

Usage from the command line is just needs a the DNS your setting up the slave with as the parameter

Taking it further there was a few hundred domains which didnt seem fun to type in one at a time so I used this script to loop over all the domains and add each one.


#!/bin/sh

ADMIN_PASS=`cat /etc/psa/.psa.shadow`
MYSQL_BIN_D=`grep MYSQL_BIN_D /etc/psa/psa.conf | awk ‘{print $2}’`
mysql=”${MYSQL_BIN_D}/mysql -N -uadmin -p${ADMIN_PASS} psa”

query=”select name from domains;”
domains=`echo $query | $mysql `

for i in ${domains}; do
./add-slave.sh $i
done

from https://gist.github.com/agarzon/37b6eac3f31a5017ffb2 which was linked in the comments.

WHMCS and Plesk 12

If you are having problems, such as randomly not loading pages, running WHMCS on otherwise stock Plesk 12 server, try updating the install of ioncube. It seems the version installed with Plesk is a little older and doesnt quite work right with the current version of WHMCS.

Rsync backup CentOS server with email report

Running various business critical CentOS based Linux servers means good backups are a must. The ability to restore completely from backup to a DR site is a must.

To do this I keep a copy of the server backed up at root level on a locally hosted NAS.

A nightly rsync runs, with appropriate exlucsions that keeps a local copy of the system in sync. Data usage on the various Web/DNS/email servers I run works out to be around 50-200mb a night.

rm -f /var/log/sync/*

rsync -avzh –delete –stats server1.com:/ ¬†/store/backup/server1/ >/var/log/sync/server1 –exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs,usage/*}

tail /var/log/sync/* | mail -s “Server sync report”logs@myemail.com

add a rsync line for each server.

the rsync logs are kept in /var/log/sync. To know if it was a success I can monitor the email. As I’m really only interested in success/fail i use tail to only show me the last few lines of each log.

To restore, do a minimal install of the same CentOS version, install rsync, and rsync directly over root from the backup. Reboot to bring the new system back online as per the last backup.