Symfony2 impossible to clear cache on my prod server - symfony

i've deployed my S2 Project on my remote server (nginx) and when i try to clear the cache i've got an error:
[RuntimeException]
Unable to write in the "/Applications/MAMP/htdocs/Git/S2project/app/cache/prod" directory
why does it point on my local install and not on my server??

you don't have permission to write in cache folder, you should run this command:
chmod -R 777 app/cache/*
and same for the logs folder
chmod -R 777 app/logs/*

You can also try to remove cache "manually"
rm -rf cache/*
and then as suggested by ponciste
chmod 777 -R cache/*

the uname of the app.php file is not set to the right user on your prod server.

Related

Cannot update plugin for WordPress on localhost on Mac

I'm running WordPress 5.8.1 on localhost, on my Mac. I am unable to update plugins. I get this error:
Update failed: Could not create directory.
I've tried changing the permission on the wp-content folder as suggested here like this:
sudo chmod -R 755 wp-content
but it didn't work. I still get the error message.
I also tried this
sudo chown -R _www wp-dir
sudo chmod -R g+w wp-dir
still no luck.
Ok, Managed to find the issue. Apache uses a different username so this command was ok:
sudo chown -R _www wp-dir
But my username wasn't _www (hence my error)
you can find the apache username in the etc/httpd.conf file

WordPress File Access Permission

I am trying to upload an image to set a background image for my theme, but I get this error:
Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?”
I tried to change the access permissions with the help of these blogs:
https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress
https://gist.github.com/Adirael/3383404
But nothing has helped me, and now I also get a 500 error page.
I'm stuck here, can anybody help?
-----------Comment-----------
Output Image for ps -ef| grep httpd
I executed this command
find . type f -exec chmod 644 {} \;
and the 500 error page is not being displayed now. I am able to view my web page. But I am still unable to upload a background image. (same error appears "Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?")
The following command will fix your issue
sudo chmod -R 777 wp-contents/uploads/
If you're using Bitnami Lamp then run the following commands in your SSH terminal:
sudo chown -R bitnami:daemon /opt/bitnami/apache/htdocs
sudo chmod -R g+w /opt/bitnami/apache/htdocs
sudo chmod 440 /opt/bitnami/apache/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apache/htdocs/.htaccess
and if you're using Bitnami WordPress then run the following commands in your SSH terminal:
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
sudo chmod -R g+w /opt/bitnami/apps/wordpress/htdocs
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/.htaccess
The recommended permissions are:
Directories: 775
Files: 640
wp-config.php and.htacess: 440
Thanks
Maybe is already solved, but can help other users with similar issues.
I made a Shell Script on Debian10 to solve permissions issues.
After running it, I make the folder accesible on the Apache2.conf too (WordPress can't Upgrade or Upload Media if not)
What it does:
Set new Owner on all Files and (Sub)Directories ( user:group )
Set Permissions: 755 to Directories and 644 to Files
wp-config.php : Preventing world access for "wp-config.php", leaving it accesible to WordPress (660)
Allow WordPress to manage the "wp-content" (Directories to 755 & Files to 664)
Privatize "wp-content" (Set 755)
Link:
https://github.com/ieselisra/wordpress_fix_permissions_debian10/

W3 Total Cache plugin doesn't work without setting 777 permission for w3tc-config directory

I have my Wordpress website running on Apache and installed w3-total cache plugin installed. To enable Page Cache, it wants me to set 777 permission to w3tc-config and cache folder.
It shows the following warning.
Execute next commands in a shell:
chmod 777 {MyDirectory}/wp-content/cache
chmod 777 {MyDirectory}/wp-content/w3tc-config
Is it secure? Is there a workaround?
If you're using W3C Total Cache you should do :
chmod 777 wp-content/w3tc-config
chmod 777 wp-content/cache
rm -rf wp-content/cache/config
rm -rf wp-content/cache/object
rm -rf wp-content/cache/db
rm -rf wp-content/cache/minify
rm -rf wp-content/cache/page_enhanced
In this case,Everytime when you clear cache then w3tc needs to regenerate a cache,So need write permission.

Unable to write cache symfony2

RuntimeException in ClassCollectionLoader.php line 239:
Failed to write cache file "/var/www/fareast/app/cache/dev/classes.php".
I have this error when I run my project in symfony2.
I have nginx as my web server and centOS 7 as my OS.
I tried deleting the cache folder manually and by
php app/console cache:clear
then I did a bad practice to app/cache and app/logs
chmod -R 777
but I have the same error.
/var/log/nginx/error.log is also empty.
Do you recommend other solutions?
Or do I have to install some php5 libraries for cache?
Setting 777 permissions do nothing, because when webserver user write folders to it, the folders belong to this user, and you, as command line user haven't access to them, and vice versa. Set permissions in correct way: http://symfony.com/doc/current/book/installation.html#book-installation-permissions
In symfony3 i've faced the same issue...
So, problem would not solve only using "cache clear"
You have to change (R/W)permission of cache folder in your project
For ex: "projectname/var/cache"
Now refresh...
If still issue is coming, change(R/W)permission of logs folder in your project
For ex: "projectname/var/logs"
You have to use the following script to determine your web server user and grant the needed permissions:
rm -rf var/cache/*
rm -rf var/logs/*
HTTPDUSER = `ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
sudo chmod -R +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var
sudo chmod -R +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var

symfony2 after cache clear get blank page

I thought I solved a permissions issue by removing cached files, then giving 777 permissions, it works and shows the page for my site with the htaccess set to remove /web/app_dev.php. But if do php app/console cache:clear --env=prod it goes back to a blank page again and the permission go back to 755 , how do I change permission on the cache:clear thanks ?
rm -rf app/cache/*
rm -rf app/logs/*
chmod 777 -R app/cache
chmod 777 -R app/logs
Set the permissions like it says here in the documentation, using ACL, or with setfacl
http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Resources