HaschekSolutions / pictshare

:camera: PictShare is an open source image, mp4, pastebin hosting service with a simple resizing and upload API that you can host yourself. :rice_scene:
https://www.pictshare.net
Apache License 2.0
819 stars 123 forks source link

cannot make it work on ubuntu server #116

Closed ghost closed 4 years ago

ghost commented 4 years ago

When I try to upload a file I'm getting cannot post error. Am I missing something?

curl -F "file=@/Users/apple/Desktop/dev/bethabit/marketing/logo.png" https://bethabit.com/api/upload.php


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /api/upload.php</pre>
</body>
</html>

this is the nginx block I use.


server {
        listen 80;
        server_name bethabit.com www.bethabit.com;

        client_max_body_size 50M; # Set the max file upload size. This needs to be equal or larger than the size you specified in your php.ini

        root /var/www/pictshare-master; # or where ever you put it
        index index.php;

    location / {
        try_files $uri $uri/ /index.php?url=$request_uri;
    }

    location ~ \.php {
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; #may be slightly different depending on your php version
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
    }

    location ~ /(data|tmp|bin|content-controllers|inc|interfaces|storage-controllers|templates|tools) {
       deny all;
       return 404;
    } 
}

this is the pictshare config


<?php 
/**
 * All settings that are uncommented are mandatory
 * Others optional
 */

//Use a specific domain for links presented to the user
//Format: https://your.domain.name/
// MUST HAVE TAILING /
define('URL','https://bethabit.com/');

//define('JPEG_COMPRESSION', 90);
//define('FFMPEG_BINARY','');
//define('ALT_FOLDER','/ftp/pictshare');
//define('ALLOWED_SUBNET','192.168.0.0/24');

//S3 settings
//
//define('S3_BUCKET','bucketname');
//define('S3_ACCESS_KEY','');
//define('S3_SECRET_KEY','');
//define('S3_ENDPOINT','http://localhost:9000'); //optional, only if you're using S3 compatible storage like Minio
geek-at commented 4 years ago

does it work if you point it to pictshare.net?

curl -F "file=@/Users/apple/Desktop/dev/bethabit/marketing/logo.png" https://pictshare.net/api/upload.php

?

ghost commented 4 years ago

that does work but obviously I need to store the files in my server.. I tried changing the URL in pictshare config file to "https://pictshare.net/" but got the same result "Cannot GET /api/upload.php"

geek-at commented 4 years ago

Sure, just making sure it's a problem on your side.

what's the output of

ls -al /var/run/php/php7.3-fpm.sock

ghost commented 4 years ago

It was cannot access '/var/run/php/php7.3-fpm.sock': No such file or directory I installed php7 again according to another document https://pixelspress.com/how-to-install-php-7-3-fpm-on-ubuntu-19-10/ Now I get srw-rw---- 1 www-data www-data 0 May 12 05:33 /var/run/php/php7.3-fpm.sock and I do php -v I get this PHP 7.3.17-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Apr 19 2020 07:44:26) ( NTS ) I restarted nginx and I was getting the same cannot post error. I thought nginx cannot access var/www/ by sudo so I placed the repo to the root and tried running it again without any success.

geek-at commented 4 years ago

really sounds like a PHP problem. anything in the nginx or php error log?