Cannot load or save configuration - php

I get this cannot load phpMyAdmin message. I've tried creating the config folder and the config.inc.php file. When I ĺog on to localhost/phpmyadmin/setup/ it still gives me this message.
Error message: "Cannot load or save configuration Please create web server writable folder config in phpMyAdmin top level directory as described in documentation. Otherwise you will be only able to download or display it."
I have given the www/html folder full rights.
How to I fix this?
thanks in advance!

I have had similar issue on my Ubuntu 16.04. I made a research and in the end I found a resolution of the issue. Maybe my case solution will help somebody else.
Background: For security reasons I have non privileged user and group apache:apache (sudo groupadd apache | useradd -g apache apache). They are preset by directives (User apache; Group apache) in /etc/apache2/apache2.conf. This user apache:apache owns Apache2 main directory (sudo chown -R apache:apache /etc/apache2) and some other files, for example: sudo chown -R apache:apache/etc/phpmyadmin/htpasswd.setup
In this manual: http://docs.phpmyadmin.net/en/latest/setup.html - I found that...
Debian and Ubuntu have changed way how setup is enabled and disabled,
in a way that single command has to be executed for either of these.
To allow editing configuration invoke:
/usr/sbin/pma-configure
To block editing configuration invoke:
/usr/sbin/pma-secure
Note! In the content of the two files listed above we talk about /var/lib/phpmyadmin/config.inc.php instead of /etc/phpmyadmin/config/config.inc.php. It was the key.
In my case I was modified the content of these scripts (see below) and now I can use localhost/phpmyadmin/setup properly.
/usr/sbin/pma-configure:
#!/bin/sh
echo "Unsecuring phpMyAdmin installation..."
echo "Setup script can now write to the configuration file."
echo
echo "Do not forget to run /usr/sbin/pma-secure after configuring,"
echo "otherwise your installation might be at risk of attack."
sudo sudo chown -R apache:apache /var/lib/phpmyadmin/config.inc.php
chmod 0660 /var/lib/phpmyadmin/config.inc.php
/usr/sbin/pma-secure:
#!/bin/sh
echo "Securing phpMyAdmin installation..."
echo "Setup script won't be able to write configuration."
sudo sudo chown -R root:root /var/lib/phpmyadmin/config.inc.php
chmod 0640 /var/lib/phpmyadmin/config.inc.php

Related

Directory is not writable CentOS7, Apache 2.4.6, PHP 5.4.16

I have Linux user, let say admin. Apache process is running under admin user. I have the next simple script for testing permissions:
<?php
$flag=is_writable("/var/www/html/admin/protected/runtime");
if($flag)
print "Is writable\n";
else
print "Is not writable\n";
echo 'Current user: ' . exec('whoami');
?>
When I run this script in the console it says:
Is writable
Current user: admin
When I open page in the Firefox it says:
Is not writable Current user: admin
I'm confused, how it can be that directory is writable and is not writable simultaneously under the same user?
Problem is in selinux. Permissive mode setenforce 0 - solves problem. But it is not good solution, better one is configure selinux. More about selinux available here https://wiki.centos.org/HowTos/SELinux.
See https://techblog.jeppson.org/2016/10/install-wordpress-centos-7/ which answered a lot of my SELinux issues.
Basically you can leave setenforce to 1 and run
sudo semanage fcontext -a -t httpd_sys_content_t /var/www/html/
sudo restorecon -v /var/www/html/
to grant specific permissions to your wordpress directory.
==== EDIT ====
In practice, it worked to solve the top wordpress root directory issue but lower levels have an issue. I ended up with:
chcon -R -t httpd_sys_rw_content_t /var/www/html/
Im sure that centos is viewing your browser as a non group user, therefore if your permissions for that directory are anything but 777, Firefoxe probably won't be able to do it.
you could change ownership of the directory to apache with
sudo chown -R www-data:www-data /path-to-directory
or you could try making the file permissions 777 just to see if that is the problem.
In general, it is best to save files to your database for security reasons.

Wordpress plugin install: Could not create directory

