FASTPANELWIKI

Websites

How to change a PHP mode

On this page

Introduction

FASTPANEL® allows to select one of four different PHP modes for each website individually. They are:

  • PHP as an Apache module
  • PHP-FPM
  • FCGI
  • CGI

To choose PHP mode, open "Settings" menu in the Site card. Please note that using any mode different from "Apache module" allows you to use an alternative PHP version if it is installed on the panel.

Which mode is better to choose?

  • If the website does not use the .htacess file, then you should select the PHP-FPM mode.
  • If the website uses the .htacess file and the main PHP version is suitable, then you should select the Apache module.
  • If the website uses the .htacess file and the alternative PHP version is required, then you should select the FastCGI mode.
  • CGI mode is better to be used as the last option if for some particular reason the website doesn’t work properly in the other modes.

Let's take a closer look at each mode.

PHP as Apache module

This mode uses a system-default PHP version. In this case Nginx is used as a Frontend server, and Apache - as a Backend one (scripts are processed by the mod_php module). Apache operates in MPM ITK mode which allows each website to operate under a separate user.

FastCGI

This mode allows switching between PHP versions. In this case Nginx is used as a Frontend server, and Apache - as a Backend one (scripts are processed by the mod_fcgid module). In FastCGI case processes are being kept in the server memory and process several requests which speeds up PHP scripts processing which, in turn, affects a site working speed. It is recommended to use this mode when an alternative PHP version is used.

PHP-FPM

This mode allows switching between PHP versions. In this case PHP-FPM is used as a Backend server and Nginx stays as a Frontend one. It is important to keep in mind that in this mode .htaccess files cannot be processed and all .htaccess settings have to be converted into Nginx configuration.

CGI

This mode allows switching between PHP versions. Apache operates as a Backend server and creates a separate PHP process for each request.

How to change a PHP version

On this page

Introduction

FASTPANEL® allows you to use alternative PHP versions for each site individually. You may install and use any PHP version starting from 5.3. You may apply any PHP version to your website starting from PHP 5.3

This article covers the following points:

PHP version change through the example of PHP 7.4

  1. Go to "Settings" -> "Applications" in the side menu

  2. Find php74 application, click "Install" and wait until the installation is completed:

  3. Open the card of the website that needs PHP changing and click on "Settings" menu

  4. Perform the following actions:

    • Open "PHP settings" submenu
    • Select FastCGI as the PHP mode
    • Select PHP version needed in the PHP version field.
    • Click "Save" button.

When "PHP Version" will become active you may choose required PHP version, php74 in this particular case.

Instead of FastCGI you can also choose PHP-FPM or CGI, but in 95% of cases it is FastCGI that is suitable. More information about PHP modes you can find here

You may check if the correct PHP version is applied by creating info.php file in the root directory of your website with the following content:

<?php phpinfo(); ?>

After that open the file via Internet browser by following the alike link http://yourwebsite.com/info.php

If everything is done correctly you will see a page showing technical information about php 7.4

How to change PHP (CLI) version for the user

FASTPANEL® allows you to select PHP versions for each user individually. This action will allow you to access the alternative version of PHP on the command line using the normal php command.

This action influences only on PHP version in the command line and on the tasks in the crontab scheduler. PHP versions selected for the websites will remain unchanged.

To change the PHP version for the user, open the "Users" menu. Choose the user, click on the "Edit user" icon, and select a suitable version in the "PHP (CLI) version" field

After changing this feature, reconnect the server via SSH. In the previously opened sessions the PHP version will remain the same.

How to use alternative PHP versions on command line (CLI)

As a rule, to run scripts through the command line, the following command is used:

php /path/to/script.php

This way the main server PHP version will be used, even if an alternative one was chosen for the website.

note

If beforehand the PHP version was changed according the instructions in How to change PHP (CLI) version for the user, then the common php command will use the chosen user’s PHP version, not the server’s one.

How to use alternative versions in crontab scheduler

To run the script through the alternative version, you should change the php command to the full path to the alternative interpreter. In case of PHP 7.4 it will be /opt/php74/bin/php, so the command will look like:

