File not readable exception - pear/Config_Lite - php

I have two config files located in: /etc/svnauth and var/www/svnauth
I have given read, write access to for both files like shown below
chown -R apache:apache /etc/svnauth
chmod -R 770 /etc/svnauth
chown -R apache:apache /var/www/svnauth
chmod -R 770 /var/www/svnauth
When I try to read these two files using pear/Config_Lite, /etc/svnauth always fails. I can successfully read the /var/www/svnauth file
Any reasons for this? What am I missing here
Following is the error message i get:
Fatal error: Uncaught exception 'Config_Lite_Exception_Runtime' with message 'file not readable: /etc/svnauth' in /var/www/html/svnmanager/Config/Lite.php:112 Stack trace: #0 /var/www/html/svnmanager/index.php(60): Config_Lite->read('/etc/svnauth') #1 {main} thrown in /var/www/html/svnmanager/Config/Lite.php on line 112

is open_basedir set in your php.ini? If so, does it contain /etc/?

Related

Wordpress wp-settins.php errors Notice: Use of undefined constant ABSPATH

Just installed Wordpress with this tutorial https://www.digitalocean.com/community/tutorials/wordpress-lamp-ubuntu-16-04-ru and got php errors when open wp-settings.php
Notice: Use of undefined constant ABSPATH - assumed 'ABSPATH' in /var/www/wordpress/wp-settings.php on line 19
Warning: require(ABSPATHwp-includes/load.php): failed to open stream: No such file or directory in /var/www/wordpress/wp-settings.php on line 19
Fatal error: require(): Failed opening required 'ABSPATHwp-includes/load.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/wordpress/wp-settings.php on line 19
Okey, I tried
sudo chmod 755 $(find /var/www/wordpress/ -type d)
sudo chmod 644 $(find /var/www/wordpress/ -type f)
Tried to manually set the way to WP's files in wp-config.php. Tried another version of the WP. Set the ownership of the files and folders to not-root sudo-user. Nothing changes. Tryed on clear 14.04 and 16.04 ubuntu and nothing.
Your constants need to be strings.
It is string, I didn't change files from repo.
Also, my WP can't update itself because
Warning: copy(/var/www/wordpress/wp-admin/includes/update-core.php): failed to open stream: Permission denied in /var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php on line 257
My mistake, I should open domain/wp-admin/options.php instead of domain/wp-settings.php

Permission denied for new php files uploaded by ftp user

When i try to upload php file using vsftpd to /var/www/ and visit the file from web server i got this error,
Warning: Unknown: failed to open stream: Permission denied in Unknown
on line 0
Fatal error: Unknown: Failed opening required
'/var/www/.../.../public_html/d.php'
(include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
i tried chown -R www-data:www-data /var/www after that the error got fixed but i have to do the same every time i upload a new file, is there is anyway to fix that for all new files?
The best way is to apply an ACL to the directory in question.
This will set the default so new files and folders are given the ACL, this says that the group of www-data will have read,write,execute permissions by default on all files/folders from /var/www recursively
sudo setfacl -Rdm g:www-data:rwx /var/www
This will set the ACL for existing files and folders, this says that the group of www-data will have read,write,execute from /var/www recursively for existing files and folders
sudo setfacl -Rm g:www-data:rwx /var/www

Laravel php artisan class log does not find

centos7.0
laravel 5.1.11
php7.0
"php artisan"
message:
Fatal error: Uncaught ReflectionException: Class log does not exist in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php:741
Stack trace:
#0 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('log')
#1 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 /home/website/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Foundation\Application->make('log')
#4 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(774): Illuminate\Container\Container->getDependencies(Array, Array)
#6 /home/website/vendor/ in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
The error was thrown because one of the values in the .env file may have spaces.
Just enclosed any values with space in double quotes.
For example let's assume that this is part of your .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=This Will Cause An Error
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
....
APP_KEY=This Will Cause An Error will cause this issue because it needs to be in quotes like:
APP_KEY="This Will Work"
Also any space after the values may cause the same issue too
In my case the reason for this error was a missing php extension. Since this missing extension raises an error, the logger tries to log it. This exception appears as a result of no 'log' class resolved from the container. I think this is a Laravel bug.
Check your Apache user and file system user first.
Then run the following commands to set file system permissions:
sudo chmod 755 storage -R
sudo chmod 755 vendor -R
sudo chmod 755 bootstrap -R
After you finished changing the file permissions, clean your chache with the following commands:
php artisan config:cache
php artisan cache:clear
php artisan config:clear
This works for me.

CakePhp with xampp

I am trying to execute my first application in cakephp, but it's giving an error
Fatal error: Uncaught exception 'CacheException' with message 'Cache
engine _cake_core_ is not properly configured.' in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php:166 Stack trace:
#0 /opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php(136): Cache::_buildEngine('_cake_core_') #1
/opt/lampp/htdocs/CakeTooDoo/app/Config/core.php(336):
Cache::config('_cake_core_', Array) #2
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Core/Configure.php(78):
include('/opt/lampp/htdo...') #3
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/bootstrap.php(171):
Configure::bootstrap(true) #4
/opt/lampp/htdocs/CakeTooDoo/app/webroot/index.php(92):
include('/opt/lampp/htdo...') #5 {main} thrown in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php on line 166
and two warnings
Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to
File cache in /opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php on
line 310
Warning: /opt/lampp/htdocs/CakeTooDoo/app/tmp/cache/persistent/ is not
writable in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Engine/FileEngine.php on
line 337
Pleas give me any solution to do my first application with cakephp.
you can use a permissive ownership:
chmod -R 777 app/tmp
A better method is to change group ownership of tmp and everthing below it to www-data ( or whatever group your apache server runs in ) with 'chgrp -R www-data tmp' followed by 'chmod -R 774 tmp' This makes tmp read/write for you and the www-data group but readonly for everyone else
let me know if i can help you more.
The cache folder is not writable according to warning.
open terminal, run sudo chmod 777 /opt/lampp/htdocs/CakeTooDoo -R
Plus, you should reconfigure file permissions, like 775, in real productions.

permission denied on php from command line

I'm trying to run a script using crontab, but I have problems making it work even from the command line. The script runs fine from the browser and it creates some excel files in reports/ folder which is owned by apache. The script file is owned by me: john.
When I try to run the script from the command line, I get the following warnings, and the excel file doesn't create. I've tryed with the full path, but I get the same results.
This is what I got after I try to run the script from command line
public_html]$ php include/tests/mailme.php
PHP Warning: fopen(reports/4-March.xls): failed to open stream: Permission denied in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 90
Warning: fopen(reports/4-March.xls): failed to open stream: Permission denied in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 90
PHP Fatal error: Uncaught exception 'Exception' with message 'Can't open reports/4-March.xls. It may be in use or protected.' in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php:93
Stack trace:
#0 /home/john/public_html/PHPExcel/Writer/Excel5.php(233): PHPExcel_Shared_OLE_PPS_Root->save('reports/...')
#1 /home/john/public_html/include/generate_daily_excel.inc(401): PHPExcel_Writer_Excel5->save('reports/...')
#2 /home/john/public_html/include/tests/mailme.php(41): generateDailyExcel('04-02-2013')
#3 {main}
thrown in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 93
Fatal error: Uncaught exception 'Exception' with message 'Can't open reports/4-March.xls. It may be in use or protected.' in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php:93
Stack trace:
#0 /home/john/public_html/PHPExcel/Writer/Excel5.php(233): PHPExcel_Shared_OLE_PPS_Root->save('reports/...')
#1 /home/john/public_html/include/generate_daily_excel.inc(401): PHPExcel_Writer_Excel5->save('reports/...')
#2 /home/john/public_html/include/tests/mailme.php(41): generateDailyExcel('04-02-2013')
#3 {main}
thrown in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 93
I assume that if I change the owner of reports, the browser version will not be allowed to save. I'm new to linux and rights.
When you run php code from command line. The script runs with your user permission , not with www-data user permissions.
You should run script as root (not recommend) , or instead change the file permissions:
sudo chown yourUser:www-data file
sudo chmod 664 file
And you should do nearly the same with the directory:
sudo chown yourUser:www-data dir
sudo chmod 775 dir
The error is laid out very explicitely for you: "failed to open stream: Permission denied". When you are running this from the command line, you are user "john" (I assume from your home path). Does user "john" have permission to write in the reports directory?
What are the permissions of the actual reports directory?
ls -al /home/john/public_html/reports

Categories