By don128898
I can’t figure out why PHP can’t write/delete files. I believe I have everything setup properly, but clearly I’m missing something obvious. Running Ubuntu 12.10.
nginx:
root@DonaldAllen:/# ps aux|grep nginx|grep -v grep
root 24427 0.0 0.3 79236 1608 ? Ss 04:59 0:00 nginx: master process /usr/sbin/nginx
www-data 24428 0.0 0.9 82372 4924 ? S 04:59 0:00 nginx: worker process
www-data 24429 0.0 0.9 82372 4924 ? S 04:59 0:00 nginx: worker process
www-data 24430 0.0 0.9 82372 4924 ? S 04:59 0:00 nginx: worker process
www-data 24431 0.0 1.1 82708 5656 ? S 04:59 0:00 nginx: worker process
php5-fpm:
root@DonaldAllen:/# ps aux|grep php|grep -v grep
root 24415 0.0 1.2 278244 6056 ? Ss 04:59 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
1000 24416 0.5 4.5 291636 22816 ? S 04:59 0:02 php-fpm: pool www
1000 24417 0.5 4.4 291328 22448 ? S 04:59 0:02 php-fpm: pool www
1000 24432 0.2 3.7 287480 18676 ? S 04:59 0:01 php-fpm: pool www
/etc/nginx/sites-enabled/default:
server {
listen 80;
root /var/www/subdomain.site.com;
index index.html index.htm index.php;
server_name subdomain.site.com;
location / {
try_files $uri $uri/ /index.php;
}
fastcgi_intercept_errors off;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PYRO_ENV production;
}
}
/etc/php5/fpm/pool.d/www.conf
user = donaldallen
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
And the directory with my website files:
drwxr-xr-x 9 www-data www-data 4096 Apr 9 04:43 subdomain.site.com/
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
What exactly is the situation, what is the script or app and what is it trying to do that requires write/delete? On Wordpress, for instance, I have to add group write permissions to the uploads folder before it will work, i.e. 775 instead of 755.
php-fpm needs write access, not nginx, and its process is running as uid 1000, not as www-data <br> <br>so you could chown -R 1000 /var/www/subdomain.site.com <br> <br>ideally you would limit what directory www-data and php-fpm have write access to, maybe limit it to an upload directory for example.
You have to set folder owner manually and recursivly I guess ?
chown -R www-data:www-data /var/www/subdomain.site.com
That will work for now, but own to make it work for new files in the future as well…? I don’t know…
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.