How to install FuelPHP with Nginx on Debian 8

FuelPHP is a PHP framework that is simple, flexible and community driven. It is designed from the ground up to support the hierarchical model – view – controller (HMVC) and provides a command line tool for creating projects, debugging projects, or similar tasks. Today we are going to show you how to install FuelPHP on Linux.

Since we are going to install FuelPHP on Debian 8 with Nginx already preinstalled as the web server, make sure you have Nginx preinstalled on the server too. If you don’t have Nginx on your server, you can use the Nginx-based LEMP stack installation guide and other LEMP stack components.

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

sudo apt-get update
sudo apt-get upgrade

This may take several minutes. After the update is complete, you can continue with other steps. Go ahead and install Git using the following command:

sudo apt-get install git-core

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

curl get.fuelphp.com/oil | sh

This will download the Oil package and store it in the ‘/ usr / bin’ directory on Debian. Later, you can use Oil to create an alternate project. To create a new FuelPHP project, go to the ‘/ var / www’ directory:

cd /var/www/

and run the following command:

oil create first_project

It will take a few seconds, your first project will be ready. The installer will also run ‘oil refine install’ and ‘php composer.phar update’, which make some of the required write directories and pull composer dependencies.

Now create a new Nginx config 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.ru;

    access_log /var/log/nginx/domainname.ru-access.log;
    error_log /var/log/nginx/domainname.ru-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;
    }
}

Don’t forget to replace domainname.ru with your actual domain name. Save the file, enable the site, and restart Nginx for the changes to take effect. You should now be able to access your first FuelPHP project using your web browser. Open your web browser and go to your domain.

To get started with FuelPHP we recommend reading the official FuelPHP documentation available at http://fuelphp.com/docs/. There you can find more details on how to set up an application, how to set up a database, etc.

Sidebar