I was running an older version of InvoiceNinja and used the shell script to upgrade. The script went through, but when I tried opening Ninja it tried to redirect me to an ‘update’ page and that 404’d.
I suspect that when I’d set it up, I had done something weird with .htaccess but I don’t remember what it was, and it got overwritten on upgrade.
Any advice? I’m an apache noob and it sucks feeling helpless like I am.
I’m running Apache, and my sites-enabled entry looks like this:
Alias /ninja /var/www/ninja/public
<Directory /var/www/ninja/public>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
I tried changing the alias to /var/www/ninja (without the public) and the directory also to the same thing, but that didn’t help.
The shell script doesn’t touch anything outside of /var/www/ninja, so unless something went wrong during the update, that shouldn’t have harmed anything.
Try
<Directory /var/www/ninja/public>
AllowOverride All
</directory>
The .htaccess file I’m talking about is in /var/www/ninja. I might have edited it when I set it up so that the URLs worked. I don’t remember what I did now.
I only provided the sites-enabled entry as additional info to help diagnose what may be wrong.
<Directory /var/www/ninja/public>
AllowOverride All
</directory>
#!/bin/bash -ue
#Invoice Ninja Self-Hosted Automatic Update
#This version will check https://invoiceninja.org for an updated version and install if found.
#Tested and works with cron. Lines 51, 54, & 79 output timestamps so you can pipe to a logfile.
#USE AT YOUR OWN RISK
#Replace </path/to/ninja> (line 13) and </download/path> (line 57) with your specifics, obviously.
#!!IMPORTANT!! Be sure to edit lines 16 & 17 if www-data is not the owner/group for /ninja/storage!
#SET INITIAL VARIABLES
#Remaining variables will be set if an update is required
#--------------------------------------------------------
ninja_home="/var/www/ninja"
ninja_storage="$ninja_home/storage"
versiontxt="$ninja_storage/version.txt"
storage_owner="www-data"
storage_group="www-data"
#GET INSTALLED AND CURRENT VERSION NUMBERS
#--------------------------------------------------------
ninja_installed=$(cat "$versiontxt")
ninja_current=$((wget -qO- https://invoiceninja.org/index.php) | (grep -oP 'Download Version \K[0-9]+\.[0-9]+(\.[0-9]+)'))
#SEE IF AN UPDATE IS REQUIRED
#--------------------------------------------------------
update_required="no"
set -f
array_ninja_installed=(${ninja_installed//./ })
array_ninja_current=(${ninja_current//./ })
if (( ${#array_ninja_installed[@]} == "2" ))
then
array_ninja_installed+=("0")
fi
for ((i=0; i<${#array_ninja_installed[@]}; i++))
do
if (( ${array_ninja_installed[$i]} < ${array_ninja_current[$i]} ))
then
update_required="yes"
fi
done
#MAIN UPDATE SECTION
#--------------------------------------------------------
case $update_required in
no)
printf '%s - Invoice Ninja v%s is installed and is current. No update required.\n' "$(date)" "$ninja_installed"
;;
yes)
printf '\n%s - Updating Invoice Ninja from v%s to v%s.\n\n' "$(date)" "$ninja_installed" "$ninja_current"
#Set remaining variables
tempdir="/home/atom/tmp/InvoiceNinja"
ninja_temp="$tempdir/ninja"
ninja_file="ninja-v$ninja_current.zip"
ninja_url="https://download.invoiceninja.com/$ninja_file"
ninja_zip="$tempdir/$ninja_file"
printf 'Downloading Invoice Ninja v%s archive "%s" ...\n\n' "$ninja_current" "$ninja_url"
wget -P "$tempdir/" "$ninja_url"
printf 'Extracting to temporary folder "%s" ...\n\n' "$tempdir"
unzip -q "$ninja_zip" -d "$tempdir/"
printf 'Syncing to install folder "%s" ...\n' "$ninja_home"
sudo rsync -tr --stats "$ninja_temp/" "$ninja_home/"
printf '\nResetting permissions for "%s" ...\n\n' "$ninja_storage"
sudo chown -R "$storage_owner":"$storage_group" "$ninja_storage/"
sudo chmod -R 775 "$ninja_storage/"
printf 'Removing downloaded ZIP file "%s" ...\n\nRemoving temporary folder "%s" ...\n\n' "$ninja_zip" "$tempdir"
rm -rf "$tempdir/"
printf '%s - Invoice Ninja successfully updated to v%s!\n\n' "$(date)" "$ninja_current"
;;
esac
The user/group www-data is correct, and atom is the user I login as (with su permission). I ran the script with sudo.
I just checked now, and some (php) files in the /var/www/ninja folder were owned by root. I did a ‘chown -R www-data:www-data’ to see if that would help but no luck still.
Yeah, just ran a diff between your copy and mine, and no differences that would cause any issues.
Oddly enough, on mine, http://mysite/ninja gets a not found error (expected, since that directory doesn’t exist in /ninja/public, while http://mysite/login goes to the login page.
Here’s what’s in my .htaccess if you wanna compare.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# http://stackoverflow.com/a/20865084/497368
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# In case of running InvoiceNinja in a Subdomain like invoiceninja.example.com,
# you have to enable the following line:
# RewriteBase /
</IfModule>
Thank you so much for posting that. Though it didn’t directly help, it looked different from the .htaccess I was working on (in the /ninja/ directory).
So I checked the /ninja/public directory and it was the same as the one you posted.
When I add RewriteBase /ninja/ to that, everything works!
Keywords for people in search: solution, solved, fix.