所有配置文件都存储在 config/. 每个选项都有说明,因此您可以随意浏览文件并熟悉可用的选项。
常见的Web服务器及其配置可以在下面找到
要求:
mod_rewrite
AllowOverride
选项有时你可能要.htaccess
文件中注释掉:
##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
# RewriteBase /
如果已安装到子目录,则还应添加子目录的名称:
RewriteBase /mysubdirectory/
编辑.
nano /etc/nginx/sites-available/default
在服务器部分中使用以下代码。如果已将October安装到子目录中,请将第一个/位置指令替换为安装在October下的目录:
location / {
# Let OctoberCMS handle everything by default.
# The path not resolved by OctoberCMS router will return OctoberCMS's 404 page.
# Everything that does not match with the whitelist below will fall into this.
rewrite ^/.*$ /index.php last;
}
# Pass the PHP scripts to FastCGI server
location ~ ^/index.php {
# Write your FPM configuration here
}
# Whitelist
## Let October handle if static file not exists
location ~ ^/favicon\.ico { try_files $uri /index.php; }
location ~ ^/sitemap\.xml { try_files $uri /index.php; }
location ~ ^/robots\.txt { try_files $uri /index.php; }
location ~ ^/humans\.txt { try_files $uri /index.php; }
## Let nginx return 404 if static file not exists
location ~ ^/storage/app/uploads/public { try_files $uri 404; }
location ~ ^/storage/app/media { try_files $uri 404; }
location ~ ^/storage/temp/public { try_files $uri 404; }
location ~ ^/modules/.*/assets { try_files $uri 404; }
location ~ ^/modules/.*/resources { try_files $uri 404; }
location ~ ^/modules/.*/behaviors/.*/assets { try_files $uri 404; }
location ~ ^/modules/.*/behaviors/.*/resources { try_files $uri 404; }
location ~ ^/modules/.*/widgets/.*/assets { try_files $uri 404; }
location ~ ^/modules/.*/widgets/.*/resources { try_files $uri 404; }
location ~ ^/modules/.*/formwidgets/.*/assets { try_files $uri 404; }
location ~ ^/modules/.*/formwidgets/.*/resources { try_files $uri 404; }
location ~ ^/modules/.*/reportwidgets/.*/assets { try_files $uri 404; }
location ~ ^/modules/.*/reportwidgets/.*/resources { try_files $uri 404; }
location ~ ^/plugins/.*/.*/assets { try_files $uri 404; }
location ~ ^/plugins/.*/.*/resources { try_files $uri 404; }
location ~ ^/plugins/.*/.*/behaviors/.*/assets { try_files $uri 404; }
location ~ ^/plugins/.*/.*/behaviors/.*/resources { try_files $uri 404; }
location ~ ^/plugins/.*/.*/reportwidgets/.*/assets { try_files $uri 404; }
location ~ ^/plugins/.*/.*/reportwidgets/.*/resources { try_files $uri 404; }
location ~ ^/plugins/.*/.*/formwidgets/.*/assets { try_files $uri 404; }
location ~ ^/plugins/.*/.*/formwidgets/.*/resources { try_files $uri 404; }
location ~ ^/plugins/.*/.*/widgets/.*/assets { try_files $uri 404; }
location ~ ^/plugins/.*/.*/widgets/.*/resources { try_files $uri 404; }
location ~ ^/themes/.*/assets { try_files $uri 404; }
location ~ ^/themes/.*/resources { try_files $uri 404; }
如果您的网络服务器正在运行Lighttpd,您可以使用以下配置来运行OctoberCMS。使用您喜欢的编辑器打开您的站点配置文件。
nano /etc/lighttpd/conf-enabled/sites.conf
将以下代码粘贴到编辑器中,然后更改host
地址和 server.document-root
以匹配您的项目.
$HTTP["host"] =~ "domain.example.com" {
server.document-root = "/var/www/example/"
url.rewrite-once = (
"^/(plugins|modules/(system|backend|cms))/(([\w-]+/)+|/|)assets/([\w-]+/)+[-\w^&'@{}[\],$=!#().%+~/ ]+\.(jpg|jpeg|gif|png|svg|swf|avi|mpg|mpeg|mp3|flv|ico|css|js|woff|ttf)(\?.*|)$" => "$0",
"^/(system|themes/[\w-]+)/assets/([\w-]+/)+[-\w^&'@{}[\],$=!#().%+~/ ]+\.(jpg|jpeg|gif|png|svg|swf|avi|mpg|mpeg|mp3|flv|ico|css|js|woff|ttf)(\?.*|)$" => "$0",
"^/storage/app/uploads/public/[\w-]+/.*$" => "$0",
"^/storage/temp/public/[\w-]+/.*$" => "$0",
"^/(favicon\.ico|robots\.txt|sitemap\.xml)$" => "$0",
"(.*)" => "/index.php$1"
)
}
web.config: .
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="OctoberCMS to handle all non-whitelisted URLs" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/.well-known/*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/storage/app/uploads/.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/storage/app/media/.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/storage/temp/public/.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/themes/.*/(assets|resources)/.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/plugins/.*/(assets|resources)/.*" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="^/modules/.*/(assets|resources)/.*" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
可在config/app.php配置文件中,默认情况下debug
处于启用状态.
启用后,但在实时生产站点中使用时,应始终禁用调试模式
启用时,调试模式使用以下功能:
Important: Always set the
app.debug
setting tofalse
for production environments.
安全模式设置可在config/cms.php配置文件中找到,并带有enableSafeMode参数。默认值为null。
如果启用了安全模式,出于安全原因,CMS模板中的PHP代码部分将被禁用。如果设置为null,则在禁用调试模式时安全模式打开。
oc 提供了一种简单的方法来保护您的应用程序免受跨站点请求伪造。首先,随机令牌放在用户的会话中。然后,当使用开始表单标记时,将令牌添加到页面并随每个请求一起提交.
虽然默认情况下启用CSRF保护,但您可以使用配置文件中config/cms.php
的enableCsrfProtection
禁用它
oc 平台和一些市场插件将分两个阶段实施变更,以确保平台的整体稳定性和完整性。这意味着除了默认的stable build之外,它们还有一个 test build。
您可以通过config/cms.php
更改文件中的edgeUpdates
参数来指示平台更喜欢来自插件市场的测试版本。
/*
|--------------------------------------------------------------------------
| Bleeding edge updates
|--------------------------------------------------------------------------
|
| If you are developing with October, it is important to have the latest
| code base, set this value to 'true' to tell the platform to download
| and use the development copies of core files and plugins.
|
*/
'edgeUpdates' => false,
注意: 对于插件开发人员,我们建议在“插件设置”页面为市场上列出的插件启用测试更新。
注意: 如果使用 Composer 管理更新, 然后使用以下内容替换
composer.json
文件中的默认OctoberCMS要求,以便直接从开发分支下载更新。
"october/rain": "dev-develop as 1.0",
"october/system": "dev-develop",
"october/backend": "dev-develop",
"october/cms": "dev-develop",
"laravel/framework": "5.5.*@dev",
为了在生产环境中获得最高安全性,您可以将Web服务器配置为使用公共/文件夹以确保只能访问公共文件。
首先,您需要使用october:mirror
命令生成公用文件夹。
php artisan october:mirror public/
这将在项目的根目录中创建一个名为public/
的新目录,之后您应该修改Web
服务器配置以将此新路径用作主目录,也称为wwwroot
。
注意: 执行上述命令可能需要使用系统管理员或sudo权限。它也应该在每次系统更新后或安装新插件时执行。
为程序设置不同的运行环境,这通常很有用。您可以通过设置APP_ENV
环境变量来实现,默认情况下,它设置为production
。有两种常用方法可以更改此值:
1.直接设置您的网络服务器APP_ENV
.
例如,在Apache
中,可以将此行添加到.htaccess
或httpd.config
文件中:
SetEnv APP_ENV "dev"
2.在根目录中创建.env
文件:
APP_ENV=dev
在上述两个示例中,环境都设置为新的值dev
。现在可以在路径config/dev
中创建配置文件,并覆盖应用程序的基本配置。
例如,要仅为dev
环境使用不同的MySQL数据库,请使用以下内容创建名为config/dev/database.php
的文件:
<?php
return [
'connections' => [
'mysql' => [
'host' => 'localhost',
'port' => '',
'database' => 'database',
'username' => 'root',
'password' => ''
]
]
];
October
支持使用特定主机名检测到的环境。您可以将这些主机名放在环境配置文件中,例如config/environment.php
当通过global.website.tld
访问应用程序时,环境将设置为全局,同样适用于其他环境。
<?php
return [
'hosts' => [
'global.website.tld' => 'global',
'local.website.tld' => 'local',
]
];
DotEnv
配置作为基本环境配置 的替代方法,您可以在环境中放置常用值,而不是使用配置文件。然后使用DotEnv语法访问配置。运行october:env
命令将公共配置值移动到环境中:
php artisan october:env
这将在项目根目录中创建一个.env文件,并修改配置文件以使用env helper
函数。第一个参数包含在环境中找到的键名,第二个参数包含可选的默认值。
'debug' => env('APP_DEBUG', true),
您的.env
文件不应提交给应用程序的源代码控制,因为使用您的应用程序的每个开发人员或服务器都可能需要不同的环境配置。