Skip to main content

Posts

Showing posts with the label linux

Standardizing infra - lxd is not Docker

LXD logo from Ubuntu blog Selling a software package that is deployed to a customer data-centre can be challenging due to the diversity found in the physical infrastructure. It is expensive to make (and test) adjustments to the software that allow it to run in a non-standard manner. Maintaining a swarm of snowflakes is not a scalable business practice. More deployment variations means more documentation and more pairs of hands needed to manage them. Uniformity and automation are what keep our prices competitive. Opposing the engineering team's desire for uniformity is the practical need to fit our solution into the customers data-centre and budget. We can't define a uniform physical infrastructure that all of our customers must adhere to. Well, I suppose we could, but we would only have a very small number of customers who are willing and able to fit their data-centre around us. We are therefore on the horns of a dilemma. Specifying standard physical hard...

Using OpenSSH to setup an SFTP server on Ubuntu 14.04

I'm busy migrating an existing server to the cloud and need to replicate the SFTP setup.  They're using a password to authenticate a user and then uploading data files for a web service to consume. YMMV - My use case is pretty specific to this legacy application so you'll need to give consideration to the directories you use. It took a surprising amount of reading to find a consistent set of instructions so I thought I should document the setup from start to finish. Firstly, I set up the group and user that I will be needing: groupadd sftponly useradd -G sftponly username passwd username Then I made a backup copy of and then edited /etc/ssh/sshd_config Right at the end of the file add the following: Match group sftponly ChrootDirectory /usr/share/nginx/html/website_directory/chroot X11Forwarding no AllowTcpForwarding no ForceCommand internal-sftp -d /uploads For some reason if this block appears before the UsePAM s...

Compressing Apache output with mod_deflate on Centos

Apache on Centos ships with mod_deflate installed and enabled by default.  To check this you can grep your config file and make sure the line which loads it is not commented out. cat /etc/httpd/conf/httpd.conf | grep LoadModule deflate_module When Apache loads it reads all the config files (ending in .conf) in /etc/httpd/conf.d so we'll add configuration options for mod_deflate into this directory. Lets use a file called deflate.conf to specify the config: <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutput...

Wordpress on Hiphop / Nginx / Varnish

I recently was asked to investigate speeding up one of the Wordpress sites of a fairly large government organization in Britain.  A large part of my investigation focused on the server stack because I felt that we could get more out of the hardware that was provisioned for us. I decided to set up a stack on my development machine to see how it would work and if it was feasible.  I settled on nginX with hiphop and a Varnish frontend cache.  I realize that nginX would be just fine as the cache and server but in this particular case it would not be possible to replace Apache with nginx on the live server.  I also wanted to experiment with ESI and it looked better documented in Varnish than nginx. Installing HHVM is very easy: wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add - echo deb http://dl.hhvm.com/ubuntu saucy main | tee /etc/apt/sources.list.d/hhvm.list apt-get update apt-get install hhvm Installing nginx is also very easy:...

Fixing the "smsbox_list empty" error in Kannel

I got this error even though I had an smsbox defined.  Unfortunately I had forgotten to create the smsbox-route group, so this is a very quick fix: #--------------------------------------------- ## SMS ROUTING ##--------------------------------------------- group = smsbox-route smsbox-id = mainbox smsc-id = ztemodem-smsc-group sim-buffering = false ... continues ... Just make sure the id's matchup, so my smsbox group begins with this: #--------------------------------------------- ## SMS BOX ##--------------------------------------------- group = smsbox smsbox-id = mainbox ... continues ... And my SMSC looks like this: #--------------------------------------------- ## GSM MODEM SMSC ##--------------------------------------------- group = smsc smsc-id = ztemodem-smsc-group ... continues ... This successfully cleared the "smsbox_list empty" error and allowed messages to be delivered properly. Kannel had until then been able to send messages and receive delivery...

Setting up a Kannel SMS centre on a Raspberry Pi with a K3565-Z modem

