Fuel PHP Framework

How to Install FuelPHP Framework on Ubuntu 24.04 or Newer

Welcome to the Greenhost.cloud blog! Today, we’ll guide you through the installation of FuelPHP, a flexible and community-driven PHP framework, on Ubuntu 24.04 or newer. FuelPHP is known for its simplicity, modularity, and scalability, making it a perfect choice for modern web applications.

Whether you’re an experienced developer or just starting, this step-by-step tutorial will help you get FuelPHP up and running smoothly on your Ubuntu machine. Let’s dive into the process!

Prerequisites

Before we begin, ensure you have the following prerequisites installed on your Ubuntu system:

  1. Ubuntu 24.04 or newer
  2. PHP (version 7.4 or newer)
  3. Composer (for managing PHP dependencies)
  4. Nginx or Apache (for serving your application)

Step 1: Update Your System

Open your terminal and update your package list to ensure you have the latest software:

sudo apt update && sudo apt upgrade -y

Step 2: Install PHP and Required Extensions

FuelPHP requires PHP and several extensions. Install PHP and the necessary extensions using the following command:

sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-json php-curl -y

Step 3: Install Composer

Composer is a dependency manager for PHP that will help us install FuelPHP. To install Composer globally, run the following commands:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Verify the installation by checking the Composer version:

composer --version

Step 4: Install FuelPHP

Now that you have Composer installed, you can create a new FuelPHP project. Navigate to the directory where you want to install FuelPHP, then run:

composer create-project fuel/fuel your_project_name

Replace your_project_name with the desired name of your project. This command will create a new directory with the FuelPHP framework and all its dependencies.

Step 5: Set Up Directory Permissions

FuelPHP requires certain directory permissions to function correctly. Navigate to your project directory and set the appropriate permissions:

cd your_project_name
sudo chmod -R 755 fuel/app/tmp
sudo chmod -R 755 fuel/app/cache

Step 6: Configure Your Web Server

For Nginx:

If you are using Nginx, create a new configuration file for your FuelPHP application:

sudo nano /etc/nginx/sites-available/your_project_name

Add the following configuration, replacing placeholders with your actual project path:

server {
    listen 80;
    server_name your_domain.com; # Replace with your domain or IP
    root /path/to/your_project_name/public; # Update with your project path

    index index.php index.html index.htm;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Adjust PHP version if needed
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Save and exit the editor, then enable the site and restart Nginx:

sudo ln -s /etc/nginx/sites-available/your_project_name /etc/nginx/sites-enabled/
sudo systemctl restart nginx

For Apache:

If you prefer Apache, create a new configuration file:

sudo nano /etc/apache2/sites-available/your_project_name.conf

Add the following configuration:

<VirtualHost *:80>
    ServerName your_domain.com # Replace with your domain or IP
    DocumentRoot /path/to/your_project_name/public # Update with your project path

    <Directory /path/to/your_project_name/public>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/your_project_name_error.log
    CustomLog ${APACHE_LOG_DIR}/your_project_name_access.log combined
</VirtualHost>

Enable the new site and the rewrite module, then restart Apache:

sudo a2ensite your_project_name.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 7: Access Your FuelPHP Application

Open your web browser and navigate to your domain or IP address. You should see the FuelPHP welcome page, confirming that the installation was successful!

Conclusion

Congratulations! You have successfully installed the FuelPHP framework on Ubuntu 24.04 or newer. You can now start building your PHP applications with the flexibility and power that FuelPHP provides.


For more insights and updates, consider subscribing to our blog or following us on social media. Thank you for reading.