Carbon is one of the main datetime libraries used during Laravel development, and it provides many friendly functions for datetime manipulation and mathematics. But what if you want to test code which calls functions such as today()
or now()
?
Blog
PHP fpm process manager options explained
PHP FPM (FastCGI Process Manager) is a popular technology for processing php directives, particularly when used in conjunction with NGINX although it can be used with Apache.
In a common deployment scenario, the webserver is configured as a reverse-proxy with fpm providing the heavy lifting by processing the php code. Some of the most significant benefits of this approach are the ability to scale both up and out as your site or application grows.
Although every Linux distribution will work ‘out of the box’, there are a number of parameters which can be tuned to enhance performance.
Continue reading “PHP fpm process manager options explained”
Permanent redirects with Nginx
Recently, I had the need to redirect all traffic from one domain to identical URLs on a new domain. Luckily, NGINX provides a simple way to accomplish this.
The following will work as an available site for domain www.domainone.com on any NGINX version after 0.9.1:
server {
server_name www.domainone.com;
return 301 http://www.domaintwo.com$request_uri;
}
The server will listen on port 80 for request to www.domainone.com
and redirect to the same request at www.domaintwo.com
.
Note that the server is being asked to provide a 301 status code to inform the requesting client that the redirect is permanent. If you are wishing to redirect encrypted traffic then you will need a similar block listening at port 443.
Importing missing apt keys
This is another one where I get a mental blank. I know there is a way to import a new gpg key for apt, but I always have to look it up.
sudo apt-key adv --keyserver keys.gnupg.net --recv 886DDD89
And that is all there is to it. (Substitute your favourite keyserver and the correct key, obviously).
Using wireshark without root
Wireshark is a great and powerful tool, but for too long I’ve just been starting it as root, and ignoring the nag-screen that Debian keeps throwing at me. But it’s dead simple to do it the right way without root privileges.
Continue reading “Using wireshark without root”Adding users to groups
It’s embarrassing. I just have a mental block when it comes to adding an existing user to an existing group.
sudo adduser user group
or to remove a user from a group
sudo deluser user group
Meh!
Ipsec on a small LAN
Most tutorials cover implementing IPsec as a VPN solution between two sites, but what if you want to secure communications on one site representing a not atypical home LAN with a couple of machines: some wireless, some Linux, some Android, some Windows, and a dual ipv6/ipv4 stack (courtesy of Hurricane Electric’s free TunnelBroker service)? And to make life more difficult, there are some devices that don’t support IPsec at all. Obviously, you need at least two IPsec capable machines for this to make much sense.
Does it work, and how well?
Continue reading “Ipsec on a small LAN”Streaming multiple DAB channels from an RPi
There are any number of ways to listen to BBC radio over the web. You can use iPlayer for live and catchup, or you can stream to a client using one of the many published urls.
But to save my bandwidth I decided to stream the BBC’s DAB over my local network using a spare DVB-T USB stick. Although I used a Raspberry Pi for the guide, it would work equally well with any modern Linux distro.
Throughout this guide my RPi has a hostname of ‘raspberry’: replace this with your own hostname or ip address as appropriate.
Continue reading “Streaming multiple DAB channels from an RPi”