/opt/php74/bin/php /path/to/script.php

How to change PHP settings

On this page

Introduction

With the help of FASTPANEL®, you can set unique PHP settings for each website individually.

note

Apart from PHP settings for each site, it is possible to make default settings for each PHP branch. This feature is described here.

Editing PHP settings

To edit PHP settings, go to the "PHP Settings" section of the Site card

This section contains all PHP settings that can be applied to the website

The list of settings shows:

  • the setting name
  • a module the setting belongs to
  • the setting value
  • the information if the setting has been changed or not

How to grant access for a developer to specific site

On this page

Introduction

FASTPANEL® includes an option to provide limited access to the panel with custom rights to a particular website.

How to set up additional access to the site

To start with, go to site card and open "Access to management" menu

"Access to management" menu shows the list of users who are granted permissions to manage the site. The list contains the following columns:

  • User’s email address
  • User’s permissions
  • User’s settings

To grant access click "Add access" and in the window that opens enter the email address to grant access to

Then specify permissions for the user. They could be as follows:

  • Files - access to the site files
  • Database - access to the site database
  • Scheduler - access to task management for the site
  • FTP - accounts - access to the site FTP account settings

You can choose any privileges combination

After a user is created, an email with panel access credentials will be sent to the address specified. These additional users can assess the panel just like any other user by using the type link: https://IP_ADDRESS:8888/

You can grant access the same way during the last step of website creating via the Site Creation Wizard.

How to install a Laravel based site

On this page

The installation is done using composer. The domain used as an example is example.com and the user of the site is user.

Preparation

Installing Composer

Install composer in FASTPANEL® in the "Applications" section

Creating a website

Create a website in FASTPANEL® and specify the public subdirectory in the site settings in the "Site Directory" section.

Creating a project

To create a project, you need to connect to the server via SSH using the data of the site owner. The site owner is shown in the site card in FASTPANEL

After SSH connection is established, you should clear the site directory using the following command example (instead of example.com specify your site name)

