Zend Cache - problem with deleting cache files - php

I have an strange problem with Zend Cacke (File Backend) running on linux with apache and php 5.2
The files are stored in /myspace/tmp1
Directory has the persmission:
drwxrwxrwx 2 nobody nogroup 8192 2010-09-20 13:35 tmp1
The created temp file has the following permissions:
-rw------- 1 nobody nogroup 317 2010-09-20 13:40 content---a51607ba255692370eae1155c7f45856
If if i do:
$cache->clean(); inside my script, than the method returns true, but the file is not removed (no error in php error log).
On my local development machine running under win xp everything works fine. I think it is some kind of permission problem? The Apache is running as "nobody"
Any suggestions are welcome!

I think you need to use Zend_Cache::CLEANING_MODE_ALL as by default it cleans only outdated AFAIK.

Related

Laravel returning server error 500 on CentOS 7

As the title says, I have a VPS running on CentOS 7, I installed all the requisites for Laravel, PHP 7.3, but it still giving me 'Server Error 500'.
Note that this is a fresh installation of Laravel with composer.
My CentOS version is CentOS Linux release 7.2.1511 (Core)
PHP version is PHP 7.3.6 (cli)
I manually installed all the necessary modules from PHP
What I have already tried
I already did quite a lot of research:
Laravel giving 500 internal error on centos 7 with apache and php 7
I followed what the answer to that questions says and still the same for me.
I did also set up permissions correctly following this other post:
How to set up File Permissions for Laravel 5 (and others)
Also these ones
Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
https://www.ionos.com/community/server-cloud-infrastructure/apache/how-to-fix-http-error-code-500-internal-server-error/
And a bunch of more articles I read on another websites.
These are the permissions for the project folder:
drwxr-xr-x 13 apache apache 4096 May 31 05:23 laravel
And for storage:
drwxr-xr-x 5 apache apache 4096 May 31 04:44 storage
Tried generating the key and got this:
[root#server laravel]# php artisan key:generate
ErrorException : file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory
at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
> 96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1 file_get_contents("/var/www/laravel/.env")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
2 Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:soTdeaCmsY1ELnpJLCcYkBJjY6SWiLYwY+Mvoxl9wOw=")
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:80
Please use the argument -v to see more details.
[root#server laravel]#
Seems like you miss the Laravel environment configuration file.
In a fresh Laravel installation you should have a .env.example file. Duplicate that one and rename it to .env then run the php artisan key:generate command.
Did you created the var/www/laravel/.env file from your var/www/laravel/.env.example file?
So, I fixed it configuring properly the .env and generating a key as #mdexp mentioned.
So for everyone having problems, check the links in my question and set everything correctly

PHP can't see any files on a mounted filesystem

I have a new file server (FilServerB) that I have had up and running for a few months. I've been moving all my processing servers over to use FileServerB for their PHP code. I recently found a server (server name is susan) that I had missed, and it was still connecting to the old file server (FileServerA). When I mounted FileServerB on susan, none of the code would run on it anymore. In ssh, when I go to a directory with PHP code in it, and run "php cleanISL.php", it says this:
Fatal error: Unknown: Failed opening required 'cleanISL.php' (include_path='.:/local/online/live/common:/local/online/pear') in Unknown on line 0
If I create a new php file on the local filesystem, it runs just fine. If I try an is_file or is_directory for a file or directory that I know exists on the mounted filesystem, it always returns false. However, I can glob directories, and it shows the files in there just fine.
I've tried changing (and removing completely) my include_path, I've tried going back to the old file server (which works), and then unmounting the old one and mounting the new one the exact same way (still doesn't work), and a few other things. I can't tell if the issue is with PHP, or somehow with the way the server is mounted, or something else. I've made sure SELINUX is disabled. The issue seems to be only affecting PHP, and only when I mount the new FileServerB, and only on this particular server (susan). But I'm baffled at what could be causing it or how to fix it.
Also, I have mounts to other servers (for data/media) on this same server (susan), and those work just fine, ie, PHP can see and read files on those mounts too.
UPDATE 1, strace info
This is the relevant line of the strace on a failed is_dir:
stat64("/online/live/tools/test/fixes/", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
And this is the output of a stat command on the same dir:
File: `/online/live/tools/test/fixes/'
Size: 4096 Blocks: 8 IO Block: 32768 directory
Device: 18h/24d Inode: 11815229588 Links: 3
Access: (0775/drwxrwxr-x) Uid: ( 1004/ UNKNOWN) Gid: ( 1010/ UNKNOWN)
Access: 2016-07-06 07:28:46.606024801 -0600
Modify: 2016-06-24 16:23:42.206547505 -0600
Change: 2016-06-24 16:23:42.206547505 -0600
And this is a namei -m result:
dr-xr-xr-x /
lrwxrwxrwx online -> /mnt/code/online/
dr-xr-xr-x /
drwxr-xr-x mnt
drwxr-xr-x code
drwxr-xr-x online
drwxrwxrwx live
drwxrwxr-x tools
drwxrwxr-x test
drwxrwxr-x fixes

"End of script output before headers" on CentOS, but working on other LAMP stacks

I've set up a Centos 6 + CPanel 11 VPS, and everything is as it was out of the box. I've installed Phorum 5.2.20 in the public_html directory, but Phorum is causing an error 500. The error log reports:
[Mon Jul 27 11:21:57.770447 2015] [core:error] [pid 14342] [client x.x.x.x:42531] End of script output before headers: admin.php
The code works fine on my Debian LAMP server (and several other non-Centos/CPanel LAMP stacks I've used to test this), and Wordpress and some other stuff runs fine on the CentOS machine.
I've tried other code too, and it works on my other servers, but doesn't work on CentOS. Phorum is the only code that matters, so I made question focuses on that. I'm also reluctant to edit the core files of Phorum.
Any ideas?
Fixed: Permission Issue
I have also faced the same issue after installing fresh installation on VPS, later I found It's a permission issue, Directory should be 755 and files should be 644 then only it works.
sudo chmod -R 755 projectfolder
sudo chmod -R 644 index.php //projectfiles
I think there is an issues with the php handler. Can you please try to change your php handler through WHM >>Service Configuration >> Configure PHP and suEXEC and check your URL again.
For me the error was caused by file permissions. Luckily it was just the one file causing it so I used the same permissions as the working .php files and it worked.
In my case 644 worked with enough permission to run and not too much to trip the security settings.
I had same error for more than a day finally i found out that accidentally my /home/mysite_username/fcgi-bin/php7.0.fcgi file owner and group was changed to root. Restoring owner to mysite_username solved this issue. (I'm using Virtualmin)
Fix permissions from User Account Menu of CWP.

php + ubuntu upgrade

Just upgraded from Ubuntu 12.10 to Ubuntu 13.10
But left old php.ini and httpd.conf
And this is what I get now:
Fatal error: require_once(): Failed opening required 'serverConstants.php' (include_path='.:/usr/share/php:/www/allSites') in /www/myproject/src/lib/starter.php on line 12
-rwxrwxrwx 1 www-data root 202 Jan 23 2013 /www/allSites/serverConstants.php
How is this even possible?
/www is mounted from host machine (Ubuntu runs in a VM) if that matters, but I did't have this problem before the upgrade
Some servers (particularly on shared servers, but could be anywhere) forbid access to "world writable" files and directories, as a security measure. The first thing to try is changing the permissions on this file to 644 or even 444.

php apache file ownership and creation problem

I am trying to do a really basic rename of a file to another name in my code. However there seems to be some ownership/permissions problem that is stopping this working correctly.
This is my (simplified) code:
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$St_Num = '7940';
$Co_Code = 'RDCO2';
rename("$St_Num-$Co_Code-1.jpg", "$St_Num-$Co_Code-4.jpg");
These are my permissions of the files I am trying to change:
Code:
-rw-r--r-- 1 apache dev 4065 Oct 22 17:57 7940-RDCO2-3.jpg
-rw-r--r-- 1 apache dev 4276 Oct 28 09:39 7940-RDCO2-2.jpg
-rw-r--r-- 1 apache dev 4336 Oct 28 09:39 7940-RDCO2-1.jpg
This code was working, and it seemed to work when apache was the creator of the file. However, when I changed the ownership to 'apache' it stopped working. Does PHP/Apache have a concept of knowing who the creator of a file was? Would this stop a rename() from working?
I'm stumped with this one now - any help is appreciated.
Thanks,
Picco
do chmod(0666) [on the server] to give all users (including apache) write rights
You have to set read-write ownership for that specific directory to public-www.

Categories