Our office (who wants me to mention how awesome they are) had a need for a means to send/receive automated sms messages relating to online banking. We decided to give a Raspberry Pi the job and so I have had the fun of setting it all up. First off I installed Rasbian (  http://www.raspbian.org/  ) which is a Debian fork and is sufficiently easy to do following the guide on eLinux ( here  ) which is linked to from the Raspberry Pi project website downloads page. Next came a standard LAMP stack install.  I needed to have a web-server running because we will be running a management package on the box to track messages etc. Next came Kannel.  I used the default package available from the Rasbian repositories so there was no need for fiddling. My kannel.conf file was the next hurdle.  For the most part this is pretty easy to set up from the examples given on Kannel's site and elsewhere on the web.  I want to just mention the modem part, which was pe...

Installing phpMyAdmin and removing the popup authentication in CentOS 6

Installing phpMyAdmin is a snip in CentOS, but there is a little trick that most tutorials skip out. For some reason the default setup (using standard repositories) does not like you having a null password for your mySQL root account. I know that you are supposed to be able to set a blank password in the pma config file and set the option to allow blank passwords to true, but this did not work for me until I set a root password. I kept getting a popup box that looked exactly like a .htaccess Apache protect but was actually just a Javascript prompt. So here goes: Step One - enable your EPEL repo: $ cd /tmp $ wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm # rpm -ivh epel-release-6-5.noarch.rpm Step Two - Install phpMyAdmin # yum search phpmyadmin # yum -y install phpmyadmin Step Three - optionally edit your Apache conf If you get Apache forbidden errors (should not be the case) you can try editing your .conf file...

Three steps to create a self-signed certificate in Apache for Ubuntu 11.10

It is very simple and quick to create a self-signed certificate on your development machine. Of course you would never use this on a production server because self-signed certificates are vulnerable to man in the middle attacks.  You will need to make sure that you have the ssl-cert and libapache2-mod-gnutls packages installed. Step One : Use the ssl-cert package to create a self-signed certificate.  This will create the certificate files in /etc/ssl which is where the Ubuntu default Apache configuration expects to find them. make-ssl-cert generate-default-snakeoil --force-overwrite Step Two : Active the SSL module and the default SSL site using the convenience wrappers: a2enmod ssl a2ensite default-ssl Step Three : Restart Apache service apache2 restart

Adding a CakePHP based virtual host in Apache 2.2

It's very simple to set up a name based virtual host in Apache 2.2 using the default Ubuntu package. I'm assuming that you have installed Apache already and that you have edited /etc/apache2/sites-enabled/000-default to change the AllowOverride None to something like this: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> If you have not already used this command sudo a2enmod rewrite then do so in order to enable mod_rewrite. Now edit your /etc/hosts file and add an entry that points to the server where you are setting up the virtual host. The line should look something like this: 192.168.0.100 mysite.local Where the IP address points to the server where you are setting up the host and mysite.local is a nickname for the site. Remember to add the .local :) Now create a file in /etc/apache2/sites-ava...

Reverse Engineering an MS-SQL database without Visio

The splash screen for Squirrel SQL I'm working on a project that draws from a Microsoft Sql Database.  Unfortunately there is no project documentation which means that it takes longer to become familiar with the design.  I particularly wanted an ERD of the database but this wasn't available.  So I looked for open source reverse engineering tools and found Squirrel SQL .  This is a very handy tool as it supports a variety of databases and client operating systems. Installing the Microsoft JDBC ( available from the Microsoft site ) was a snap: Just download the archive, extract it somewhere meaningful (I put mine as a directory in Squirrel). Edit the Microsoft SQL driver in your driver list Add an extra class and point it to the JDBC4 jar file (version 4 is required for newer versions of the JDK) The driver should load now Then proceed to add your connection alias per normal and you're connected to your MS-SQL database. The plugin to reverse engineer your dat...

Fixing mySQL CDR module compile error for Asterisk 1.6 in Ubuntu

There is a bug in the Ubuntu release (still in 10.04) that causes a mismatch between the Asterisk 1.6 package and its addon package. This results in the error message: WARNING[4238] loader.c: Module 'app_addon_sql_mysql.so' was not compiled with the same compile-time options as this version of Asterisk. To produce this error you just need to apt-get install asterisk-mysql in an effort to get the cdr logging to a mySQL database (assuming that you also used aptitude to install Asterisk 1.6 of course). In order to fix it do the following: aptitude purge asterisk-mysql apt-get build-dep asterisk-mysql apt-get -b source asterisk-mysql dpkg -i asterisk-mysql_1.6.2.0-1_i386.deb Do this in a temp folder as it will create a number of .deb packages. You may need to change the filename depending on your hardware architecture. The idea is to uninstall the faulty package that Ubuntu created and then compile a copy of the addons that matches the current Asterisk version. Since you've h...

Squid proxy server

My job title is "PHP developer" but because I'm the only person in the office familiar with Linux I get roped into administering the LAMP stack and other systems roles. Yesterday I was asked to investigate methods of monitoring individual bandwidth use. I've installed Squid proxy server so that all traffic is getting routed through my pet Linux box that I keep spare just for such occasions. Right, now I'm asked to install software to filter out sites not related to work (like OkCupid... uhoh). So I find a program that slots into Squid and install it. Bang! Facebook and all other sites mysteriously get replaced with a kitten (from icanhazcheeseburger.com) chewing network cables captioned as "Ohnoes!!!1 kitty is eating my megahurtz!". Putting me in charge results in silliness. I hope they do it less often. Anyway, despite my best efforts to make the access denied picture cute and adorable my users still hate me. It's tough being a webslave. A li...