How to install FuelPHP with Nginx on a Debian 8 VPS

fuelphpFuelPHP is a PHP framework which is simple, flexible and driven by the community. It is designed from the ground up to support the Hierarchical model–view–controller (HMVC) and it provides command line tool to create projects, debug projects or perform similar tasks. Today we will show you how to install FuelPHP on a Linux VPS.

Since we are going to install FuelPHP on a Debian 8 VPS with Nginx as a web server already preinstalled, make sure that you have Nginx preinstalled on your server too. If you do not have Nginx preinstalled on your server you can use our LEMP stack installation guide to install Nginx and the other LEMP stack components.

If Nginx is installed on your server you can continue with the instructions below.
First of all, connect to your server via SSH and update all your system software to the latest version available. Use the commands below for that purpose:

sudo apt-get update
sudo apt-get upgrade

This could take a few moments. Once the update is completed, you can continue with the other steps. Go ahead and install Git by using the following command:

sudo apt-get install git-core

We will use the quick installer to install FuelPHP. First download the Oil package using curl:

curl get.fuelphp.com/oil | sh

This will download the Oil package and will store it into the ‘/usr/bin’ directory on your Debian VPS. Later, you can use Oil to create Fuel projects. To create a new FuelPHP project, navigate to the ‘/var/www’ directory:

cd /var/www/

and issue the following command:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
oil create first_project

It will take a few moments for your first project to be ready. The installer will also run ‘oil refine install’ and ‘php composer.phar update’ which make some of the necessary directories writable and pull the composer dependencies.

Now, create a new Nginx configuration file and add the following virtual block for your domain name:

nano /etc/nginx/sites-available/domainname

Enter the following content:

server {
    server_name domainname.com;

    access_log /var/log/nginx/domainname.com-access.log;
    error_log /var/log/nginx/domainname.com-error.log;
    root /var/www/first_project/public;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param FUEL_ENV "production";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Do not forget to replace domainname.com with your actual domain name. Save the file, enable the site and restart Nginx so the changes can take effect. Now you should be able to access your first FuelPHP project using a web browser. Open you favorite web browser and navigate to your domain name.

To get started with FuelPHP our recommendation is to read the official FuelPHP documentation available at http://fuelphp.com/docs/. There you can find more information about how to configure your application, how to configure a database etc.

Of course you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install FuelPHP for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment