I have implemented wkhtml2pdf through the package laravel-pdf (https://packagist.org/packages/ignited/laravel-pdf) which makes use of a slim wrapper around wkhtmltopdf written by Michael Haertl (https://packagist.org/packages/mikehaertl/phpwkhtmltopdf)
It used to work fine. Then I upgraded to PHP5.5 and Laravel 4.1.
Now I get the following error:
Could not run command '' --bin '/var/www/docassembly/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64' /tmp/tmp_WkHtmlToPdf_f0LNZv.html /tmp/tmp_WkHtmlToPdf_gJY5R6: sh: 1: : Permission denied
It looks like Apache doesn't have the permissions to execute the binary.
The binaries are owned by the apache user and are 777. It does write an empty file to the tmp directory though. The /tmp folder is also 777 and owned by apache user.
When I run the command manually in the terminal, it works as expected.
Any ideas?
First check what is the file permission with command
ls -l /var/www/docassembly/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64.
Should be
-rwx------ 1 www-data www-data 38824584 Aug 17 00:40 wkhtmltopdf-amd64.
If not change with command
chmod 700 /var/www/docassembly/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64.
Hope this helps.
Related
I have files that owned by root and I want to change it permission with php using chmod(). But it gave me an error chmod(): Operation not permitted instead.
if (file_exists($filepath)) {
chmod($filepath, 0755);
}
PHP Error Response
How to use chmod() in php but the files ownership are root ?
Can I achieve this without changing files ownership ?
Application Environment:
PHP 7.1.33
Code Igniter 3 framework
Apache 2.4.6
CentOS Linux release 7.8.2003
Any answer are appreciated, thanks before.
EDIT:
I've run ps aux | grep httpd and it shows only root and apache on the list.
As the files are owned by root and not www-data, apache will not have permissions to change the file's read and write permissions. You would need to set the folder to be owned and writable by www-data.
The command in centOS for doing so is
sudo chown -R apache:apache ./filepath
You would need sudo for the root owner as well as replace filepath with your folder's name
I'm getting a permission denied error when trying to run the rename command in PHP.
The file it is trying to rename is in another users home directory.
Here's what I've done so far:
Given the PHP user (userA) access to that group. So when I run id
I get
uid=1004(userA) gid=1006(userA) groups=1006(userA),10(wheel),1007(userB)
The PHP script is running as userA.
I ran sudo chmod -R g+rwx ./* in from the /home/userB/subdomains/mp3s directory.
When I navigate to the directory where the files are kept, under /home/userB/subdomains/mp3s/ and run ls -lha I get:
-rw-rwxr-- 1 userB userB 62M Aug 8 2017 Stress Management - Lesson 1.mp3
So the group has permission to read/write/execute, and my userA has access to that group, so why can't it rename the file?
So I am betting you got SELinux with that fancy CentOS instance. Add the following on top of your permission changes to allow PHP to rename files:
sudo chcon -t httpd_sys_rw_content_t /home/userB/subdomains/mp3s/ -R
The command may need different permissions for PHP CLI as opposed to the web service operating against it but you can find information on that on the CentOS SELinux how to:
https://wiki.centos.org/HowTos/SELinux
The first command helped me and was found on:
https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/
I tried to install Nextcloud 13 in Plesk, but if I try to open the link I get a HTTP 500 error.
PHP version: 7.0.27
PHP modules: click here
php_error.log: too long (I can send the pastebin link)
Please tell me if you need more info. I would really appreciate any help.
You might have set the wrong file permission on your Nextcloud installation.
If you created the Nextcloud directory with root permission, you need to change the ownership of the directory to a user or a group, that Plesk has permissions for.
Use these commands to change the ownership (replace myPleskUser with the username you specified during the Plesk installation)
cd /var/www/vhosts/mydomain.tld/
chown -R myPleskUser ./nextcloud
chgrp -R psaserv ./nextcloud
I installed Laravel 5 on a new VPS, I was running everything fine but I noticed I wasn't getting any Laravel errors the system would only fire a server 500 error at me which is no help when debugging my code.
When I looked in the laravel storage/log it was empty which was strange because I had set the correct file permissions of 777.
So how do I get laravel logs? Why aren't they being written to my storage/log file.
If you've set your file permissions correctly on the /storage file directory and you're running on a VPS not shared hosting you might want to check your apache log, inside var/log/apache2/error.log
Here you might just see a line that read something along the lines of /var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
Well this is strange because you have the correct file permissions...
Let's start by SSH'ing into your VPS head to the directory where laravel is installed normally cd /var/www/html
In here if you run ls -l You should get some results similar to this image below:
Notice how we've been accessing the site as the root user, this is our problem and we can confirm this by running ps aux | grep apache2
You can see here apache2 is running as the user www-data, which is normal for apache. Which means when our laravel installation trys to move files either using ->move() or just trying to write the log file it fails as the www-data user doesn't have permission. So you can change to this www-data user by running: chown -R www-data:www-data * (shorthand for same user/group chown -R www-data. *)
Now if you run ls -l in your www/html directory you should see root user changed to www-data:
This means were now editing the files as the www-data user which has permission, so any changes you make via SFTP should reflect this user change. Fixed!
Edit - This is the first time I answered my own question hopefully it's okay.
I am using CakePHP 2.4.7 and I'm trying to execute CakePHP shell on remote host.
I'm connecting to server as root and then executing $ [path_to_my_foler]/app/Console/cake
The output is: -bash: [path_to_my_foler]/app/Console/cake: Permission denied
How could it be? How to fix it?
Did you get this solve? I think this could do the trick. (Running the command from your app directory
chmod +x Console/cake
In CakePHP Version 3 and above this is the right command.
chmod +x bin/cake
This is CakePHP documentation for reference.
Console
The cake executable has been moved from the app/Console directory to
the bin directory within the application skeleton. You can now invoke
CakePHP’s console with bin/cake.
Documentation link