updated README.md
This commit is contained in:
66
README.md
66
README.md
@@ -7,7 +7,6 @@ The application uses PHP and a Python authentication service running on Apache2.
|
|||||||
|
|
||||||
- Apache2, configured, up and running
|
- Apache2, configured, up and running
|
||||||
- PHP 8.1 or higher
|
- PHP 8.1 or higher
|
||||||
- Python 3
|
|
||||||
- Required PHP extensions: `php-json`, `php-curl`
|
- Required PHP extensions: `php-json`, `php-curl`
|
||||||
|
|
||||||
Hint:
|
Hint:
|
||||||
@@ -15,7 +14,6 @@ Hint:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install apache2
|
sudo apt install apache2
|
||||||
sudo apt install php libapache2-mod-php
|
sudo apt install php libapache2-mod-php
|
||||||
sudo apt install python3
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -35,43 +33,6 @@ For simplicity, I'll use my current Ubuntu instance user name, you should replac
|
|||||||
rm -r uploader/uploader-master
|
rm -r uploader/uploader-master
|
||||||
rm master.zip
|
rm master.zip
|
||||||
```
|
```
|
||||||
### Install Python prerequisites
|
|
||||||
|
|
||||||
```
|
|
||||||
pip install flask pam
|
|
||||||
```
|
|
||||||
|
|
||||||
### Create Python authentication service
|
|
||||||
(note: **port 7000** is used; if you need to change port number, make needful changes in the **app.py** and php scripts - search for '7000')
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo nano /etc/systemd/system/flaskapp.service
|
|
||||||
```
|
|
||||||
|
|
||||||
Add the following content to this file (but replace **User**, **WorkingDirectory** and **ExecStart**):
|
|
||||||
|
|
||||||
```
|
|
||||||
[Unit]
|
|
||||||
Description=Flask Application
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
User=ubuntu
|
|
||||||
WorkingDirectory=/home/ubuntu/uploader
|
|
||||||
ExecStart=/usr/bin/python3 /home/ubuntu/uploader/app.py
|
|
||||||
Restart=always
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
### Enable and start the service:
|
|
||||||
```
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable flaskapp
|
|
||||||
sudo systemctl start flaskapp
|
|
||||||
sudo systemctl status flaskapp.service
|
|
||||||
```
|
|
||||||
|
|
||||||
### Configure PHP
|
### Configure PHP
|
||||||
|
|
||||||
@@ -95,17 +56,7 @@ For simplicity, I'll use my current Ubuntu instance user name, you should replac
|
|||||||
sudo chmod -R 755 /var/www/html/upload
|
sudo chmod -R 755 /var/www/html/upload
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create a new user for uploading files
|
### Do not forget to add proper permissions to www-data (used by apache & php)
|
||||||
(please note, I don't recommend you to use your actual ssh-enabled user account):
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo adduser --no-create-home --disabled-password --gecos "" uploader
|
|
||||||
sudo passwd uploader
|
|
||||||
sudo chown uploader:uploader /var/www/html/upload
|
|
||||||
sudo chmod 755 /var/www/html/upload
|
|
||||||
```
|
|
||||||
|
|
||||||
### Do not forget to add proper permissions to www-data (used for apache & php)
|
|
||||||
```
|
```
|
||||||
sudo chown -R www-data:www-data /var/www/html/upload
|
sudo chown -R www-data:www-data /var/www/html/upload
|
||||||
sudo chmod -R 775 /var/www/html/upload
|
sudo chmod -R 775 /var/www/html/upload
|
||||||
@@ -118,14 +69,14 @@ For simplicity, I'll use my current Ubuntu instance user name, you should replac
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Edit file config.php and adjust variables
|
### Edit file config.php and adjust variables
|
||||||
(web site name, time zone etc.)
|
(website name, time zone etc.)
|
||||||
```
|
```
|
||||||
sudo nano /home/ubuntu/uploader/config.php
|
sudo nano /home/ubuntu/uploader/config.php
|
||||||
```
|
```
|
||||||
|
|
||||||
### Copy all app files (html, php & js) to the app folder:
|
### Copy all app files (html, php & js) to the app folder:
|
||||||
```
|
```
|
||||||
sudo cp /home/ubuntu/uploader/*.php /home/ubuntu/uploader/*.js /home/ubuntu/uploader/*.html /var/www/html/uploader/
|
sudo cp /home/ubuntu/uploader/*.* /var/www/html/uploader/
|
||||||
```
|
```
|
||||||
|
|
||||||
### Restart Apache to apply changes:
|
### Restart Apache to apply changes:
|
||||||
@@ -146,13 +97,4 @@ The uploaded files will be listed on the page, and you can delete them using the
|
|||||||

|

|
||||||
|
|
||||||
## Issues / TODO
|
## Issues / TODO
|
||||||
|
- Add checking upload size before starting upload.
|
||||||
There are two unresoved (yet) issues with the app:
|
|
||||||
- First, I have to use a Python app (running as a service), for the user authentication in the PHP scripts because I can't make the PAM PHP extension works 😒 Google's searches returned tonns of useless and non-working advises and suggestions; even ChatGPT can't resolve that issue. It looks like this module is deprecated but I can't find any working replacement.
|
|
||||||
By the way, if I'll get PAM module working in PHP, Python app and auth.php will be replaced by very simple call:
|
|
||||||
``` if (pam_auth($username, $password))```
|
|
||||||
|
|
||||||
BTW, I found a [third-party implementation](https://github.com/amishmm/php-pam) but haven't tried yet.
|
|
||||||
|
|
||||||
- Secondly, a very strange error occurs: if I use the authenticate function from the **auth.php** module in file_list.php (adding ```require_once 'auth.php';```), then the file list is not appearing on web page. Although the user is authenticated and **file_list.php** sends a list of files in JSON format. If I define this function (using copy&paste) in the **file_list.php** module itself, then everything works great.
|
|
||||||
Perhaps this has something to do with PHP session - I'm not a big expert in PHP and web programming. If anyone can help solve this problem, I would be very grateful - I hate strange errors!
|
|
||||||
|
|||||||
Reference in New Issue
Block a user