I'm new on the web server world, so please bear with me.
I'm trying to build my own API for mobile application using Ubuntu, Nginx and Lumen.
Everything was going fine till I came to upload images from the mobile app to my web server and save the URL in the mysql
database backend.
Let's assume my project folder is named TestProject
and I want to save the images under Testproject/public/Images/user_id/img.png
.
What permissions should I use to make only the web server able to write the folders and images, and anybody else can only read the images via URL request only?
Update to clarify :
My major concern is the security (I don't want any to delete, add or execute files on my server) so to be more clear my scenario is as follows:
- Mobile app user sends the images and user_id (to be used as sub folder name) via http/https post request.
- On server side PHP-Lumen code will receive the images and save them under
Testproject/public/Images/user_id/img.png
(as I mentioned before, this step should be done only by the web server user; now I have only root) and then save the image's URL in MySQL database. - All mobile app users can read all the images via url (in mobile app reads mean download via http/https request).
My suggested solution :
Creating a new super user and make it the owner of all project folders and give it the permissions to read and write folders and files (which I don't know how to do) and give world the permission to only read all files inside the /images
folder (which I also don't know how to do).
root
user becauseroot
is god and can essentially view all the system files without problem anyways)/var/www/html
from that answer to whatever filepath is on your system. And do not run this out of your home dir.../images
folder is readable by everyone but not writable except bywww-data
.