I have a centOS -based virtual machine on digital ocean.
It is running NGINX HTTP sever.
I configured it to use multi domains, and set up SSL.
One of my domains runs a Wordpress application.
I migrated the WordPress files from my godaddy hosting.
Everything works great except when I try to upgrade the wordpress core ( updating and installing plugins works just fine).
When I try to upgrade WordPress to version 5.4.2 I get a permissions error (as shown in attachment photo):
Permission denied in /var/www/mydomain.com/wordpress/wp-admin/includes/class-wp-filesystem-direct.php on line 281
wordpress core upgrade file permissions error display
I tried doing the following just to diagnose the issue... I have the directory full access to nginx user:
chmod -R 777 /var/www/
chown nginx:nginx /var/www/
This did not work
I made sure php user is nginx by outputting echo exec('whoami'); on the page.
I am completely dumbfounded.
Does anyone know what the problem may be?
As a last resort I manually upgraded my wordpress version using FTP, but I'm concerned that I never figured out the root cause of this issue and it will spring back up again opening up a can of worms.
CentOS includes a mandatory access control (MAC) security mechanism in its Linux kernel by the name of SELinux. According to a support forum thread on Wordpress.org, this mechanism sometimes can cause issues that manifest with this error.
SSH into your server and use the following command to change the SELinux "context" for the entire /var/www/mydomain.com folder:
chcon -R –-type httpd_sys_rw_content_t /var/www/mydomain.com/
The last post in the above-linked thread indicated that this change of context alleviated the errors you're seeing.
As an aside, for your system's security, ensure you change your file permissions back to their defaults.
Related
I'm installing WordPress through Xampp. I used to work with MAMP and it basically works the same way.
Normally I do everything manually as in copying the files and installing the database.
When loaded the famous "can't establish database connection" kicks in.
Now I thought this might have something to do with the fact that MAMP and Xampp have some minor differences. So I decided to use the WordPress installer.
After placing the files in XAMPP->xamppfiles->htdocs->customFolder I ran the installer.
Database is created in phpMyAdmin and I expect the installer to finish after adding the credentials. But nooooo. For some reason this sob keeps denying the wp-config.php to be created.
I quadruple checked every credential of the database. Have no idea on why step2 fails to install WordPress.
So I might think this is an port issue. I have also installed MAMP and it is running on port:8080. After setting xampp to port:8080 it gives me an error saying it can't bind to that port. Changed it to port:8666 but the same problem occurs.
Any thoughts or extra info?
---- UPDATE ---
So I created the wp-config.php manually and got these extra error messages.
All files in the htaccess folder have now file permission 777. This is merely for testing and would never happen in a live environment.
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: YES) in /Applications/XAMPP/xamppfiles/htdocs/testing/wp-includes/wp-db.php on line 1531
There must be file permission issue, You must grand 777 rites to create wp-config file. chmod 775 wp-content/upload
Also note
All files should be owned by the actual user's account, not the user account used for the httpd process.
Group owneraship is irrelevant, unless there's specific group requirements for the web-server process permissions checking. This is not usually the case.
All directories should be 755 or 750.
All files should be 644 or 640. Exception: wp-config.php should be 440 or 400 to prevent other users on the server from reading it.
No directories should ever be given 777, even upload directories. Since the php process is running as the owner of the files, it gets the owners permissions and can write to even a 755 directory.
It sounds like a folder/file permissions issue rather than a port issue.
This question should help you solve the permissions on your xampp/xamppfiles/htdocs/customfolder
XAMPP permissions on Mac OS X?
When WordPress gives that error it's most often because it can't create the wp-config.php file due to insufficient write permissions.
I found the solution.
MAMP uses a user root and password root.
XAMPP in contrast to MAMP doesn't.
The user name is root but the password is empty.....
I faced this issue attempting to install within XAMPP and what solved it for me was to run XAMPP as administrator. This reflects other answers referring to permissions.
The other thing that can be an issue is XAMPP timing out on the install. One can modify their php.ini file within xampp to increase the max execution time. As they say "I hope this helps"
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 90
I had same issue using XAMPP 8.1.12 on WINDOWS 10;
Try installing an older version, in my case XAMPP 8.0.25 fixed the problem.
I am struggling to get a default Symfony application from PhpStorm 2017.2.1 which works locally (Windows), but seemingly will not deploy to a remote server (Linux) and run.
Windows setup:
Windows 10, PHPstorm 2017.2.1, php5.6, symfony 3.3.9, default symfony app (namely, I installed Symfony and am using their default app -- no personally written code). This works, when run with "php bin/console server:run" from a command prompt, and "localhost:8000" in a broswer, generating "Welcome to Symfony 3.3.9" "Your application is now ready. You can start working...."
I believe nothing is wrong here.
Remote Linux Setup:
Shared hosting, bash 4.2.46, I don't have root access, everything supposed to go in the public_html directory. A simple one line phpinfo.php file containing only
"<?php phpinfo(); ?>"
placed in that directory will render when accessing
'www.example.com/phpinfo.php'
the usual phpinfo() dump, thus I believe the PHP server is operational. I'm not sure if there is some configuration error with apache that is causing problems on the server for something more complicated like a default symfony application, or whether the issue is my PHPstorm configuration.
PHPstorm deploy configuration:
SFTP to www.example.com (test connection works, files will upload).
root path: /home/example/public_html
username and password work, auth type=password.
Web server root URL=sftp://ftp.example.com,
and it does allow files to be browsed on the server.
PHPstorm mappings:
local path=c:\blah (works, since files upload)
deployment path on server=/
web path on server=/web
I have only one mapping.
PHPstorm excluded paths:
empty
Upload and Prepare:
Cleared Linux public_html directory of everything including . files. Uploaded the local app to remote Linux server. Logged on via SSH and chmod everything public_html and under to 777 (yes, horrible security practice, but this is a test, and there is nothing else on the domain at the moment, and this will rid me of any security protection issues for test).
Test results, in order:
Test1: Browsing to www.example.com results in
**
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
**
Test 2: Browsing to www.example.com/web results in
**Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
**
Logs: Performing
ls -alsgR | grep log
produces nothing that appears to be a server logfile.
What process do I follow to get the default application to work?
This appears to have been a web server issue.
My web hosting provider would not allow me to see the httpd.conf file for this shared hosting situation, but did run test cases for me, and for whatever the configuration is, determined that
1. All files within public_html/ need to be have permissions 644 (777 not good enough)
2. All directories within public_html/ need to have permissions 755 (777 not good enough).
The two bash commands to do this, run after cd to the public_html/ folder are
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
Very frustrating problem solved w.r.t. the server.
Although I haven't fully checked it out, PHPstorm does appear to have,
under file/settings/Build/Deployment/Options, an ability to override default
protections for files and directories, so I believe it likely that any
problems occurring with PHPstorm can be fixed by configuration of those
overrides.
A client informed me that any time he tries to update a plugin, he gets an error:
To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.
I don't have FTPd setup on the server, but this seems like a basic permissions issue, right? I've never had to use FTP credentials to update any other WordPress installations.
Well, I did some reading and started messing with permissions and long story short, out of frustration, I eventually made everything writeable by everybody:
sudo chmod -R 777 src
But I'm still getting the same error. So it has to be some type of configuration issue, right?
I ran a few find . -exec grep commands to determine if there is a hard-coded document root (like in Joomla), but I came up empty handed.
Do I really have to install FTPd to be able to update WordPress from the admin interface?
Is there a config file somewhere that specifies the document root location?
Is there some other configuration option that I'm missing here?
Or maybe it's something in the database? The site was originally on a shared host but was moved to a DigitalOcean VPS a month or so ago.
I was able to force WordPress to use the filesystem instead of FTP by setting the FS_METHOD constant in wp-config.php:
define('FS_METHOD', 'direct');
More details can be found in the WordPress codex.
Try running chown -R apache:apache on the directory. I recall running in to an issue with ownership even when permissions were OK. You may have more success posting this on ServerFault as well.
Using MariaDB, Apache, PHP 5.4.x, RHEL 7
How do I allow configuration.php to be written to?
Installed Joomla several times, always ending up with the configuration.php file not writable. I proceeded, copied the config content and created a new php file, placed it where Joomla lives, opened up the permissions, changed to apache:apache, still nothing. I've referenced several articles, notably this one:
Installing Joomla 3 Error: Your configuration file or directory is not writable
I have also tried creating an empty configuration.php file and placing it in the joomla root, opening up permissions - didnt work.
My current state of installation is configuration.php file in place, but unable to remove the installation directory via the web installer (assuming because I shoehorned the config file into place and still not being writable).
I've tried several permissions setups then attempting to remove the install directory without success. Manually removing the install directory via rm -r only yields a totally inaccessible site forcing me to wipe my joomla files, databases, and install again. Thanks in advance.
The first thing I would do is check what user php runs at on your server, and compare this with ownership of your site files.
Create user.php file at the root of your domain with
<?php echo exec('whoami'); ?>
then open that file with your broser. This will give you the name of the user that php runs as on your server. It may be apache but it may not.
Compare this user with the ownership of config.php and your site installation as a whole.
If you upload a new Joomla site via SFTP and follow the standard browser instal steps, permissions shouldn't be a problem. If you are say uploading a zip file and using a terminal connection and SSH, make sure your SSH connection is the same user as the php user on your server.
Good luck!
Working with my server guy - found out that several sebool settings were keeping Apache from doing what it needed to do. Going one step further, we identified that sebool commands needed to be ran to allow httpd_can_sendmail in order to use the Sendmail feature. Hope this helps someone out there.
The command that seemed to do the trick was sudo chcon -R -t httpd_sys_rw_content_t /var/www/html
In our case, problem was with CentOS permissions. So if Joomla is installed on CentOS powered server, you need to change config file (/etc/selinux/config) to look like this:
[root#host2a ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
Actually, you only set SELINUX to permissive.
Hope this helps.
p.s. Solution works for RedHat too.
Hie,
I have installed a new httpd server and loaded my web application on it which is designed to upload files on the server. Also it creates new directories and files inside the web directory of the application. But i am unable to use these features because it gives me a permission denied error. I searched onto the web and got the clue that i require to enable ftp login through my PHP script. I changed the ownership and permissions but it is still not working. Can please someone explain the configuration required in simple steps to enable these features. I am using CentOs-6. It will be highly appreciated. Sorry for the miss formed question.
Configurations I tried out:
Create a Linux user and group named webuser. Give it permissions of
the directory of my web applications. Install Vsftpd and allow webuser
to login. Set webuser FTP root directory same as my Web Application
directory (i.e /var/www/mysite)
My httpd user is apache.
I was doing everything right. The only problem was CentOS SELinux. It was not allowing apache to write files into the web directory.
Using the command "setenforce 0" , i closed it down and everything started working.
Later, I added an exception into my SELinux policies to fix issues.