I am using this guide to install php8.3.10 on Ubuntu22.04: https://www.php.net/manual/en/install.unix.nginx.php
got to step 8 create a test file,
modified the given command: echo "" >> /usr/local/nginx/html/index.php
to: echo "" >> /etc/nginx/sites-enabled/index.php
output: -bash: /etc/nginx/sites-enabled/index.php: Permission denied
troubleshooting ps aux for both processes
input: ps aux | grep php-fpm
output: root 5764 0.0 0.0 86676 6920 ? Ss 21:45 0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
www-data 5765 0.0 0.1 86984 9424 ? S 21:45 0:00 php-fpm: pool www
www-data 5766 0.0 0.1 86984 9424 ? S 21:45 0:00 php-fpm: pool www
user 5865 0.0 0.0 6480 2100 pts/0 S+ 21:49 0:00 grep --color=auto php-fpm
input: ps aux | grep nginx
output: root 811 0.0 0.0 12076 5748 ? Ss 17:50 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
www-data 4407 0.0 0.0 12860 4460 ? S 20:38 0:00 nginx: worker process
www-data 4408 0.0 0.0 12860 4460 ? S 20:38 0:00 nginx: worker process
www-data 4409 0.0 0.0 12860 4460 ? S 20:38 0:00 nginx: worker process
www-data 4410 0.0 0.0 12860 4460 ? S 20:38 0:00 nginx: worker process
user 5882 0.0 0.0 6480 2204 pts/0 S+ 21:49 0:00 grep --color=auto nginx
so both programs are run as the same user www-data, how can permissions be denied?
The problem with permissions above is when you try to edit index.php file inside /etc/nginx/sites-enabled/index.php
, it's probably owned by root user or some other user
To check file permissions for that file you can do
ls -al /etc/nginx/sites-enabled/index.php
which will print out file permissions, owner and group, check if those match with the user you are using
If not and you need it to match, you can do
chmod user_that_should_use_file /etc/nginx/sites-enabled/index.php
chown user_group /etc/nginx/sites-enabled/index.php
the ps aux | grep nginx
will print out all currently running nginx
processes which won't explain why the file itself is not accessible
Also there is no need to put index.php files in the /etc directory, if you followed the whole setup through and used /usr/local/nginx/
sticking to it will make sure everything works and you don't get errors