Laravel Forge Upgrade to PHP 7.1

Laravel Forge is a lovely service for not having to worry about your server deployment process. It really saves me a lot of time. However, I wish that the creators would support upgrading PHP versions for existing servers.

In the past, I destroyed my server and deployed a new one to benefit from the new PHP version. Since then, I have more websites and setting everything up again sounded like a lot of work. So, I decided to try and update the PHP version myself.


First, SSH into your Laravel Forge server and make sure that you have your sudo password; you will need it.

We will add Ondřej Surý list of PHP packages for Debian so that we can download the new version of PHP.

sudo add-apt-repository ppa:ondrej/php

We will now delete our local cache of packages forcing new packages to show up.

sudo apt-get update

Download PHP 7.1 and install it.

sudo apt-get install php7.1

Since Laravel Forge runs on Nginx, we will download the PHP-FPM package and its dependencies.

sudo apt-get install php7.1-fpm

Next up, we will update our Nginx configuration. Let's open the config with your editor. For this tutorial, I am using VI.

sudo vi /etc/nginx/sites-enabled/default

You should now see a file that looks like this:

include forge-conf/default/before/*;

server {
    listen 80 default_server;
    server_name default;
    root /home/forge/default/public;

    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    include forge-conf/default/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

    location ~ /\.ht {
        deny all;

include forge-conf/default/after/*;

Do not worry about all of the scary looking configuration parameters.

We want to change one line only. If you are using VI, you can hit "i" on your keyboard to enter insert mode. This will allow you to type. Change the following line: fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; Replace it with: fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

If you are using VI, you can hit "ESC" and then ":". This will bring up a ":" at the bottom. Write wq to save your changes and exit.

The hard part is out of the way.

Restart your server.

sudo service nginx restart

Your websites should now all be running on PHP 7.1. Congratulations!

You can check your PHP version with the following command:

php -v

You should see something like:

PHP (cli) (built: Jan 20 2017 09:43:29) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache, Copyright (c) 1999-2017, b                                                                                                                                                             y Zend Technologies

Good job and enjoy!

Posted: Sunday, February 05, 2017


fnu renaldi 2017-05-02 00:04:56

Stumbled upon your blog when googling for updating forge's PHP version, i've upgraded the PHP to 7.1, however in forge dashboard it still says PHP version is 7.0. It doesn't really matter but just curious if there's any file that forge look up on our server that define the PHP version. On a side note, Taylor's provided a mean to upgrade the server's PHP version now, not sure if you're aware of it or not but i though i'd mention it.

Sander 2017-07-27 13:40:54

This worked for me and helped me to upgrade from php 7.0 to php 7.1, thank you! I ran into some problems after updating my websites through composers and had to run these commands as well: apt-get install php7.1-mbstring sudo apt-get install php-xml sudo apt-get install php-mysql Thought I'd post them here so it might help others.

Ron 2017-08-18 20:26:57

Thanks for this it was very helpful. I first attempted to used the PHP upgrade in Forge UI but it kept failing. I did have a few issues. Posting below in case it helps others. sudo apt-get -y install libapache2-mod-php7.1 php7.1-fpm php7.1-common php7.1-cli php-pear php7.1-curl php7.1-gd php7.1-gmp php7.1-intl php7.1-imap php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-ps php7.1-readline php7.1-tidy php7.1-xmlrpc php7.1-xsl php7.1-apcu php7.1-curl php7.1-fpm php7.1-gd php7.1-gmp php7.1-json php7.1-mbstring php7.1-pgsql php7.1-readline php7.1-xml php7.1-zip php-memcached php-imagick ------------ In the file /etc/php/7.1/fpm/pool.d/www.conf update user/group ... user = forge group = forge Finally I had to reboot the server. Restarting nginx alone did not work for me.

Bogdan 2017-09-11 05:00:47

Thank you ron.

muah 2017-09-12 01:41:11

@Ron , focken legend i made all the updates and for 2 days all was working, but suddenly the site stopped and after pulling my hair for a full day, updating " /etc/php/7.1/fpm/pool.d/www.conf" user/group fixed it, many thanx for the tip

olidev 2018-01-18 12:36:02

This is much easier in Cloudways Laravel hosting platform. The PHP version can be upgraded to 7.1 from their server management tab in just 1 click, from the dropdown menu.

Cedric 2018-04-19 00:36:56

Hi, Thank you for this tutorial. I am trying to upgrade from PHP 5.6 to PHP 7.1 on my laravel forge (digital ocean) project. I did everything until: sudo vi /etc/nginx/sites-enabled/default But it looks like my /etc/nginx/sites-enabled/default is empty. Is that possible? What should I do? Thank you !!

Ahmad 2018-08-08 22:11:00

casinos online cassino casino online casino online online casino

m rollex11 2018-11-17 04:21:12

Having read this I believed it was really enlightening. I appreciate you spending some time and energy to put this informative article together. I once again find myself spending a significant amount of time both reading and commenting. But so what, it was still worth it!

sky777 casino 2018-11-29 07:14:39

Pretty nice post. I just stumbled upon your weblog and wished to say that I have really enjoyed surfing around your blog posts. After all I will be subscribing to your rss feed and I hope you write again soon!

lpe88 download android 2018-11-30 17:28:27

What i don't realize is if truth be told how you're now not really a lot more smartly-appreciated than you might be right now. You're so intelligent. You understand thus considerably on the subject of this matter, produced me personally believe it from so many numerous angles. Its like men and women aren't involved unless it's something to accomplish with Woman gaga! Your personal stuffs nice. All the time deal with it up!

3win8 slot 2018-11-30 22:56:15

each time i used to read smaller articles that as well clear their motive, and that is also happening with this post which I am reading at this place.

mega888 casino 2018-12-01 23:47:05

Hey there this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!

ntc33 download 2018-12-02 14:19:30

Hey there! Someone in my Facebook group shared this website with us so I came to give it a look. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Terrific blog and excellent design.

play8oy casino 2018-12-02 16:03:53

Hey just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Ie. I'm not sure if this is a formatting issue or something to do with web browser compatibility but I figured I'd post to let you know. The design and style look great though! Hope you get the issue solved soon. Kudos

918Kiss download 2018-12-03 11:38:41

Thank you for another fantastic article. The place else could anybody get that type of information in such an ideal approach of writing? I've a presentation next week, and I am at the search for such information.

ace333 apk 2018-12-04 05:16:36

For latest news you have to pay a visit the web and on the web I found this web site as a best web page for hottest updates.

rollex11 download 2018-12-05 07:04:40

Appreciating the time and effort you put into your site and detailed information you provide. It's nice to come across a blog every once in a while that isn't the same outdated rehashed information. Fantastic read! I've saved your site and I'm including your RSS feeds to my Google account.

918kiss 2018-12-06 03:32:39

Is actually very a reputable casino features given huge profits to millions of players world wide. How can model fee cover operators manning the phones 24/7? This isnEUR(TM)t your standard online casino either.

joker123 casino 2018-12-07 16:14:35

I've been browsing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the web will be much more useful than ever before.

918kiss big win 2018-12-11 21:47:32

Then change the Meta tags to another thing and re-submit your pages to the various search engines. The final step in generating links is the anchor text and URL target. And, to whom should you submit content material?

play8oy casino apk 2018-12-12 04:56:18

All 9 of these articles were taken by 9 separate entities. When my sweep was completed, I came across 9 of my articles being simply by someone else. You will have to get in each Hyperlink to know about its SEO statistics.

Leave a Comment