Posts tagged with server

You should not run your mail server because mail is hard.

poolp.org

Contrary to the title, Gilles Chehade that it's acutually doable running your own mailserver.

TL;DR: Mail is not hard: people keep repeating that because they read it, not because they tried it. Big Mailer Corps are quite happy with that myth, it keeps their userbase growing. Big Mailer Corps control a large percentage of the e-mail address space which is good for none …

Read more [poolp.org]

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

I forgot how to manage a server

ma.ttias.be

When you don't use specific knowledge or skills, you may find that, eventually, you just forget said knowledge or skill.

Something embarrassing happened to me the other day. I was playing around with a new server on Digital Ocean and it occurred to me: I had no idea how to manage it. This is slightly awkward because I've been a sysadmin for over 10yrs, the largest part of my professional career.

Read more [ma.ttias.be]

Getting started with Varnish Cache

If you want to learn Varnish Thijs Feryn wrote a book for you. It's free to download until 7th March 2017.

Getting Strated with Varnish Cache is a technical book about the Varnish caching technology. Varnish is a so-called reverse caching proxy that acts as an intermediary between the browser and the webserver. Varnish stores HTTP responses and serves them to the browser, without accessing the backend for every request. This causes a massive speed increase.

https://blog.feryn.eu/my-varnish-book-is-now-available/

Read more

Protect your server with fail2ban

Jens Segers wrote an interesting little article about fail2ban. This piece of software prevents unauthorized pundits from accessing your server. You'll be happy to know that is installed by default on Forge.

The first thing I do on every server is set up the firewall so that all ports except for the SSH port are blocked from incoming requests. But with the SSH port unprotected, you still want it to be protected from illegitimate access, right? This is where fail2ban comes in. Fail2ban will automatically ban IPs that show the malicious signs such as too many password failures, seeking for exploits, etc.
https://jenssegers.com/82/protect-your-server-with-fail2ban

Read more

Upgrading PHP 5.6 to 7.0 on a Forge provisioned server

If you've read some posts before on this blog, then you'll probably know that I'm a big fan of Forge. The service makes it very easy to set up and administer servers. At my company we've been using it since it launched.

We currently have 80 provisioned servers. Most of them are small droplets. We have a policy of running every site on it's own droplet. This approach has many benefits, but that's maybe something for a future post.

The bulk of our servers are on PHP 5.6. That's not too bad, but once you have some sites on PHP 7, the sites running on those servers feel a bit slow. It's amazing how fast you get used to the speed that PHP 7 offers. That's why I experimented a bit with upgrading the PHP version on a Forge provisioned server. My gut feeling was that upgrading the PHP version is less work that setting up a new server and moving a site to it.

To not mess up a live site I created a snapshot and used that to set up a server to toy around with. With a little bit of research I came up with these instructions to upgrade the PHP version.

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.0

sudo apt-get install php7.0-fpm

Depending on your project you will need less or more php extensions, but these were the ones relevant for my site:

sudo apt-get install php7.0-gd

sudo apt-get install php7.0-mysql

sudo apt-get install php-memcached

sudo apt-get install php7.0-mcrypt

sudo apt-get install php-curl

sudo apt-get install php-imagick

Next, in the nginx configuration of the site I replaced unix:/var/run/php5-fpm.sock with unix:/var/run/php/php7.0-fpm.sock

The final adjustment I made was to make sure nginx would spawn the php processes under the forge. This will make sure that a php process can write to sites previously created by Forge:

// in the file /etc/php/7.0/fpm/pool.d/www.conf
...
user = forge
group = forge
...

After that I rebooted the server (maybe just restarting nginx is enough) and enjoyed browsing a site that was four times as fast. ?

If you decide to try this out for your server, be aware that what works for me doesn't necessarily work for you. Every site is a bit different. But I'm sure the instructions from this post will get you pretty far. Happy upgrading!

EDIT: Meanwhile DigitalOcean also published a guide on how to upgrade to PHP 7.

Read more

Let your clients use sftp on a Forge provisioned server original

by Freek Van der Herten – 3 minute read

A few years ago all the projects I worked on were served on a shared hosting environment. It was quite common that a client had ftp access to server to upload some files. A control like Cpanel or Plesk made it really easy to create some ftp accounts. Fast forward to today. Most projects are hosted…

Read more

Installing Imagick on a Forge provisioned PHP 7 server

Update added on 14th november 2017: Adding imagick on a forge provisioned server is now as simple as running sudo apt-get install php-imagick


Today I set up some PHP 7 servers on Forge. Those servers are going to be used to host some Blender based projects. Blender uses laravel-medialibrary to convert images. The package uses Imagick to do that. It turns out the Imagick PHP 7 extension isn't released yet. But there's an RC2 release candidate. Pascal Baljet provided this script to compile and install the extension.

#!/bin/bash
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget http://pecl.php.net/get/imagick-3.4.0RC2.tgz
tar xvzf imagick-3.4.0RC2.tgz
cd imagick-3.4.0RC2
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0RC2*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
service php7.0-fpm restart
service nginx restart

I was a bit worried that the extension would be unstable, but all image manipulations that I need on my projects (cropping and resizing some stuff), just worked. Mandatory disclaimer: your mileage may vary.

Read more

View disk space usage on Ubuntu original

by Freek Van der Herten – 1 minute read

A while ago, a disk of one of our DigitalOcean droplets had almost no free space. Ncdu (NCurses Disk Usage) is a command line tool to view and analyse disk space usage on Ubuntu. It can be installed with this command: sudo apt-get install ncdu Once it has been installed it can be launched by simply…

Read more