Skip to content

Commit 8a34530

Browse files
committed
Update opencart installer to move system/storage folder
1 parent d64af10 commit 8a34530

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

install/deb/templates/web/nginx/php-fpm/opencart.stpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ server {
3737
rewrite ^/(.+)$ /index.php?_route_=$1 last;
3838
}
3939

40+
location /storage/ {
41+
deny all;
42+
return 404;
43+
}
44+
4045
location /vstats/ {
4146
alias %home%/%user%/web/%domain%/stats/;
4247
include %home%/%user%/web/%domain%/stats/auth.conf*;

install/deb/templates/web/nginx/php-fpm/opencart.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ server {
3131
rewrite ^/(.+)$ /index.php?_route_=$1 last;
3232
}
3333

34+
location /storage/ {
35+
deny all;
36+
return 404;
37+
}
38+
3439
location /vstats/ {
3540
alias %home%/%user%/web/%domain%/stats/;
3641
include %home%/%user%/web/%domain%/stats/auth.conf*;

web/src/app/WebApp/Installers/OpencartSetup.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function install(array $options = null) : bool
2929

3030
$this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot("config-dist.php"), $this->getDocRoot("config.php")]);
3131
$this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot("admin/config-dist.php"), $this->getDocRoot("admin/config.php")]);
32+
$this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot(".htaccess.txt"), $this->getDocRoot(".htaccess")]);
3233
$this->appcontext->runUser('v-run-cli-cmd', [
3334
"/usr/bin/php",
3435
$this->getDocRoot("/install/cli_install.php"),
@@ -41,6 +42,13 @@ public function install(array $options = null) : bool
4142
"--email " . $options['opencart_account_email'],
4243
"--http_server " . "http://" . $this->domain . "/"], $status);
4344

45+
// After install, 'storage' folder must be moved to a location where the web server is not allowed to serve file
46+
// - Opencart Nginx template and Apache ".htaccess" forbids acces to /storage folder
47+
$this->appcontext->runUser('v-move-fs-directory', [$this->getDocRoot("system/storage"), $this->getDocRoot()], $result);
48+
$this->appcontext->runUser('v-run-cli-cmd', [ "sed", "-i", "s/'storage\//'..\/storage\// ", $this->getDocRoot("config.php") ], $status);
49+
$this->appcontext->runUser('v-run-cli-cmd', [ "sed", "-i", "s/'storage\//'..\/storage\// ", $this->getDocRoot("admin/config.php") ], $status);
50+
$this->appcontext->runUser('v-run-cli-cmd', [ "sed", "-i", "s/\^system\/storage\//^\/storage\// ", $this->getDocRoot(".htaccess") ], $status);
51+
4452
$this->appcontext->runUser('v-change-fs-file-permission',[$this->getDocRoot("config.php"), '640']);
4553
$this->appcontext->runUser('v-change-fs-file-permission',[$this->getDocRoot("admin/config.php"), '640']);
4654

0 commit comments

Comments
 (0)