I'm using WordPress on centos 6.
I try to install a plugin. But I got this error:
Installing Plugin: bbPress 2.5.9
Downloading install package from https://downloads.wordpress.org/plugin/bbpress.2.5.9.zip…
Unpacking the package…
Could not create directory.
How can I resolve this?
P/S: I run this command:
sudo -u root touch /var/www/html/wordpress/wp-content/plugins/test.txt
and it works. But I still get that error.
You only need to change the access permissions for your WordPress Directory:
chown -R www-data:www-data your-wordpress-directory
You can fix this by using the following commands. You should first be in the root folder of Wordpress.
sudo chown -R www-data:www-data wp-content/plugins/
sudo chmod 775 wp-content
sudo chown -R www-data:www-data wp-content/
The user that is running your web server does not have permissions to write to the directory that Wordpress is intending to create the plugin directory in. You should chown the directory in question to the user that is running Wordpress. It is most likely not root.
In short, this is a permissions issue. Your touch command is working because you're using it as root, and root has global permissions to write wherever it wants.
A quick solution would be to change the permissions of the following:
/var/www/html/wordpress/wp-content
/var/www/html/wordpress/wp-content/plugins
Change it to 775.
After installation, don't forget to change it back to the default permissions.. :D
I had to give ownership of /plugins and /upgrade to the server, nothing else.
$ cd /var/www/wordpress/wp-content
$ sudo chown www-data:www-data /plugings
$ sudo chown www-data:www-data /upgrade
Running Apache server on Ubuntu 18.04. Maybe more dirs will need to be changed later. Anyways, I plan to restore permissions once I finish editing, as suggested in this anwser.
If you have installed wordpress using apt, the config files are split in multiple directories. In that case you need to run:
sudo chown -R -h www-data:www-data /var/lib/wordpress/wp-content/
sudo chown -R -h www-data:www-data /usr/share/wordpress/wp-content/
The -h switch changes the permissions for symlinks as well, otherwise they are not removable by user www-data
To solve permission issue on plugins and themes on localhost or production quickly, you just run this
sudo chmod 757 wp-content/themes
sudo chmod 757 wp-content/plugins
if take care permission on production, you can run
sudo chown -R www-data:www-data wp-content/themes
sudo chown -R www-data:www-data wp-content/plugins
If you are mac user , using XAMP
Go to the htdocs folder and open the terminal on the folder , as shown in the screenshot
Then Type the following command on the Terminal
**sudo chmod -R 777 <your wordpress folder Name>/**
E.g sudo chmod -R 777 wordpress/
CentOS7 or Ubuntu 16
1.
WordPress uses ftp to install themes and plugins.
So the ftpd should have been configured to create-directory
vim /etc/pure-ftpd.confg
and if it is no then should be yes
# Are anonymous users allowed to create new directories?
AnonymousCanCreateDirs yes
lastly
sudo systemctl restart pure-ftpd
2.
Maybe there is an ownership issue with the parent directories.
Find the Web Server user name and group name if it is Apache Web Server
apachectl -S
it will print
...
...
User: name="apache" id=997
Group: name="apache" id=1000
on Ubuntu it is
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used
then
sudo chown -R apache:apache directory-name
3.
Sometimes it is because of directories permissions.
So try
sudo chmod -R 755 directory-name
in some cases 755 does not work. (It should & I do not no why) so try
sudo chmod -R 777 directory-name
4.
Maybe it is because of php safe mode.
So turn it off in the root of your domain
vim php.ini
then add
safe_mode = Off
NOTE:
For not entering FTP username and password each time installing a theme we can configure WordPress to use it directly by adding
define('FS_METHOD','direct');
to the wp-config.php file.
If anyone using shared hosting and get same problem it may be disk space issue. In that case contact with your hosting support and ask them to increase disk space of your acocunt.
You need to change the permission of the directory
At first change the user HTML folder (replace yourcomputerusername)
sudo chown yourcomputerusername:yourcomputerusername /var/www/html
Next change the permission for the user
cd /var/www/html
sudo chmod -R goa=rwx wordpress
or
sudo chmod -R 777 wordpress/wp-content
I was on XAMPP for linux localhost and this worked for me:
sudo chown -R my-linux-username wp-content
What I end up doing is every time I create a WordPress project. in /www/html
I run below command
sudo chown www-data:www-data wordpress_folder_name -R
hope this will help someone.
For me the problem was FTP server that WP is using to upload update. It had writting disabled in configuration, so just enabling it fixed the problem.
Shame on WordPress for providing such misleading error message.
You could try
sudo chmod goa=rwx -R /var/www/html
None of the above work for me except this one.
sudo chown daemon:daemon /opt/bitnami/apache/htdocs/
Don't forget to change /opt/bitnami/apache/htdocs/ to your directory
Webserver user must have write access to directories to perform such operations, so you can try to change owner of files to webserver user (apache in this example, but can be differ from yours)
chown -R apache YOUR_BLOG_DIRECTORY
If you are using some app that wraps http, you have to set these user in the command.
sudo chown -R [desireduser]:[desireduser] wp-content/
By example, if you are using lampp, the users that init httpd is "daemon" and the command that works will be:
sudo chown -R [desireduser]:[desireduser] wp-content/
You can search in your httpd.conf file
To solve permission issue on ubuntu server, you just run this
sudo chmod 777 -R 'wordpress wp-content file location'
for example.
sudo chmod 777 -R /usr/share/wordpress/wp-content
wordpressProject is the project name.
/var/www/html/wordpressProject sudo chmod -R 777 wp-content
Thanks. It will work.
Absolutely it must be work!
Use this
chown -Rf www-data:www-data /var/www/html

How to set root access for all files put inside my Apache2 root directory?

I am learning PHP at the moment on Linux. I have an Apache2 server running locally. Whenever I tried to save a PHP file into the root directory of Apache2 server ( /var/www/html/), I was told that permission denined.
So, I searched around and found that by default, the admininstartor do not have the root access unless explicitly request for it (like sudo su). I have also seen some posts which ask me to use gksu nautilus. However, my linux 14.04 LTS Ubuntu doesn't comes with it. (I know I can use apt-get gksu but at the moment, downloading it from internet is not an option).
Is there anyway that I can change the permission to my Apache2 server root directoy so that I can use any text editor to save/edit to that directory directly. Only the ways that do not need downloading stuffs from internet are feasiable for me at the moment.
For linux open the terminal with root login then go to the root folder and run the following command chmod 777 following is the example :-
To change all the directories to 777 (-rwxr-rwxr-rwxr):
find /opt/lampp/htdocs -type d -exec chmod 777 {} \;
To change all the files to 644 (-rwxr-rwxr--rwxr--):
find /opt/lampp/htdocs -type f -exec chmod 777 {} \;
If this will not work then try the following :-
Create a new group
groupadd webadmin
Add your users to the group
usermod -a -G webadmin user1
usermod -a -G webadmin user2
Change ownership of the sites directory
chown root:webadmin /var/www/html/
Change permissions of the sites directory
chmod 2775 /var/www/html/ -R
Now anybody can read the files (including the apache user) but only root and webadmin can modify their contents.
Hope this will help you in solving your problem.
You can set the DocumentRoot in your /etc/apache2/httpd.conf file to a place where Apache has write access. For example, you could set it to /tmp/www if you made a directory there. (If you still don't have access, you can always give everyone read access by running chmod a+r /tmp/www, but you should probably be fine.)
Obviously leaving your Apache Document Root as /tmp/www is a bad idea, so you can change it to something like /home/chris once you've got it working.
One important note: after you make a change like this, you must restart the Apache server. This can be done by running apachectl restart; ironically, you might have to have administrator rights in order to execute this (or even edit the config file in the first place), so make sure you prefix your edit & restart with sudo just in case.

phpMyAdmin "Cannot load or save configuration"

I have been trying to setup phpMyAdmin on a macbook pro running yosemite 10.10.2. I have created a config folder in phpmyadmin and have given it the permissions required:
chmod o+wr ~/Sites/phpmyadmin/config
However, when I then go onto "localhost/phpmyadmin/setup" I get an error:
Cannot load or save configuration
Please create web server writable folder config in phpMyAdmin top level
directory as described in documentation. Otherwise you will be only able to
download or display it.
(I have tried attaching an image, but can't due to my reputation points)
I have tried resetting the permissions, tried deleting and recreating the folder. Tried redownloading the phpmyadmin zip but nothing seems to work.
Could anyone kindly advise me what I am doing wrong and how I am best placed to solve this issue?
I have had similar issue on my Ubuntu 16.04. I made a research and in the end I found a resolution of the issue. Maybe my case solution will help somebody else.
Background: For security reasons I have non privileged user and group apache:apache (sudo groupadd apache | useradd -g apache apache). They are preset by directives (User apache; Group apache) in /etc/apache2/apache2.conf. This user apache:apache owns Apache2 main directory (sudo chown -R apache:apache /etc/apache2) and some other files, for example: sudo chown -R apache:apache/etc/phpmyadmin/htpasswd.setup
In this manual: http://docs.phpmyadmin.net/en/latest/setup.html - I found that...
Debian and Ubuntu have changed way how setup is enabled and disabled,
in a way that single command has to be executed for either of these.
To allow editing configuration invoke:
/usr/sbin/pma-configure
To block editing configuration invoke:
/usr/sbin/pma-secure
Note! In the content of the two files listed above we talk about /var/lib/phpmyadmin/config.inc.php instead of /etc/phpmyadmin/config/config.inc.php. It was the key.
In my case I was modified the content of these scripts (see below) and now I can use localhost/phpmyadmin/setup properly.
/usr/sbin/pma-configure:
#!/bin/sh
echo "Unsecuring phpMyAdmin installation..."
echo "Setup script can now write to the configuration file."
echo
echo "Do not forget to run /usr/sbin/pma-secure after configuring,"
echo "otherwise your installation might be at risk of attack."
sudo sudo chown -R apache:apache /var/lib/phpmyadmin/config.inc.php
chmod 0660 /var/lib/phpmyadmin/config.inc.php
/usr/sbin/pma-secure:
#!/bin/sh
echo "Securing phpMyAdmin installation..."
echo "Setup script won't be able to write configuration."
sudo sudo chown -R root:root /var/lib/phpmyadmin/config.inc.php
chmod 0640 /var/lib/phpmyadmin/config.inc.php
I was able to use phpMyAdmin in my ~/Sites directory and remove the warning by giving the config folder writable access as such:
chmod 756 ~/Sites/phpmyadmin/config
Does it work if you try setting up PHPMyAdmin in system root versus user root? On OSX that server web root should be under /Library/WebServer/Documents?
I used this guide when I set mine up, and it works fine, although I did not use Sites as my root.
http://www.dingendoen.com/osx-installs-configuration-examples/install-apache-mysql-php-on-osx-yosemite/
For local development, changing permissions worked for an OSX Sierra install:
sudo chown -R _www:_www ~/Sites/phpmyadmin

Setting up Laravel, getting PDO and permission problems

So on my linux AWS instance, I am trying to install a laravel application and am running into an awful amount of permission problems.
By default, when I cloned my project into var/www/, the owner was Root. I changed the owner to apache, and added ec2-user to apache. From what I've read, this seems correct.
From there, I tried to run php composer.phar install, which resulted in a permissions error unless I ran it sudo, and then the error was that "Class 'PDO' not found in /var/www/Mumble/app/config/database.php".
So from there, it looked like PDO wasn't installed, so I used yum to install it, which got me the typical laravel error log, but it is now saying "could not find driver". Looking at php info, pdo is configured for mysqli. Could that be my problem? Does anybody know of some places I could look for resources?
First things first, the latest version of laravel is 4.3, compatible with PHP >= 5.4 (Source: Laravel Installation).
The bad news is, the yum package of apache on AWS comes with PHP 5.3. Check your php version using php phpinfo() in your ssh console.
If you have the proper PHP version, you will have to make sure PHP is running underneath the user apache.
Go to /etc/php.ini and search for the parameter user=. Make sure it says user=apache, and group=apache.
If all of this checks out, your final step is to make sure that your /app/storage directories are on a 777 permission with owner being apache. Only laravel uses these for internal purposes, so it's alright.
I suspect you need to give the permission to access, is it accessible the /var/www directory?
if not try this,
sudo chmod -R 777 /var/www
for secure permission use 775 for the directories.
perhaps permission you need to set:
# Set group to www-data
sudo chgrp www-data /var/www
# Make it writable for the group
sudo chmod 775 /var/www
# Set GID to www-data for all sub-folders
sudo chmod g+s /var/www
# Add your username to www-data group
sudo usermod -a -G www-data username
# Finally change ownership to username
sudo chown username /var/www/
# Your account shouldn't have any more permission issues
Note: please read about the file permission before you go further .

Categories