2 files didn’t have write access, I gave WRITE access to 2 files as well as entire folders bootstrap & cache
chmod -R 777 /var/www/clients/client1/web1/web/billing2/bootstrap/cache/config.php
chmod -R 777 /var/www/clients/client1/web1/web/billing2/bootstrap/cache/routes-v7.php
chmod -R 777 /var/www/clients/client1/web1/web/billing2/bootstrap/
chmod -R 777 /var/www/clients/client1/web1/web/billing2/bootstrap/cache/
now when I click on UPDATE NOW this is what I get: Server Error without any details.
from the LOG
/storage/logs/laravel.log
[2022-11-13 16:22:59] production.ERROR: SplFileInfo::isFile(): open_basedir restriction in effect. File(/var/www/clients/client1/web1/web/billing2/…) is not within the allowed path(s): (/var/www/clients/client1/web1/web/billing2:/var/www/clients/client1/web1/private:/var/www/clients/client1/web1/tmp:/var/www/billing2.mydomain.com/web/billing2:/srv/www/billing2.mydomain.com/web/billing2:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom:/usr/local/bin/phantomjs:/usr/share/php) {“userId”:1,“exception”:"[object] (RuntimeException(code: 0): SplFileInfo::isFile(): open_basedir restriction in effect. File(/var/www/clients/client1/web1/web/billing2/…) is not within the allowed path(s): (/var/www/clients/client1/web1/web/billing2:/var/www/clients/client1/web1/private:/var/www/clients/client1/web1/tmp:/var/www/billing2.mydomain.com/web/billing2:/srv/www/billing2.mydomain.com/web/billing2:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom:/usr/local/bin/phantomjs:/usr/share/php) at /var/www/clients/client1/web1/web/billing2/vendor/codedge/laravel-selfupdater/src/helpers.php:36)
[stacktrace]
Hi @anristudio
Maybe something with your open_basedir config is wrong.
From the InvoiceNinja Docs:
file_exists(): open_basedir restriction in effect
If you aren’t able to adjust the open_basedir restrictions the following steps may help:
Delete bootstrap/cache/config.php
Delete all log files in storage/logs
Another thing I ran into, was the .htaccess-Files in root folder and in the /public folder. This is necessary if you are on a subdomain like business.domain.com .
My root .htaccess looks this way:
The .htaccess in the /public folder:
Maybe this hints help you…
P.S. I need to adjust the .htaccess files after every Update since both file are overwritten by setup routine…
1 Like
Thanks @checkitsedo
I tried your suggestion with .htaccess without any luck
I also try deleting files you mentioned same issues
I run my own hosting, I have access to configure “open_base restrictions”. In my environment, root path to InvoiceNinja is already added to open_base restrictions. Am i missing something, do I need to add additional path to “open_base restrictions”?
open_basedir restriction in effect. File(/var/www/clients/client1/web1/web/billing2/…
@anristudio
Where does the domain https://billing2.domain.com/ points to?
In my Environment i use also a subdomain. The InvoiceNinja Path is /var/www/virtual/checkit/invoiceninja. Then I have a domain shortcut business.mydomain.com which points to /var/www/virtual/checkit/invoiceninja/public
I set the APP_URL in the .env to https://business.mydomain.com (without /public and without / at the end)…
Whats happened if you set open_basedir to none? This is surely not a solution, but could help finding reason why it doesn‘t work…
I\
checkitsedo:
open_basedir to none
https://billing2.domain.com/ is a subdomain, same URL is set in .env
If I set open_basedir = none I get Cannot update system because .htaccess is not writable?
I change both .htaccess files in root & public folder to 777 still same error
Ok, i don’t know, if it helps something, but I had always troubles to update Invoiceninja… So, this is my (working) workflow:
Go back to the last working version (without this I could not get a failed update to work afterwards)
Delete the invoiceninja folder completely.
restore from backup
rsync --verbose --recursive --links --perms --times --hard-links --acls --xattrs /path/to/backup/invoiceninja/ /var/www/virtual/checkit/invoiceninja/
restore folder permissions
restorecon -R /var/www/virtual/checkit/invoiceninja/
start invoiceninja queue (if available)
fix .htaccess (complete files below)
→ /var/www/virtual/checkit/invoiceninja/.htaccess
→ /var/www/virtual/checkit/invoiceninja/public/.htaccess
Ensure that Invoiceninja is working fine
create a backup of the database
mysql checkit_invoiceninja < /var/www/virtual/checkit/cechkit_invoiceninja.sql
update to latest version
→ git pull
→ git checkout v5-stable
→ composer install
→ php artisan ninja:post-update
correct files
→ /var/www/virtual/checkit/invoiceninja/.htaccess
→ /var/www/virtual/checkit/invoiceninja/public/.htaccess
Invoiceninja migrations (if neccessary)
→ php artisan migrate --force
call Invoiceninja
→ clear browser cache
→ https://business.mydomain.com/update?secret=secret
/var/www/virtual/checkit/invoiceninja/.htaccess
<IfModule mod_rewrite.c>
# Redirect HTTP to HTTPS:
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Make InvoiceNinja work in subdomains:
RewriteBase /
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule "^.env" - [F,L]
# RewriteRule "^storage" - [F,L]
RewriteRule ^(.well-known)($|/) - [L]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
# https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess
# ######################################################################
# # INTERNET EXPLORER #
# ######################################################################
# ----------------------------------------------------------------------
# | Iframes cookies |
# ----------------------------------------------------------------------
# Allow cookies to be set from iframes in Internet Explorer.
#
# https://msdn.microsoft.com/en-us/library/ms537343.aspx
# http://www.w3.org/TR/2000/CR-P3P-20001215/
<IfModule mod_headers.c>
Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
</IfModule>
# ######################################################################
# # MEDIA TYPES AND CHARACTER ENCODINGS #
# ######################################################################
# ----------------------------------------------------------------------
# | Character encodings |
# ----------------------------------------------------------------------
# Serve all resources labeled as `text/html` or `text/plain`
# with the media type `charset` parameter set to `UTF-8`.
#
# https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
AddDefaultCharset utf-8
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Serve the following file types with the media type `charset`
# parameter set to `UTF-8`.
#
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
<IfModule mod_mime.c>
AddCharset utf-8 .atom \
.bbaw \
.css \
.geojson \
.js \
.json \
.jsonld \
.manifest \
.rdf \
.rss \
.topojson \
.vtt \
.webapp \
.webmanifest \
.xloc \
.xml
</IfModule>
# ######################################################################
# # WEB PERFORMANCE #
# ######################################################################
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force compression for mangled headers.
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Map certain file types to the specified encoding type in order to
# make Apache serve them with the appropriate `Content-Encoding` HTTP
# response header (this will NOT make Apache compress them!).
# If the following file types wouldn't be served without the appropriate
# `Content-Enable` HTTP response header, client applications (e.g.:
# browsers) wouldn't know that they first need to uncompress the response,
# and thus, wouldn't be able to understand the content.
# http://httpd.apache.org/docs/current/mod/mod_mime.html#addencoding
<IfModule mod_mime.c>
AddEncoding gzip svgz
</IfModule>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Compress all output labeled with one of the following media types.
# IMPORTANT: For Apache versions below 2.3.7 you don't need to enable
# `mod_filter` and can remove the `<IfModule mod_filter.c>` & `</IfModule>`
# lines as `AddOutputFilterByType` is still in the core directives.
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/opentype" \
"image/svg+xml" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vtt" \
"text/x-component" \
"text/xml"
</IfModule>
</IfModule>
/var/www/virtual/checkit/invoiceninja/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Make InvoiceNinja work with subdomains:
# If you want to access InvoiceNinja via a subdomain and
# this rule is missing the browser will see a `500 internal server error`.
RewriteBase /
# 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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_headers.c>
# Blocks Search Engine Indexing
Header set X-Robots-Tag "noindex, nofollow"
# Prevents PDF File Caching
<FilesMatch ".pdf$">
Header set Cache-Control no-store
</FilesMatch>
</IfModule>
/var/www/virtual/checkit/invoiceninja/.env (excerpt)
APP_URL="https://business.mydomain.com" //important: no slash at the end
BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=database
INTERNAL_QUEUE_ENABLED=false
SESSION_DRIVER=file
SESSION_LIFETIME=120
REQUIRE_HTTPS="true"
NINJA_ENVIRONMENT="selfhost"
#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=snappdf
UPDATE_SECRET=yoursecret
DELETE_PDF_DAYS=60
DELETE_BACKUP_DAYS=60
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
If this doesn’t work, I don’t know what else you could try. Maybe some others can help…
david
November 14, 2022, 12:07am
38
can you try
sudo chown -R webuser:webuser bootstrap/
And then attempt the upgrade again.
Hi David,
I did
chown -R web1:client1 /var/www/clients/client1/web1/web/billing2/bootstrap/
(billing2 is the folder where my Invoice Ninja is installed)
when I attempt to upgrade from v5.3.15 to v5.6.31 I still get “not writable”
[2023-08-21 13:25:39] production.INFO: Cannot update system because ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90 is not writable
Anything else I could try?
Thanks in advance.
hillel
August 21, 2023, 2:18pm
40
As a workaround you can manually copy over the latest release zip.
Thanks Hillel!
I manually copied over v5.7.0 (zip), I’m getting blank white page when I go to URL, log shows this error now:
[Mon Aug 21 13:42:15.096751 2023] [proxy_fcgi:error] [pid 1420446:tid 140540148803328] [remote 98.63.16.68:59631] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught ReflectionException: Class “view” does not exist in /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php:889\nStack trace:\n#0 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(889): ReflectionClass->__construct()\n#1 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build()\n#2 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve()\n#3 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve()\n#4 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make()\n#5 /var/www/clients…; PHP message: PHP Fatal error: Uncaught ReflectionException: Class “view” does not exist in /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php:889\nStack trace:\n#0 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(889): ReflectionClass->__construct()\n#1 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build()\n#2 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve()\n#3 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve()\n#4 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make()\n#5 /var/www/clients…’
hillel
August 21, 2023, 6:48pm
42
Can you try running php artisan optimize
When I run “php artisan optimize” via command prompt I get:
Composer detected issues in your platform:
Your Composer dependencies require a PHP version “>= 8.1.2”. You are running 7.4.33.
PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 8.1.2”. You are running 7.4.33. in /var/www/clients/client1/web1/web/billing/vendor/composer/platform_check.php on line 24
My server runs Debian 11 which ships with php 7.4 as default. They don’t recommend changing default php version on the system. I have additional php versions installed: php 8.1 & php 8.2, which I assigned to the website where invoice ninja is installed.
hillel
August 22, 2023, 6:13am
44
The app requires both the web and CLI versions of PHP to be >= 8.
when I run “php8.2 artisan optimize” I see
In Container.php line 891:
Target class [db.schema] does not exist.
In Container.php line 889:
Class “db.schema” does not exist
I copied my working installation v5.3.15 to another subfolder and it works w/o issues
I downloaded latest zip v5.7.4 and overwrote all the files (except ones with .)
I get HTTP ERROR 500
When I run “php8.1 artisan cache:clear” or “php8.1 artisan optimize” I get error
In Application.php line 827:
Class “Coconuts\Mail\PostmarkServiceProvider” not found
Also, apache error log shows:
[Fri Aug 25 16:28:17.399851 2023] [proxy_fcgi:error] [pid 4124152:tid 139697823905536] [remote 99.99.99.99:60644] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught ReflectionException: Class “translator” does not exist in /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php:912\nStack trace:\n#0 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(912): ReflectionClass->__construct()\n#1 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\Container\Container->build()\n#2 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(933): Illuminate\Container\Container->resolve()\n#3 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Foundation\Application->resolve()\n#4 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(918): Illuminate\Container\Container->make()\n#5 /var/www/c…PHP message: PHP Fatal error: Uncaught ReflectionException: Class “translator” does not exist in /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php:912\nStack trace:\n#0 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(912): ReflectionClass->__construct()\n#1 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\Container\Container->build()\n#2 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(933): Illuminate\Container\Container->resolve()\n#3 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Foundation\Application->resolve()\n#4 /var/www/clients/client1/web1/web/billing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(918): Illuminate\Container\Container->make()\n#5 /var/www/c…’
hillel
August 25, 2023, 10:14pm
48
It may help to run composer install
Thanks @hillel I did, I still get same issues. Any other ideas?
root@server:/var/www/clients/client1/web1/web/billing# composer self-update
You are already using the latest available Composer version 2.5.8 (stable channel).
root@server:/var/www/clients/client1/web1/web/billing# php8.1 artisan optimize
In Application.php line 827:
Class “Coconuts\Mail\PostmarkServiceProvider” not found
root@server:/var/www/clients/client1/web1/web/billing# php8.1 artisan cache:clear
In Application.php line 827:
Class “Coconuts\Mail\PostmarkServiceProvider” not found
Progress.
I was able to run:
“php8.1 -f /usr/local/bin/composer update”
php8.1 artisan cache:clear
php8.1 artisan optimize
go to https://mywebsite/update?secret=mysecretkeyhere
Now I can get to login screen, but when I enter user & password, I still see: 500: Server Error
hillel
August 27, 2023, 12:59am
51
Are there any details about the 500 error in storage/logs?