JoeGandy / ShareX-Custom-Upload

A little PHP script created for uploading custom sharex files to your own webserver
MIT License
166 stars 50 forks source link

Getting Error 500 on Version 2 #86

Closed bokerlol closed 4 years ago

bokerlol commented 4 years ago

Hey all,

I'm getting error 500 on the new version. The old one works perfectly but anytime I try to upload via ShareX and/or access the gallery page, it does not work at all.

I feel like I am setting something up incorrectly but after restarting multiple times I cannot figure it out. I'm more concerned about getting the gallery page to work correctly.

Here are some screenshots: https://i.imgur.com/VRTw648.png https://i.imgur.com/HliuKG3.png

I have everything from the release folder inside of /u/ so if I'm reading everything correctly it SHOULD be working fine. But it isn't. Any help would be much appreciated.

theaquarium commented 4 years ago

A few things: First, if your entire site is located in http://mysite.com/u, and you want to access your uploads at http://mysite.com/u/myfile.ext, you need to set your upload_access_path to /, since it's relative to base_url, not root. I should probably add a bit of documentation explaining this. Right now, it looks like your files will be at http://mysite.com/u/u/myfile.ext.

Second, you really should change the <Directory "u/"> to say <Directory "i/"> if that's where your files are stored. The point of this directive is to block the files from being directly accessed and to instead make users use the path configured through upload_access_path.

However, I don't think either of these are the problem causing the error 500. There's a few things that you should probably check. First, if you're running a version of PHP less than 7.3 and you downloaded the uploader more than a few hours ago, you should download it again since I accidentally packaged an old version that wasn't compatible with old PHP versions.

The other thing I would check is whether you have all the necessary extensions enabled in PHP and Apache. You need the openssl and fileinfo extensions to be enabled in your php.ini, and you need mod_rewrite and mod_authz_core in Apache's httpd.conf. Also make sure that you don't have AllowOverride None set for your uploader in httpd.conf, because that disables .htaccess.

theaquarium commented 4 years ago

Also, error 500 is an internal server error, so could you check your Apache's error log to see if it's throwing any errors?

JoeGandy commented 4 years ago

Yep if you post your error log, we're more than happy to help.

bokerlol commented 4 years ago

Hello! Thank you both for commenting back to me. After tons of checking, I confirmed that I have everything setup on the PHP/Apache side of things.

Just for some clarification on my websites setup: I have my website folder at the root and the website files inside that folder, but I'm wanting to keep all the Uploader files under the directory /u/. So it looks something like this: /root/website/website main files/u/

I checked out the error logs and I believe it does have something to do with the .htaccess file itself.

This the error I'm getting once I try to access website.com/u/:

[Thu Jul 23 23:40:38.856210 2020] [core:alert] [pid 1008] [client XXXXXXXXXXXX:XXXXX] /var/sentora/hostdata/[user]/public_html/[website name]/u/.htaccess: <Directory not allowed here

Also a side note: I am running PHP 5.4 if that matters. I know it's a bit out of date so not sure if that conflicts with version 2 or not.

Let me know if you have any ideas. I did make the changers to my config.php and .htaccess files that @theaquarium recommended.

Also updated SS's: https://i.imgur.com/0j5LEJ2.png https://i.imgur.com/HAQqPgK.png Thank you!

theaquarium commented 4 years ago

Ah, I see the problem. I just noticed this myself too a few hours ago. I'll release a new version of the uploader where that should be fixed. The problem is with that <Directory> line in .htaccess which I told you to change. It seems that it doesn't work on some installations of Apache. I'll release a new version soon that should fix this. If you update, the new release will have a folder called u with another .htaccess file inside it. If you want your upload directory to be something other than that inner u folder, make sure to copy that .htaccess file into your new upload folder.

As for PHP 5.4, yeah you should really probably update this. However, I don't think it'll conflict with anything core, but the password functionality may not entirely work.

bokerlol commented 4 years ago

Awesome. Thank you so much :D Really appreciate the work you all are putting into this. I'll keep an eye out for that new release.

theaquarium commented 4 years ago

Thanks! I just released it as v2.0.1.

bokerlol commented 4 years ago

Just wanted to comment and say that it works flawlessly now but I did discover an issue: When you download the generated ShareX file it does not have the .sxcu at the end.

Thanks again!

theaquarium commented 4 years ago

That's strange, @bokerlol could you open a separate issue for that?