Re: Permissions issue Ubuntu 24/Apache2/PHP-FPM - Final Upda…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Keith Smith via PLUG-discuss
Date:  
To: Main PLUG discussion list
CC: techlists
Old-Topics: Re: Permissions issue Ubuntu 24/Apache2/PHP-FPM - update3
Subject: Re: Permissions issue Ubuntu 24/Apache2/PHP-FPM - Final Update.

This is the problem. I was using the first code in the vhost config:

<FilesMatch \.php$>
      SetHandler 
"proxy:unix:/var/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>


Notice the lamp:

<FilesMatch \.php$>
     SetHandler 
"proxy:unix:/var/run/php/php8.3-fpm.lamp.sock|fcgi://localhost/"
</FilesMatch>


Now it works.






On 2024-12-11 07:54, Keith Smith via PLUG-discuss wrote:
> Ok,
>
> Yikes. I do not think I have PHP-FPM configured correctly. I think I
> am close. I have worked on this for an embarrassing maybe as much as
> 40 hours. Yikes!! I
>
> My PHP-FPM user and group is a user named lamp. lamp has ssh but not
> sudo.
>
> To the mix 3 things:
>
> 1 and 2) Set Ownership and Permissions
>
>      – sudo usermod -aG lamp www-data
>      – sudo chown -R lamp:lamp /var/www/lamp.internal
>      – sudo find /var/www/lamp.internal -type d -exec chmod 775 {} \;
>      – sudo find /var/www/lamp.internal -type f -exec chmod 644 {} \;

>
>      Notice I added lamp to the Apache group and set the directory 
> permissions to 775.

>
> 3) Added "php_admin_value[umask] = 0022" to
> /etc/php/8.3/fpm/pool.d/lamp.conf
>
>     - viewable in a browser.
>     - PHP info sows “Server API” with the value: “FPM/FastCGI”
>     – Connect via Filezilla as user lamp. I am able to download and 
> upload. New upload files are owned by lamp:lamp.
>     – Able to SSH as user lamp.
>     – Able to use Visual Studio Code add/edit/delete/save as user lamp. 
> New upload files are owned by lamp:lamp.

>
> Really happy so far. I spend a ton of time with ChatGPT to get to this
> place.
>
> Here is the problem.
>
> When I run a PHP script to create a file, the file is owned by Apache -
> www-data:www-data. I need it to be owned by lamp.
>
> Any thoughts?
>
> Thanks!!
> Keith
>
>
>
>>
>>
>> On 2024-12-05 09:53, Snyder, Alexander J wrote:
>>> What is the group of the Apache process? I think that group needs to
>>> be there like
>>>
>>> chown lamp:www-data test_file.txt
>>> chmod 775 test_file.txt
>>>
>>> Its working when you set 777 because that's making it writable to
>>> everyone.
>>>
>>> ---
>>> Thanks,
>>> Alexander
>>>
>>> Sent from my Google Pixel 7 Pro
>>>
>>> On Thu, Dec 5, 2024, 09:46 Keith Smith via PLUG-discuss
>>> <> wrote:
>>>
>>>> Hello;
>>>>
>>>> I have a private net that runs non-rountable domain names of
>>>> .internal.
>>>> I use the hosts files for DNS.
>>>>
>>>> This is for PHP development and testing.
>>>>
>>>> Desktop is Kubuntu. Have installed Virtual Studio Code (VSC).
>>>>
>>>> I have a Win10 laptop running VirtualBox and multiple VMs of which
>>>> only
>>>> one runs at a time. As I complete a configuration I clone the last
>>>> successful VM to take it to the next level.
>>>>
>>>> The Goal is to be able to remote edit using VSC.
>>>>
>>>> My config
>>>>
>>>> Ubuntu 24.04lts
>>>> Apache2
>>>> PHP 8.3
>>>> MySQL
>>>> PHP-FPM
>>>>
>>>> I think I have a complete PHP-FPM config, user is lamp, group is
>>>> lamp.
>>>>
>>>> PHP Info shows Server API FPM/FastCGI which I understand the config
>>>> is
>>>> correct.
>>>>
>>>> I can access the server using VSC and am able to
>>>> add/edit/delete/save
>>>> code files.
>>>>
>>>> My permissions and ownership is:
>>>>
>>>> - sudo chown -R lamp:lamp /var/www/lamp.internal
>>>> – sudo find /var/www/lamp.internal -type d -exec chmod 755 {} \;
>>>> – sudo find /var/www/lamp.internal -type f -exec chmod 644 {} \;
>>>>
>>>> When I run : http://lamp.internal/php-write-edit-delete.php it
>>>> reports:
>>>>
>>>> The file does not exist. It will be created shortly.
>>>>
>>>> Error writing to the file.
>>>>
>>>> Error appending to the file.
>>>>
>>>> Error deleting the file.
>>>>
>>>> ---
>>>>
>>>> When I change permissions : sudo find /var/www/lamp.internal -type d
>>>>
>>>> -exec chmod 777 {} \;
>>>>
>>>> The script reports:
>>>>
>>>> The file does not exist. It will be created shortly.
>>>>
>>>> Successfully written to the file: 'test_file.txt'
>>>>
>>>> Successfully appended content to the file: 'test_file.txt'
>>>> File Content (After Modifying):
>>>>
>>>> This is the initial content of the file.
>>>> Appended content: 2024-12-05 16:37:21
>>>>
>>>> Successfully deleted the file: 'test_file.txt'
>>>>
>>>> ---
>>>>
>>>> Interestingly I can edit files using VSC however I have difficulty
>>>> running a script from a browser.
>>>>
>>>> Any help much appreciated!!
>>>>
>>>> Thanks!!
>>>>
>>>> Keith
>>>>
>>>> ---------------------------------------------------
>>>> PLUG-discuss mailing list:
>>>> To subscribe, unsubscribe, or to change your mail settings:
>>>> https://lists.phxlinux.org/mailman/listinfo/plug-discuss
>> ---------------------------------------------------
>> PLUG-discuss mailing list:
>> To subscribe, unsubscribe, or to change your mail settings:
>> https://lists.phxlinux.org/mailman/listinfo/plug-discuss
> ---------------------------------------------------
> PLUG-discuss mailing list:
> To subscribe, unsubscribe, or to change your mail settings:
> https://lists.phxlinux.org/mailman/listinfo/plug-discuss

---------------------------------------------------
PLUG-discuss mailing list:
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss