joomla 3 error: 0 Cannot open file for writing log - php

I'm migrating my joomla 3.3.6 project from local to online server, but I get this error when I try to login into my administrator panel:
Error: 0 Cannot open file for writing log
My tmp and logs paths are correct in my configuration.php, and the permissions of the folders and files are correct too (755 and 644).
I don't know what else to do.

When you done the migration, the configure paremeters were changing also. Access the root folder where you installed Joomla, there you will locate a file with name "configuration.php". Open the file and change the following lines with the new path of logs and tmp folders:
public $log_path = '/path/to/the/joomla/logs';
public $tmp_path = '/path/to/the/jooomla/tmp';
Also please check the permissions of the above folders when modifying.
In CentOS I changed the permissions of logs/error.php to 666 then it works.

This worked for me:
Check path of your application, by
<?php
$path = getcwd();
echo "Your Absolute Path is:" . $path;
?>
then set
$log_path = 'Your Absolute Path'/logs
If it does not solve issue, then
First check in ssh who owns the /var/www directory by:
ls -la /var
Then check what user apache uses
ps aux | grep apache
or you can use:
ps aux | grep http
output:
apache 29672 0.0 1.3 388232 14240
root 29679 0.0 0.2 110456 2252
in my case apache user for /var/www was apache
so after this I made apache the owner of /var/www by:
sudo chown -R apache /var/www

It is easy to resolve.
Access configuration.php using FTP or cpanel.
Edit directly in cpanel or download it to your computer using ftp.
Edit the Log and Tmp paths to .../log and .../tmp respectly.
That solves it.
Get back on Joomla backend to verify by Accessing System>>System Information>>Directory Permissions.
Hope that helps.

Related

How to fix problem with user permissions in CentOS7, Apache and php script

I faced strange problem wher ran Apache server and php7.1 script.
PHP doesn't have it's root folder write-access. It's necessary for my task to have those permission. I start httpd service on my system, then run my script, and it doesn't work because of lack of permissions.
Where do i have to change those permissions?
This is for Linux Server running Apache2, PHP 7.1
here you can see my processes (sorry cannot attach photo) (php is running under apache user)
Also here .php shows where my root folder is
(/var/www/html)
and here is my folder with permissions:
drwsrwsrwt+ 3 apache apache 103 html
As you can see I even tried to give chmod 7777 to that folder /var/www/html,
but it still didn't work!
Then, i desided to recursively add permissions to root folder (/var/www).
i used .php testfile to check what user runs apache and also to chek root directory of script
echo `whoami`;
echo getcwd() . "\n";
$filename = '/var/www';
if (is_writable($filename)) {
echo 'folder /var/www is ready to be written' . "\n";
} else {
echo '...cant be written';
};
I have that output:
apache /var/www/html folder /var/www/html not ready
another check of write permissions in another script (not mine) tells the same
I really stuck with that, please, help)
Thank you in advance!
I bet it is because of selinux, disable it by editing
/etc/selinux/config
and make sure it has
SELINUX=disabled
https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

Error in phpMyAdmin after updating to v4.8.0: The $cfg['TempDir'] (./tmp/) is not accessible

phpMyAdmin worked fine with v4.7.9. Now after updating to v4.8.0 today (replacing the old phpmyadmin folder against the new one) I'm getting this message in phpMyAdmin:
The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able
to cache templates and will be slow because of this.
I added the folder ./tmp/ like like this: /usr/share/tmp
phpMyAdmin is on: /usr/share/phpmyadmin
This didn't change anything.
Who know this error? What can I do?
Solution was to create a folder called tmp like this: /usr/share/phpmyadmin/tmp.
Also make sure that the user (or group) running the webserver (e.g. Apache) has write access to the newly created tmp folder. Consequently, change the ownership to that user or add write access for all users. The latter one might not be really advisable.
simple fix is to create tmp dir in your phpmyadmin dir and set permission to 777
mkdir tmp && chmod 777 tmp
then
update your config.inc.php file add that line
$cfg['TempDir'] = 'tmp';
I had this same problem on Ubuntu 18.04 when I replaced the phpMyAdmin version from the package repository (v4.6.6) with the latest version (4.8.0). I don't know if you are running on Ubuntu, but maybe my response will be helpful to you (or others) who encounter something similar.
I put the new version in the standard location, /usr/share/phpmyadmin/, but Ubuntu's package installation of PMA puts some configuration settings in other places (see /etc/phpmyadmin/ and /var/lib/phpmyadmin/). I found this setting in /etc/phpmyadmin/apache.conf:
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
and sure enough that directory had been created and had the proper permissions. Wanting to stay as close as possible to the package installation settings, I made this change in /usr/share/phpmyadmin/libraries/vendor_config.php and pointed directly to that folder:
//define('TEMP_DIR', './tmp/');
define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');
This setting is picked up by /usr/share/phpmyadmin/libraries/config.default.php (which you are not supposed to edit) to set $cfg['TempDir'].
In my case I added
$cfg['TempDir'] = '/usr/share/phpmyadmin/temp';
to the
config.inc.php
File within the phpmyadmin folder
Hope it will help someone
Create a temp directory owned by and restricted to the webserver user. Do not place it inside of the phpMyAdmin webroot. (In this example, the webserver runs as apache):
mkdir -p /var/tmp/phpMyAdmin
chown apache:apache /var/tmp/phpMyAdmin
chmod 700 /var/tmp/phpMyAdmin
Next, set TempDir inside of phpMyAdmin's config.inc.php:
$cfg['TempDir'] = '/var/tmp/phpMyAdmin';
Any answer suggesting that you create /usr/share/phpmyadmin/tmp is advocating bad security practice. This is generally true for temp directories, and explicitly stated in the official phpMyAdmin documentation:
For security reasons, all directories should be outside the tree
published by webserver.
For me phpmyadmin dir was found inside /opt/lampp/
open teminal inside /opt/lampp/phpmyadmin/
give root privileges to the terminal by typing sudo su command.
now in same terminal use (mkdir -p /tmp/) hit enter
now, chmod 777 /tmp
Inside phpmyadmin directory there is a file config.inc.php. Open it using same terminal .
add this line $cfg['TempDir'] = /tmp; and Save.
Now you are good to go , just reload the tab and the error will be gone.
Create a tmp folder in the base directory of the phpMyAdmin install (e.g. /usr/share/phpmyadmin/tmp), and make sure that it is writable by the user that PHP is running under.
From the phpMyAdmin documentation:
$cfg['TempDir']
Type: string
Default value: './tmp/'
The name of the directory where temporary files can be stored.
It is used for several purposes, currently:
The templates cache which speeds up page loading.
ESRI Shapefiles import, see 6.30 Import: How can I import ESRI Shapefiles?.
To work around limitations of open_basedir for uploaded files, see 1.11 I get an ‘open_basedir restriction’ while uploading a file from the import tab..
This directory should have as strict permissions as possible as the only user required to access this directory is the one who runs the webserver. If you have root privileges, simply make this user owner of this directory and make it accessible only by it:
chown www-data:www-data tmp
chmod 700 tmp
If you cannot change owner of the directory, you can achieve a similar setup using ACL:
chmod 700 tmp
setfacl -m "g:www-data:rwx" tmp
setfacl -d -m "g:www-data:rwx" tmp
If neither of above works for you, you can still make the directory chmod 777, but it might impose risk of other users on system reading and writing data in this directory.
well,in my case this error has occured when i was using ubuntu 18.04.
All you need is to go to the installation directory (in ubuntu - opt/lampp/phpmyadmin)
and create a folder tmp with all the suitable read/write permissions.
Follow these steps in case of ubuntu-
1.go to the PMA installation directory by typing following commands in cmd-
cd opt/lampp/phpmyadmin
2.Then type the following command-
sudo mkdir tmp && chmod 777 tmp
and then you are done..!!
I hope it helps..
1) create the tmp folder
mkdir /usr/share/phpmyadmin/tmp
2) findout your php user
<?php echo `whoami`; ?>
3) Change ownership of the tmp folder to the php user found in step 2
sudo chown -R step2phpuser:step2phpuser /usr/share/phpmyadmin/tmp
4) Signout of phpmyadmin and sign back in
I had the same error message. I'm using Ubuntu16.04 with lampp. You should go to 'phpmyadmin' directory, in my case '/opt/lampp/phpmyadmin/', create a new 'tmp' folder. Open a terminal window and:
cd YOUR_PATH_TO_PHPMYADMIN
sudo mkdir tmp
Now you have to change the group of the 'tmp' folder to give access to php user. In order to find it, you can create a php file inside your localhost directory, in my case 'htdocs'
sudo touch user.php
sudo nano user.php
Inside nano editor, type:
<?php echo `whoami`; ?>
Then press CTRL + O and CTRL + X to save and exit.
Open the browser and type in your address bar
localhost/user.php
It shows your php user.
After that, go to the terminal and navigate to your recently created 'tmp' directory inside phpmyadmin directory and type:
sudo chgrp YOUR_PHP_USER tmp -R
And change the permission to the 'tmp' directory:
sudo chmod 775 tmp -R
I recommend never give 777 permission to any file.
I hope it helps!
For Arch and Manjaro users:
Create a folder tmp at /etc/webapps/phpmyadmin/ - mkdir /etc/webapps/phpmyadmin/tmp
Set permission to 777 - chmod 777 /etc/webapps/phpmyadmin/tmp
Add this line to the config file at /etc/webapps/phpmyadmin/config.inc.php - $cfg['TempDir'] = '/tmp';
Cheers :)
I had the same problem but none of the answers above could solve.
In my case my php security settings was so strict protecting php to access directories out of scope defined in open_basedir located at my /etc/php.d/99-security.ini(which I added perviously from a security toturial and the settings also could be located at /etc/php.ini file in your case):
;; Limit PHP Access To File System
; Limits the PHP process from accessing files outside
; of specifically designated directories such as /var/www/html/
open_basedir="/home/:/etc/phpMyAdmin/:/var/lib/phpMyAdmin/"
change to:
open_basedir="/home/:/etc/phpMyAdmin/:/var/lib/phpMyAdmin/:'/usr/share/phpmyadmin/tmp/" ;<== changing to this solved the prblem
you just need to add your own directory in error mesage ('/usr/share/phpmyadmin/tmp/') and the end of open_basedir option. Don't forget placing separator : before adding it.
If the folder already exists for example from a previous installation:
chmod -R 777 PATH_TO_FOLDER
Therefore permission on subdirectories are also modified (recursively).
In my case [MacOs El Capitán/portuguese], the message was:
The $cfg['TempDir'] (./temp/) is not accessible
My solution, in xamppfiles/phpmyadmin/config.inc.php:
$cfg['TempDir'] = './temp/'; to $cfg['TempDir'] = '../temp/';
That is, I just added a point to the path... work's fine.
I just changed my vendor_config.php file to define('TEMP_DIR', '/tmp/'); instead of define('TEMP_DIR', './tmp/');
This seems to work.
I had a similiar problem, with the "temp" directory. The solution was to change the owner and group of the "twig" directory (inside "temp") to "apache" (both owner and group)
Create the tmp folder in the root of phpmyadmin files
In addition to that, you also need to provide all permissions to that folder. That's what I did in Windows.
My Answer goes to centos 7 Sentora users,
tmp folder has to be created under phpMyadmin of Sentora as shown below
cd /etc/sentora/panel/etc/apps/phpmyadmin/
sudo mkdir tmp
After creating the folder make sure you give Apache access permissions to the tmp folder
chown -R apache /etc/sentora/panel/etc/apps/phpmyadmin/tmp/
simply go to the phpmyadmin folder and put this code
$cfg['TempDir'] = './tmp/';
and then check tmp folder is exists or not into phpmyadmin if not exists then create tmp folder and give read and right permission to it.
For me, the error message was as follows:
The $cfg['TempDir'] (/var/lib/phpmyadmin/tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this
Then I navigate and checked the location. there was the tmp folder but was owned by www-data by default. After that, I make it writable by the user the PHP is running under. Problem solved.

Getting Access forbidden on new localhost project

I'm attempting to setup a new webproject based off of the Open Source Point of sale system. I have followed the install steps as I usually do, but when I goto my localhost/webproj I get the following error:
Access forbidden!
You don't have permission to access the requested directory. There is
either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.11
I have checked readonly flags on all files/folders, no problem there.
but there is this line in the readme which I'm having trouble verifying and wondering if that could be the cause.
PHP needs to have php-gd, php-bcmath, php-intl, php-sockets
and php-mcrypt installed and enabled.
how do I check these php 'things' are installed and enabled?
EDIT: Using windows 10. logged in locally as an admin user. Single machine no domain.
CD into your localhost directory using terminal / cmd prompt and check for ownership permissions firstly.
cd localhost (my assumption, you may need to tweak this to where your localhost files are stored) then run ls -ll which will display your permissions and ownership information.
If you find the ownership is wrong run:
chown -R yourUserName:staff webproj/*
You can then run a chmod to be sure:
chmod -R 755 webproj/*
To run a test you could simply chmod the files to 777 to see if this allows entry.
Are you sure there is an index.php in that folder; or whatever is your default directory index? Default permissions are usually good, but there are times you may have to chmod 777 on local dev to make things work. You can check modules with phpinfo(). Create a file, say phpinfo.php, and add just a single line like so: <?php phpinfo(); ?>
Oh, and XAMPP is usually owned by root, at least on nix, so chowning htdocs to your own account will fail.
OK it looks like this was caused by the new application having its index.html in a sub folder. If I launched directly from this sub folder it works. This was done to heighten security in the web application.

Can't create a directory using mkdir() with 0777 permissions

I have this:
<?php
$oldmask = umask(0);
mkdir("test", 0777);
umask($oldmask);
?>
but receive the error
Warning: mkdir(): Permission denied in /Applications/XAMPP/xamppfiles/htdocs/add/add_site.php on line 27
I am on Mac OSX El Capitan using XAMPP.
So assuming you are calling your script through Apache, the apache user must have rights to write on the directory.
In order to do so, first you have to find what user is running apache, for this you may use :
ps aux | grep http
or
ps aux | grep apache
When you've found apache user, you can create a writable directory for apache :
mkdir /Applications/XAMPP/xamppfiles/htdocs/add/apachedir # create a directory for apache
# for the line below, replace apache:apache by your apache user:group.
chown apache:apache /Applications/XAMPP/xamppfiles/htdocs/add/apachedir # give directory ownership to apache user
Now if you edit your script as such :
mkdir("./apachedir/test", 0777);
Everything should be working.
Then I'd recommend you to be careful when changing a directory permission to 777, it means everyone can read / write in the folder. This is a bad practice most of the time, and critical when this folder is a son of apache webroot (any user could write in this directory and could run their code with apache rights).
You have to give full permission to you htdocs directory in xampp.

Codeigniter – The upload destination folder does not appear to be writable

I'm using CodeIgniter's upload helper and received the above error when trying to upload an image. The permissions for the folder I'm trying to upload to are 755. When I changed it to 777, the error went away, but isn't 777 kind of a security risk?
I'm running on Apache. Is there a better way to allow users to upload files without setting the folder permissions to 777? How can I get 755 to work?
Thanks for the help!
If the folder is for loading files by users than permisision 777 is required.
It's up to you to validate what files are loaded through upload script.
Also you can use .htaccess to alow or not alow certain files to be executed from that directory.
The documentation for upload in codeigniter it's pretty simple and intuitive. Also here you can look at some ways to validate the type of files that are uploaded https://codeigniter.com/userguide3/libraries/file_uploading.html
I don't think so giving any folder on server 777 permission is good. Instead giving 777 permission i suggest make www-data user as owner of desired folder and give 755 permission like below
chown -R www-data:www-data /var/www/html/uploads/
For 755 permission
chmod 755 -R /var/www/html/uploads/
In my NGINX + PHP-FPM installation the issue was solved changing the SElinux parameters from enforcing to permissive:
edit and change options with vi /etc/selinux/config
apply options without restart with sudo setenforce 0
check the status with sestatus.
try this:
sudo chmod 777 -R /path/to/write/folder
I know this is not an active question and may not be an issue for most but because I came across this I wanted to clarify for anyone else that may see this.
You DO NOT need 777 permission on your upload directory. This is actually not a good idea. The last 7 means it is public writable which does not need to be in most cases. Typically 755 should be good enough
More than likely the issue is that the directory is not owned but the user running Apache which is typically www-data
Step by step:
Check owner of dir (i.e.)
ls -l /path/to/upload/
Output should show similar
drwxr-xr-x 4 www-data www-data 4096 Oct 26 20:41 uploads
If not then you should change to www-data if that is the user Apache is running under. To check what user apache is running under :
ps aux | egrep '(apache|httpd)'
This should list something similar:
www-data 419 0.0 0.9 556292 156656 ? S 18:46 0:00 /usr/sbin/apache2 -k start
Hope This Helps!

Categories