Installation

Last updated: Tue, 02 Jun 2020 19:13

This page describes the default installation for the most of HTTP projects. If you want use Berlioz Framework for CLI projects, go to CLI Project to know more.

Berlioz Framework

Installation of Berlioz Framework must be done by Composer, it's the recommended installation.

composer create-project berlioz/website-skeleton my-project --remove-vcs

You can specify the version to composer:

composer create-project berlioz/website-skeleton my-project "1.0" --remove-vcs

Info:

Option --remove-vcs remove automatically the .git directory from the default project.

HTTP server

To run the application, your HTTP server must be pointed on public directory.

Apache server

Apache is the most popular web server.

For Apache version >= 2.4:

<VirtualHost *:80>
    ServerName getberlioz.com
    DocumentRoot "/path/to/my-project/public"

    <Directory "/path/to/my-project/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

For Apache version < 2.4:

<VirtualHost *:80>
    ServerName getberlioz.com
    DocumentRoot "/path/to/my-project/public"

    <Directory "/path/to/my-project/public">
        AllowOverride All
        Allow from all
    </Directory>
</VirtualHost>

Warning:

Needs to enable the module mod_rewrite on Apache.

Cf. Apache documentation for installation.

If you want increase the performances of your server, disables support of .htaccess files.

For that, you must specify to Apache the fallback resource and disable AllowOverride option:

<Directory "/path/to/my-project/public">
    AllowOverride None
    FallbackResource /index.php
    # ...
</Directory>

Nginx

Nginx is a high performance web server.

To run PHP application with Nginx, you need to use PHP FPM (FastCGI Process Manager).

server {
    server_name getberlioz.com;
    root /path/to/my-project/public;

    # Test existent of file before redirect to fallback file: index.php
    location / {
        try_files $uri /index.php$is_args$args;
    }

    # Configuration for index.php file calls
    location ~ ^/index\.php(/|$) {
        # FastCGI configuration
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # FastCGI parameters to give directory and script infos
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        # To do not use index.php file for routes
        internal;
    }

    # To deny all others PHP files
    location ~ \.php$ {
        return 404;
    }
}

PHP HTTP server

If you want test application without Web Server to install, you can use built-in web server.

To start server:

cd /path/of/project
cd public
php -S localhost:8000 index.php

In your web browser, go to the url: http://localhost:8000, you will see your project!

Warning:

The PHP built-in web server is only for development environment. Do not use it in production!

Test first page

Go to in your favorite browser, and try to go to your page, in your example: getberlioz.com.

If everything ok, you will see this screen:

First page

You can also see on this first page, the debug console of Berlioz. If you click on, you will see the debug detail:

Debug