Installation
Server Requirements
Before you install Fresns, it's important to check that your server meets the requirements. To run Fresns, you will need:
Environment | Services |
---|---|
Web Server | Nginx or Apache or IIS or Caddy |
Package Manager | Composer 2.5 or higher |
Code Lang | PHP 8.1 or higher |
Database | MySQL 5.7 or 8.x |
PHP Config Requirements
- Extensions:
fileinfo
- Functions:
putenv
symlink
proc_open
passthru
Download
- Latest Version: v2.7.2 (2023-03-05)
Option 1: Download the full package manually
- Click to download
- Website engine and theme templates already built in
Option 2: Download via Composer
- Download the program
composer create-project fresns/fresns
- Configuration Manager
php artisan vendor:publish --provider="Fresns\PluginManager\Providers\PluginServiceProvider"
php artisan vendor:publish --provider="Fresns\ThemeManager\Providers\ThemeServiceProvider"
php artisan vendor:publish --provider="Fresns\MarketManager\Providers\MarketServiceProvider"
- If you need a website, please go to the application market to select a website engine and theme template
Installing
1. Config the Web Server
- Point the website directory to
/public/
- Add URL Rewriting to the configuration file
- Set directory folder ownership
Note: As the “website root directory” is not the “main program root directory”, the website will request the main program root directory file upwards when running, so please do not turn on the function configuration of anti-cross-site attack (open_basedir).
2. Install Config
- Access
{website}/install
- Check the environment and configure the database information according to the process
- Fill in the administrator information and register an administrator account
- Login Panel
{website}/fresns/admin
Config Intro
Task Scheduling
When running Fresns, you need a way to keep “scheduled tasks” running normally, and task scheduling of Laravel framework is a mechanism to ensure that main programs and plug-ins can use scheduled tasks. With task scheduling configured, the main program can regularly clean up and log off accounts and detect the expiration of user roles.
# Task Config
* * * * * cd /your-project-path && php artisan schedule:run >> /dev/null 2>&1
# or
su -c "cd /your-project-path && php artisan schedule:run >> /dev/null 2>&1" -s /bin/sh owner
# Example
* * * * * cd /www/wwwroot/fresns && php artisan schedule:run >> /dev/null 2>&1
# or
su -c "cd /www/wwwroot/fresns && php artisan schedule:run >> /dev/null 2>&1" -s /bin/sh www
.env Config File
After successful installation, there will be an .env
file in the root directory of the main program, which is used to store all the configuration information of Fresns. The details are as follows:
APP_ENV=production #Operating environment, local for test use, production for official operation
APP_KEY=Encryption Key #Data encryption key, which can be regenerated with the command php artisan key:generate
APP_DEBUG=false #Whether to output detailed error messages
APP_URL=Main Program URL #example https://discuss.fresns.com
APP_FOUNDER=1 #Founder Account ID (accounts->id)
DB_CONNECTION=mysql #Database Type
DB_HOST=127.0.0.1 #Default is 127.0.0.1
DB_PORT=3306 #Default is 3306
DB_DATABASE=fresns #Database
DB_USERNAME=fresns #Username
DB_PASSWORD=123456 #Password
DB_TIMEZONE=Asia/Singapore #Database Timezone
DB_PREFIX=fs_ #Default is fs_
Trusted Proxies
If you are running as a proxy, you need to configure .env
trusted IP information, multiple separated by English commas.
Let's take the Cloudflare proxy environment as an example and configure IPv4 and IPv6
# IPv4
TRUSTED_PROXIES=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22
# IPv6
TRUSTED_PROXIES=2400:cb00::/32,2606:4700::/32,2803:f800::/32,2405:b500::/32,2405:8100::/32,2a06:98c0::/29,2c0f:f248::/32
# or All
TRUSTED_PROXIES=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,2400:cb00::/32,2606:4700::/32,2803:f800::/32,2405:b500::/32,2405:8100::/32,2a06:98c0::/29,2c0f:f248::/32
Cache Config
You may specify which cache driver you would like to be used by default throughout your application. Fresns supports popular caching backends like Memcached
, Redis
, DynamoDB
, and relational databases out of the box. In addition, a file based cache driver is available, while array
and null
cache drivers provide convenient cache backends for your automated tests.
- The default caching system is
File
, if you want to change it, we recommendRedis
orMemcached
caching. - Before you can change the cache configuration, you must install the appropriate PHP extension and then modify the `.env' file to include the cache configuration.
Redis
In addition to cache, other driver systems that support Redis can also be configured to use it.
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
CACHE_DRIVER=redis
BROADCAST_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis
Memcached
Memcached only supports drive cache and session.
MEMCACHED_HOST=127.0.0.1
MEMCACHED_PORT=11211
MEMCACHED_USERNAME=null
MEMCACHED_PASSWORD=null
CACHE_DRIVER=memcached
SESSION_DRIVER=memcached
Timezone Config
Fresns is a software that supports cross-time zone service. To ensure the consistency of time values, UTC time zone standard is adopted in the software.
Input time
- Considering the reason of the framework, the time zone option in the configuration file
.env DB_TIMEZONE
can only be based on PHP time zone function, which is named after the region. - The time entered the database from the framework will be processed into the time zone time configured by
.env DB_TIMEZONE
, that bypasses the framework will be processed into the database time zone by the database (the database time zone is usually the system time zone of the server where the database is located). Therefore, the time zone in the configuration file must be consistent with that in the database in order to ensure the accuracy of time. - The installation function of Fresns will randomly pair a PHP time zone function according to the UTC time zone you selected. If it does not conform to your region, please modify it in the
.env
file yourself. For example, Beijing, Shanghai, Singapore and Western Australia are all UTC+8 time zones, and any one of them can meet the standard. - In the background, you can check the UTC time zone of your database in the “Dashboard” system information.
Output time
- Fresns will automatically determine the UTC time zone of the database, and then output the time according to the client’s request.
- When there is no request from the client, the “Default Time Zone” set in “Site Settings” will be output by default. For example, if the database time zone is UTC+8 and the default time zone set by the site is UTC-7, the database time will be converted to UTC-7 by default when the client does not file a request.
- Requirement logic for the client time zone: when logging in, the user-defined time zone is preferred; If not logged in or not set by the user, the system time zone of the user’s device (computer or mobile phone) is obtained. If no system time zone is obtained, it will be based on the default time zone set by the site.
URL Rewriting
Make sure your Web server directs all requests to the public/index.php
directory file, and never try to move the index.php
file to the main program root directory. This is because running the program from the main program root directory will expose many sensitive files to the public Internet, which is a very unsafe way to run.
Nginx
location / {
try_files $uri $uri/ /index.php?$query_string;
}
Apache
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
IIS
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Caddy
rewrite {
to {path} {path}/ /index.php?{query}
}
Directory Structure
fresns/ // Main Program Root Directory
├── app/ // Core Code Directory
├── bootstrap/ // Bootstrap Framework Directory
├── config/ // Configuration File Directory
├── database/ // Data File Directory
├── extensions/ // Extensions Directory
│ ├── plugins/
│ ├── themes/
│ └── backups/
├── public/ // Website Root Directory
│ ├── assets/ // Extension Static Files
│ ├── static/ // Built-in Static Files
│ ├── index.php // Website Entrance File
│ ├── favicon.ico // Site ico Icon
│ └── robots.txt // Search Engine Robots Protocol
├── resources/ // Framework Resource Directory
├── storage/ // Framework Storage Directory
├── vendor/ // Packages Directory
├── .env // Configuration File (generated after installation is complete)
├── artisan // Framework Command File
├── compose.json // Package Config
├── compose.lock // Package Installation Info
├── fresns.json // Fresns Config
├── install.lock // Installation Lock File (after having this file, it is forbidden to execute the installation again)
└── LICENSE // Copyright Documents
Folder Ownership
During installation, Fresns may request that you make certain directories writable. To allow write access to a directory on Linux, execute the following command:
chmod 755 /path/to/directory
If Fresns requests write access to both the directory and its contents, you need to add the -R
flag so that the permissions are updated for all the files and folders within the directory:
chmod 755 -R /path/to/directory
If after completing these steps, Fresns continues to request that you change the permissions you may need to check that your files are owned by the correct group and user.
ENVIRONMENTS MAY VARY
Your environment may vary from the documentation provided, please consult your web server configuration or web hosting provider for the proper user and group that PHP and the web server operate under.
NEVER USE PERMISSION 777
You should never set any folder or file to permission level 777
, as this permission level allows anyone to access the content of the folder and file regardless of user or group.