rm -rf /var/www/user/data/www/example.com/*

Then go to the site directory

cd /var/www/user/data/www/example.com

And create a project

composer create-project laravel/laravel ./
Example of output in case of correct installation
73 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
76 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
No security vulnerability advisories found
> @php artisan key:generate --ansi
Application key set successfully.

Installing a specific version of Laravel

To install a specific version, when creating a project, you must specify the version at the end of the command in quotation marks

composer create-project laravel/laravel ./ "5.8.*"

Database connection

  • For artisan specify the data to connect to the database in the file.env in the site directory
  • For the site, specify the data to connect to the database in the file ./config/database.php

To edit the .env file you may use a text editor called nano via SSH:

nano .env
Example of .env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=site_db
DB_USERNAME=db_user
DB_PASSWORD=0j9vd3qATwTsXW7C

To edit the ./config/database.php file via SSH:

nano ./config/database.php
Example of ./config/database.php
    'mysql' => [
        'driver' => 'mysql',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'site_db'),
        'username' => env('DB_USERNAME', 'db_user'),
        'password' => env('DB_PASSWORD', '0j9vd3qATwTsXW7C'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'prefix_indexes' => true,
        'strict' => true,
        'engine' => null,
        'options' => extension_loaded('pdo_mysql') ? array_filter([
            PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
        ]) : [],
    ],

In the nano editor, Ctrl+O is used to save changes, Ctrl+X is used to exit the editor.

Memcached connection (optional)

You need to install the PHP memcached module for the PHP version used on the site, as well as install the application.

Installing the memcached PHP module
Installing the memcached application
Editing a configuration file

Specify the data to connect to memcached in file ./config/cache.php

Example of ./config/cache.php
'memcached' => [
    'driver' => 'memcached',
    'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
    'sasl' => [
        env('MEMCACHED_USERNAME'),
        env('MEMCACHED_PASSWORD'),
    ],
    'options' => [
        // Memcached::OPT_CONNECT_TIMEOUT => 2000,
    ],
    'servers' => [
        [
            'host' => env('MEMCACHED_HOST', '127.0.0.1'),
            'port' => env('MEMCACHED_PORT', 11211),
            'weight' => 100,
        ],
    ],
],

Using Artisan on a non-system version of PHP

To use artisan on a non-system version of PHP, you must specify the full path to the executable file. Example of using an alternative php version 8.2:

/opt/php82/bin/php artisan list

Basic Artisan commands

Commands should be executed in a root directory of your project (example.com in this example)

cd /var/www/user/data/www/example.com

To view a list of all available Artisan commands, you can use the command

php artisan list

Launch a local Laravel development server. You can specify the --host and --port keys

php artisan serve

Start migration

php artisan migrate

Enabling maintenance mode on the site, key --redirect=/ to specify the page for maintenance mode

php artisan down

Turning off the maintenance mode on the site

php artisan up

Systemd

On this page

Introduction

With Systemd, we can run any application as a service.

FastAPI

As an example, consider running the FastAPI framework:

  1. Create a website using the "Systemd" template.
  1. Connect to the server via SSH as the root user.
  2. Install the required packages:

Debian/Ubuntu:

apt update && apt install python3-pip python3-venv -y

Rocky Linux/AlmaLinux:

yum install python3-pip python3-virtualenv -y
  1. Switch to your site’s system user:
su - yoursiteuser

Replace yoursiteuser with the actual username.

note

You can determine the site user in the site card, field "Site user". To change the site user password, go to "Management" → "Users" section in FASTPANEL®.

  1. Create a virtual environment and activate it:
python3 -m venv myenv
source myenv/bin/activate

Replace myenv with the desired environment name.

  1. Install the required packages for FastAPI:
pip install fastapi uvicorn
  1. Deactivate the virtual environment:
deactivate
  1. Create a file main.py in the website directory with the following content:
import os
import uvicorn
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"hello": "world"}

if __name__ == "__main__":
    port = int(os.getenv("SERVICE_PORT", 8000))
    uvicorn.run(app, host="0.0.0.0", port=port)
  1. In the site dashboard, go to “Settings” → “Backend”.
  • Set "Launch command" to: python3 main.py
  • Save and check the website

Logs

A Systemd service can generate logs. In FASTPANEL®, they are located in the site dashboard, in the "Logs" section, under the "Backend log" tab.

How to create a WordPress based site

On this page

Introduction

Most content management systems are distributed in archive packages that need to be unpacked and installed on a server. This article will guide you through creating a site in FASTPANEL®, using the installation of the most popular CMS as an example.

You can create WordPress based site two ways:

info

We recommend to create a separate user for each new website.

Automatic CMS installation

First of all you need to prepare the panel by creating a new site. In order to do that start the Site Creation Wizard by clicking "Create site" button on the right side of the screen.

On the first step of Site Creation Wizard you can install WordPress for the site you have just created.

This will open the Site Creation Wizard. The whole process contains three steps:

  • Domain connection
  • Setting up CMS settings
  • Site user's credentials

Simply input username and password for the future site administrator and the rest will be done by the panel itself.

After that you input site user's data

info

This is not WordPress administator credentials. It is for user on server that own site.

Follow the Wizard instructions and complete the site creation.

note

Be sure to save the database and FTP account access data in a safe place

You can also "View", "Download" or "Send" the access data to your site:

In order to proceed, click "Site card"

Manual CMS installation

First of all you need to prepare the panel by creating a new site. In order to do that use this manual

After site creation first of all you need to download an installation package. In this particular case you can do it by following the link and save the archive on your computer.

In the site card click "Files" to get to the File Manager.

In the opened modal window click "Upload" or simply drag and drop the archive to the workspace

In the opened module window choose the previously downloaded WordPress distribution archive

Right-click the archive and select "Extract from the archive"

note

For space saving purposes you may delete the archive after extraction.

Now you are just a few steps from completing WordPress installation. Enter WordPress directory by double-clicking it. Select all files and directory and click "Move"

Go to the site main directory and click "Paste"

After WordPress is unpacked, open your site in the browser to access WordPress installation wizard. Finish the installation by following the installation wizard instructions.

Logs

On this page

Introduction

Analyzing site logs allows to audit its work and use the statistics for various purposes.

FASTPANEL® provides a special module to view access logs and error logs, and there is also a log analyzer module – AWStats.

Setup

To setup log options:

  1. Go to a site card
  2. Select "Settings"
  3. Open "Log settings" menu

In this menu you can configure the following options:

  • Enable/disable site access logging
  • Enable/disable logging of site errors
  • Choose the number of log files stored after rotation
  • Site logs rotation periodicity

How to view site logs?

To view site logs open "Logs" section in the Site card

This section contains access and error logs for frontend and backend servers. Each log has its own tab:

  • Frontend access log (Nginx)
  • Frontend error log (Nginx)
  • Backend access log (Apache, PHP-FPM)
  • Backend error log (Apache, PHP-FPM)

Is there any tool to work with statistics?

FASTPANEL® provides the AWStats application, which allows you to generate visual reports on site visits based on automatic analysis of website logs.

To use AWStats make sure to install it via the "Applications" menu

After it is installed, "AWSTATS" tab will appear in "Logs" section.

This tab allows to enable or disable the periodic report generation. When enabled, reports will be generated every 6 hours. After a report is generated, it can be opened. Moreover, you can run logs checking and report generation out of schedule, manually.

How to create a new website

On this page

Introduction

This article will guide you through how to create a site in FASTPANEL®.

info

We recommend to create a separate user for each new website.

Creating a website

To create a new site, start the "Site Creation Wizard" by clicking the "Create site" button on the right side of the screen.

This will open the Site Creation Wizard. The whole process contains three steps:

  • Domain connection
  • Setting up backend and database
  • Backup setup

The Site Creation Wizard offers the following options:

  • Create a CMS based site – Automatically create a site based on a CMS, with the ability to install WordPress in just a few clicks

  • PHP – Create a website or application using PHP

  • Node.js – Deploy a modern web application built with Node.js and the current JavaScript stack

  • Reverse proxy – Create a site that works as a reverse proxy for another service

  • Systemd – Run websites and services managed via systemd units as separate backend applications

  • Blank (static) – Create a static website that simply serves unchanging content (HTML, CSS, JS, images)

You can configure following settings:

  • User's credentials
  • Backend settings
  • Database settings
  • Backup plans
  • FTP access
  • SFTP access

Follow the Wizard instructions and complete the site creation.

note

Be sure to save the database and FTP account access data in a safe place

You can also "View", "Download" or "Send" the access data to your site:

Scanning

On this page

Introduction

By using the module "Scanning" you can check your website for malware code. The module is based on Ai-Bolit scanner by Revisium. AI-Bolit scanner is an effective tool for webmasters and site administrators to search for viruses, vulnerabilities and malware code.

note

The check does not affect the performance of the website or the control panel: you can continue working with the panel while the scanner is running

Upon completion, a report will be prepared and shown in the table below. The scanner only reports about found vulnerabilities and malware code. It will not remove or edit infected files.

The scan can be run according to the schedule or launched manually.

Scan site for containing viruses

To start scanning go to the Site card of the website you would like to scan and click "Scanning"

To start scanning manually, simply click "Run" and select scanning options you need

Scanning module supports three modes:

  • Express – scans only js, php, html and .htaccess files
  • Normal – scans all files for containing malware code in the site directory
  • Paranoid – scans all files for even potential vulnerabilities

Scanning settings also allow you:

  • to exclude certain types of files from scanning
  • to set the maximum size of files to be scanned
  • and to limit memory usage for the scanning script

Scheduled scan

In FASTPANEL® you may schedule scanning. Open "Settings" menu in the "Scanning" section. In the pop-up window you can configure the scan schedule: daily, weekly, monthly, or yearly. You may also set your own (arbitrary) schedule by clicking "Configure"

Scanning module also allows you to email reports. To use this feature enter you email address in the "Email" field.

After scanning is complete you will receive an email with a link to report:

Site settings

On this page

Introduction

To open site settings open the site card first and then select "Settings" menu

Settings has several submenus:

This menu also contains "Delete website" button which removes the site and all related data (files, domains, certificates, databases etc.)

Let’s have a closer look on each section:

Main settings

This submenu includes general site settings:

  • Enable/disable a website
  • Enable/disable temporary link usage
  • Domain
  • Admin email
  • Site encoding
  • IP-address, the site will be available at
  • Site aliases

HTTPS

This submenu contains management tools to make your site work via HTTPS protocol. After the certificate is specified in "SSL certificate field", additional options will appear:

  • HTTPS redirect - this option makes all requests redirected to HTTPS with 301 code. (Moved Permanently).
  • HSTS - when enabled this option sends Strict-Transport-Security header that forces browser to use HTTPS connection only
  • HTTP2 - enabling the second version of HTTP protocol

Redirects

This submenu contains redirect setting for incoming requests to the website:

  • The main site mirror - when it is enabled, requests will be redirected from aliases to the name specified in the parameter. For example, here you can set up a redirect from the main domain to the www subdomain, or vice versa.
  • Enable auto subdomains - Auto subdomains is a setting that automatically adds a wildcard alias (*.example.com) to the site. Subdomain files will be available from the main domain. They should be created in folders corresponding to the subdomain name in websites root directory. E.g. subdomains sub0.example.com root directory will be /var/www/www-root/data/example.com/sub0 .
tip

Please note that the wildacrd alias (*.example.com) must be added manually to the DNS.

Backend (PHP, Reverse proxy, etc.)

This submenu includes options for backend processing by the web server:

  • Backend type – The type of backend that will handle requests
    Available options: PHP, NodeJS, Systemd, Reverse proxy, Static content
  • Handler – The way the backend is connected to the web server, for example, Apache module
  • PHP version (can be changed only for a specific PHP modes)
  • Worker amount – Specified for PHP-FPM mode only
  • Application file – This option specifies the page to show upon request to the site
  • Working directory – Specifies a root directory to use for the website. Cannot be changed
  • Working subdirectory – Specifies the site directory if it needs to operate from non-root directory
  • Environment – Environment variables passed to the application (for example, operating mode, sandbox settings, etc.)

Static content

On this page

Introduction

FASTPANEL® allows to configure the parameters for serving static content by the server, such as images, CSS files, video files and others.

Configuring Static Content Processing

To manage static content processing:

  1. Go to the Site card
  2. Select "Settings" section
  3. Open "Static content" menu

In this menu you can manage static content processing by a web-server for the site. They are as follows:

  • Enabling/disabling compression (Gzip)
  • Setting gzip compression level (from 1 to 9) where 1 is the weakest compression and 9 is the strongest.
  • Configuring the caching time for static files in days (0 - no caching)
  • List of file extensions that web server will process as static content
note

It is recommended not to set the compression level greater than 5. Due to the reason that the greater the compression level is, the higher the CPU load is on your server

How to use Reverse Proxy mode

On this page

Introduction

FASTPANEL® supports Reverse Proxy mode, allowing you to define servers (e.g., web servers, application servers) to which incoming requests can be proxied.

To choose Reverse Proxy mode, open "Settings" menu in the Site card and select "Reverse proxy" from the "Backend (PHP, Reverse proxy, etc.)" menu.

Reverse Proxy types

Both a host and a Unix socket can be used.

Host

When using the Host type as the address, the URL or IP address must be specified together with the port.

Examples of correct Hosts:

  • http://127.0.0.1:3000
  • https://localhost:443
note

Using the https:// protocol together with unix:// or http:// is not possible.

Unix

When using the Unix type as the address, the path to the Unix socket must be specified.
The prefix unix:/ is not required.
For example /tmp/my_socket is a correct Unix socket address.

Multiple addresses

When specifying multiple addresses in the upstream list, requests will be distributed between the them using a round-robin balancing method.