ewww as a separate php tool … to be run on whole WHM account
-
What I wanna do is to optimize all the images on clients WHM account with 60+ domains … few are wordpress websites but most are Static HTML with all the image files in one folder …
I am looking into ways to do this, and since EWWW plugin is so good for me and I use it on so many wordpress websites, It would be great if it could work independent of wordpress
-
sticking as a feature request. It’s been on my todo list for a long time, if we get enough interest, I’ll move it up the priority list a bit.
Yes, this would be awesome!
Maybe no separate php tool would be required. Can wordpress plugins write outside the wordpress folder? That would do if we could add extra paths such as /var/www + sub folders. And if wordpress plugins are not allowed to write outside the wordpress folder, perhaps some symlink trick could do?
Yes, symlinks work, I’ve done it before. Then you could run something via cron using wp-cli. Forgot to mention that.
@millllan, would something like that work for you also?
I’ve tried the symlinks earlier today. Didn’t succeed.
The issue is, the images are “a million” of sub folders. I.e. /var/www/w/images/thumb/[abc]/[xyz]/. And wordpress expects them all in one folder, i.e /var/www/blog/wp-content/uploads/2015/02 with no sub folders?
Could you give an example symlink command please that worked for you?
I dont know if i can make symlink outside of curent user home folder … would it make file permission problems afterwards ?
So the idea is too make symlinks to folders i want to optimize, all this using root account over ssh
I’ll try it when i find the time … but i dont even know how to create symlinks in shell
Other way I wanted to try is to use all these tools like optipng, pngout while using root account but this would definitely create file permission problems afterwards
millllan brings up a good point, but you can fix those afterwards. So long as the files are world-readable, it shouldn’t cause any issues in while you’re still running the optimization.
Couple things you need to know do do this properly:
1. EWWW will scan any folder within your WordPress root folder (defined by the ABSPATH constant).
2. EWWW will scan it recursively, so no worries there.
3. EWWW will also add all these images to your WP database, so I recommend having a dedicated WP install for this scan & optimize operation.To do a proper symlink, where you have these two folders:
/var/wwww/wordpress/ = your wordpress root
/home/blogger8/joomla/images/ = some other random folder that I just made upYou run the command like so:
ln -sf /home/blogger8/joomla/images/ /var/www/wordpress/joomla_images/
Then you enter the latter folder into Folders to Optimize, and with the number of images you’re dealing with, I strongly recommend using WP-CLI, and not attempting this from the WordPress dashboard.
Does’t work for me unfortunately. This is what I tried.
sudo -u www-data mkdir /var/www/blog/wp-content/uploads/wiki_images/
sudo -u www-data ln -sf /var/www/w/ /var/www/blog/wp-content/uploads/wiki_images/
Then went to advanced settings and added:
/var/www/blog/wp-content/uploads/wiki_images/
Pressed save changes. Went to bulk optimize. Showed “There are no images to optimize.”
I thought perhaps I may not add it to wp-content sub folder. Therefore also tried something else.
sudo -u www-data mkdir /var/www/blog/forum_images/
sudo -u www-data ln -sf /var/www/forum/ /var/www/blog/forum_images/
Didn’t work either.
you don’t want to do a mkdir before creating the link. it will probably fail or do unexpected things then. It IS entirely possible that symlinks are not available in your environment…
So once you’ve created the symlink, did you do a directory listing to see what is in the folder:
ls /var/www/blog/wp-content/uploads/wiki_images/
If it doesn’t display anything, then that’s the first problem. Remove the directory, and recreate the symlink. And then of course make sure something is inside the folder this time.
The environment should be fine. Debian jessie on a vserver. We should be able to do practically everything.
Symlink creation works when dropping the leading slash.
sudo -u www-data ln -sf /var/www/forum/ /var/www/blog/forum_images
sudo -u www-data ln -sf /var/www/w/ /var/www/blog/wiki_images
The folder is nicely filled up.
ls -la /var/www/blog/wiki_images
lrwxrwxrwx 1 www-data www-data 11 Mar 14 17:41 /var/www/blog/wiki_images -> /var/www/w/
ls -la /var/www/blog/wiki_images/images/0/00/Kde0_5.png
-rwxr-x--- 1 www-data www-data 362556 Nov 29 20:55 /var/www/blog/wiki_images/images/0/00/Kde0_5.png
Now, when trying to optimize, I am getting:
Operation timed out, you may need to increase the max_execution_time for PHP
Increased max_execution_time from 30 to 60. But my stopwatch says, it already shows this message after ~7 seconds. Any idea how to fix that one?
then you’re probably hitting a memory limit.
I’ve set php…
max_execution_time = 120 memory_limit = 1024M
But that didn’t help. There is more than 8 GB of free RAM. What memory limit could it be?
Is it still stopping after 7 seconds or so, or does it go longer now?
You really should be running it via wp-cli, which will remove the timeouts, and make increasing the memory limit less risky (you generally have separate php.ini files for CLI and apache)
I’ve tried it
ln -sf /home/wtmmeuk/www/ /home/lmorguk/public_html/wp-content/
created symlink … i could browse into /home/lmorguk/public_html/wp-content/www/ from ssh, it would redirect me to /home/wtmmeuk/www/But on ewww it just gave infinite “Scanning, this could take a while”
Than i tried to open that symlink trough cpanel … and it just gave me “This directory is empty.” message.
All this makes me think its permissions issue … wordpress is running under some limited account (lmorguk in my case) that cant follow symlink to another users folder, but root can
I dont know if i could install wp under root account on whm, that would propably work
I end up installing optipng and running it recursively on the whole /home/ directory. Hopefully it wont cahnge the file permissions
cd /home/
## Overwrite images ##
## Keep file system permission and make a backup of original PNG (see options below) ##find -name ‘*.png’ -print0 | xargs -0 optipng -nc -nb -o7 -keep -preserve -log optipng.log
Its a mixture of what i found here : http://www.cyberciti.biz/faq/linux-unix-optimize-lossless-png-images-with-optipng-command/ and here: http://blarg.co.uk/blog/recursively-optimize-png-files
Nah, running this is not safe it breaks file permissions, my pngs are not showing on the website, and they are there in the right folder on cpanel… optimized 🙂
- The topic ‘ewww as a separate php tool … to be run on whole WHM account’ is closed to new replies.