Posts tagged with forge

🚀 Deploying a Laravel Project on Forge with Reverb WebSockets | Real-Time Setup Tutorial

– youtu.be - submitted by Bert De Swaef

Want to deploy your Laravel project on Forge with real-time WebSockets using Reverb? In this step-by-step tutorial, we’ll walk you through setting up Laravel Forge, configuring your server, and integrating Reverb for real-time communication. Whether you're building a chat app, notifications system, or live updates, this guide will help you get everything running smoothly.

Read more [youtu.be]

Join 9,500+ smart developers

Every month I share 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.

Automatic monitoring of Laravel Forge managed sites

– ohdear.app

Oh Dear!, the monitoring service that my buddy Mattias and I run, now has the ability to auto import sites from Forge.

Forge recently introduced a feature called tags, whichs allows you to add custom tags to any server or site in Forge. We use those tags to determine which sites we should automatically add to your Oh Dear! Account. Every site or server tagged with oh-dear will be added. This allows you to still pick which sites should - or should not - get monitored.

Read more [ohdear.app]

Setting up Laravel Horizon with Forge and Envoyer

Dries Vints, maintainer of Laravel.io, posted a step-by-step guide on how to get started with Laravel Horizon on a Forge provisioned server.

I recently installed Horizon for Laravel.io and while it wasn’t that hard to install, I still had to figure some things out. Since this was the first time setting everything up I thought I’d write up the steps to take to get started with Horizon and set everything up with Forge and Envoyer.

https://medium.com/@driesvints/laravel-horizon-with-forge-and-envoyer-82a7e819d69f

Read more

Free Wildcard SSL Using Forge + Cloudflare

If you need a free SSL certificate Let's Encrypt seems like the obvious way to go. But the installation and renewal process of Let's Encrypt surely has it's caveats. An alternative to Let's Encrypt is to use a free certificate issued by Cloudflare. On his blog Taylor Otwell published a post explaining how to request and install such a certificate.

I personally prefer to use Cloudflare, another service that offers free SSL certificates, as well as a variety of other free and paid services that are useful for web developers. I prefer Cloudflare because: - Cloudflare doesn’t require any renewal process to ever run on my server. LetsEncrypt renewals must run on my server at least every 3 months and that’s just one more thing that sometimes can (and does) go wrong. - Cloudflare supports wildcard sub-domains.

https://medium.com/@taylorotwell/free-wildcard-ssl-using-forge-cloudflare-ab0ebfbf129f

Read more

How agencies & freelancers should do web hosting

Andrew Welch of the New York based agency nystudio107 wrote a good overview of the options agencies & freelancers have regarding hosting.

Web hosting is something that many agencies and freelancers don’t give a whole lot of thought to. They just use whomever they’ve had a long-standing relationship with, and call it a day.

However, choosing the right host—and the right type of host—can be crucial to the success of a project. And the hosting world has changed a whole lot in the past few years, so let’s dive in.

https://nystudio107.com/blog/web-hosting-for-agencies-freelancers

At my company Spatie we're pretty happy with our choice to hosts our client projects on VPSes. We provision them using Laravel Forge and some custom ansible scripts.

Read more

Using Varnish on a Laravel Forge provisioned server original

by Freek Van der Herten – 12 minute read

For a project we're working on at Spatie we're expecting high traffic. That's why we spent some time researching how to improve the request speed of a Laravel application and the amount of requests a single server can handle. There are many strategies and services you can use to speed up a site. In…

Read more

An unofficial Forge API

You might not know this but Forge already has an API, it's just not a documented and feature complete one. Open up your dev tools and inspect the web requests being sent while you do various stuff on Forge.

Marcel Pociot published a new package called Blacksmith (great name Marcel) that can make calls to that API. Here are a few code examples taken from the readme:

$activeServers = $blacksmith->getActiveServers();

$server = $blacksmith->getServer(1);

$sites = $server->getSites();

$newSite = $server->addSite($site_name, $project_type = 'php', $directory = '/public', $wildcards = false);

$jobs = $server->getScheduledJobs();

$newJob = $server->addScheduledJob($command, $user = 'forge', $frequency = 'minutely');

Very cool stuff. Because the Forge API doesn't include a method to login, the package will under the hood just submit a filled in login form.

An official API for Forge has been on my wishlist for quite some time. Because Forge's code base already includes an API my guess is that it wouldn't be too work to grow it in to a full, publicly available one. Though I surely cannot read Taylors mind, I think that if there were some more indications that a Forge API would be used by enough people, there's a higher chance that an official API would be built. I think the only reason why the API hasn't been built yet is because not enough people are asking for it. It makes sense for Taylor to only work on things that would actually be used. So if you are using Forge and do want an official API go ahead and star the BlackSmith package on GitHub and make some noise about it.

Read more

Cloudflare adds support for http2 server push

Cloudflare pushes forward! Read the entire article for a good explanation on http2 and server push.

Today, we’re happy to announce HTTP/2 Server Push support for all of our customers. Server Push enables websites and APIs to speculatively deliver content to the web browser before the browser sends a request for it. This behavior is opportunistic, since in some cases, the content might already be in the client’s cache or not required at all.
https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2/

In semi-related news: Laravel Forge recently made a nice change as well. If you install an ssl certificate on a Froge provisioned server, http2 will be enabled by default.

Read more

Enable http2 on a Forge provisioned server

Added on 2016-04-28: newly provisioned Forge servers will now use http2 by default whenever you install an ssl certifcate.

Like mentioned in the post on how to upgrade PHP, I'm a big fan of Forge. By default sites provisioned by Forge use regular http. Let's learn how to enable http2.

The http2 protocol provides a lot of benefits over http. In short it'll make your website load much faster. If want to know how this protocol works under the hood watch this excellent video by Mattias Geniar or read this blogpost at Cloudflare. Here an interesting test by (again) Mattias that shows the potential speed improvements.

A prerequisite for using http2 is that you serve your website via an encrypted connection (note: this is not 100% true but virtually all major browsers won't support http2 via unencrypted connections). Thanks to LetsEncrypt you can get free ssl certificates. Watch this free video on Laracasts to learn how to install a LetsEncrypt certificate.

Support for http2 was introduced in Nginx 1.9.5. You can check the version number of your Nginx installation by running nginx -v. If you're on 1.9.5 or higher you're good. You just have to add http2 to a server block in the Nginx configuration:

server {
  listen 443 ssl http2;
  ...
}

The Chrome developer tools can be used to check if you're site is indeed using http2. The column "protocol" should display "h2".

http2

Don't be overwhelmed with sadness if you're running something below Nginx 1.9.5. Upgrading is easy! Only three instructions are needed to upgrade to, at the time of this writing, Nginx 1.9.14:

sudo add-apt-repository ppa:nginx/development
sudo apt-get update
sudo apt-get install nginx

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

What would make Laravel Forge even better original

by Freek Van der Herten – 2 minute read

A little over a year ago Laravel Forge was launched. At Spatie we currently have 60 servers that are provisioned by and administered using it. I'm assuming we still hold the biggest Forge-account. By this time next year the number of servers will probably be higher. So yeah, I'm a very happy…

Read more