Wordpress Multisite: was working without needing to input FTP credentials and now needing FTP credentials and unable to add to Media Library

hi, I had things working: - i created a wildcard top-level domain for wordpress multisite and for each alias user of the top-level server, - i ssh'd as the alias user and installed wordpress ---> wordpress multisite was working without having to input the FTP credentials and could add new items to media library

  • then i did something and subsequently, in order to install a theme or plugin as the network admin, it requires FTP credentials.
  • furthermore, uploads to the media library returns some error message about being unable to upload the file (after seeming uploading)

Running Centos 7.3, FCGid is the PHP execution.

doing some research, I 1. > Virtualmin > Limits and Validation -> Validate Virtual Servers -> Fix Permissions ==> no luck 2. chown -R aliasowner:aliasowner /home/top-level-vs/public_html ==> no luck 3. chown -R apache:apache /home/top-level-vs/public_html/wp-content ==> can now add new media library items 4. i didn't do anything with permissions - they all seemed good at either 755 or 750

so changing the ownership to apache gave me back the ability to add media library items. but i still have FTP credentials problem.

any suggestions is appreciated to eliminate the FTP credentials requirement.

Status: 
Closed (fixed)

Comments

whoops - step 2 chown -R aliasowner:aliasowner is incorrect. when i looked at ownership, it seemed that all the wordpress multisite files had the correct ownership of the top-level-virtual-server-user.

the other top-level virtual servers that i installed wordpress on don't have the same problem (can add new plugins/themes without FTP credentials)

whoops again - i'm getting tired: step 1 is also incorrect. i didn't ssh as each alias user - just had to do one wordpress installation having ssh'd as the top-level virtual server user.

Virtualmin > Limits and Validation > Validate Virtual Servers ==>

MySQL database : MySQL login ... does not exist

not sure if this is relevant (i get the same message for several virtual servers but they don't have the FTP credentials problem)

i never see the top-level-virtual-server-user that's having the problem (harreson) running php

top
26087 server1+  20   0  663956  49260  39236 S   0.0  1.2   0:03.84 php70-cgi                                                                                
26354 eric      20   0  571360  63208  49416 S   0.0  1.5   0:20.92 php70-cgi                                                                                
26404 marn      20   0 1186168  79104  47976 S   0.0  1.9   0:04.22 php70-cgi                                                                                
26408 marn      20   0  562576  62300  48588 S   0.0  1.5   0:02.93 php70-cgi                                                                                
26427 marni     20   0  547808  55848  45360 S   0.0  1.3   0:05.88 php70-cgi                                                                                
26814 server1+  20   0  573540  44168  35548 S   0.0  1.1   0:03.65 php70-cgi                                                                                
26816 server1+  20   0  573868  46824  37928 S   0.0  1.1   0:04.07 php70-cgi                                                                                

i could remove the requirement for FTP credentials by putting the FTP credentials in the wp-config but then i run into the problem of ownership permission of the user not being apache.

so i can at least eliminate the FTP credentials by putting the FTP credentials in wp-config and be able to upload themes and plugins. but i have to change ownership from apache to the top-level-virtual-server-user.

so then only the unable to add new Media Library item is the problem.

if i chmod -R apache:apache just ../wp-content/uploads then i can add a new Media Library item

so, here's what i did to make things work: 1. bypass requirement for FTP credentials in Wordpress dashboard by putting FTP credentials in the wp-config.php file 2. be able to add new Media Library items by changing the ownership of /wp-content/uploads to apache

let me know if anyone has a more elegant solution

Howdy!

What PHP Execution Mode is it that you're using there?

By default, having things owned as the Virtual Server owner should work, but if the PHP Execution Mode is changed to mod_php, that can cause what you're describing there.

Also, now that I've written that I think I see you mentioned that you're using FCGID.

Are you by chance using a PHP version from a third party repository?

If so, that can cause that issue as well.

Is there any chance you could create a new file named test.php within the public_html folder of this domain, and in that file, place the following contents:

<?php phpinfo(); ?>

Then, could you share the URL to access that script?

That will help us identify what's going on. Thanks!

i don't think that i changed the php execution mode at any time.

yes, i have a third party repo for php7 and the rh-scl for 5.6.

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

php70 is running i believe (according to above top output) but the test.php gives the default centos 7 php 5.4

http://harreson.com/test.php

oh, php70 is running on the other virtual servers but it looks perhaps like this particular VS that's having the problem is running 5.4

when i look at > Virtualmin > Server Configuration > PHP Versions for this VS, it shows Default HTML directory set at 7.0.14

don't know why test.php shows 5.4

the other VS that are running PHP7.0 don't have the same problem - they don't require FTP credentials and they can write to the wordpress uploads directory and add a new media item.

Yeah it looks like it's running PHP version 5.4.x as mod_php, which does help us understand a bit about what's going on there.

If you go into System Settings -> Re-Check Config, does it detect any problems?

Also, if you look at Server Configuration -> Website Options for this particular domain, what is the PHP Execution Mode currently set to?

it doesn't look like Re-Check Config catches any significant errors (notes that ipv6 is not set):

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active ..
Your system has 4 GB of memory, which is at or above the Virtualmin recommended minimum of 256 MB.
BIND DNS server is installed, and the system is configured to use it.
Mail server Postfix is installed and configured.
Postfix can support per-domain outgoing IP addresses, but is not currently configured to do so. This can be setup in the Postfix Mailserver module.
Apache is installed.
The following PHP versions are available : 5.4.16 (/bin/php-cgi), 5.6.5 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.15 (/bin/php70-cgi)
Webalizer is installed.
Apache is configured to host SSL websites.
MySQL is installed and running.
ProFTPD is installed.
Logrotate is installed.
SpamAssassin and Procmail are installed and configured for use.
ClamAV is installed and assumed to be running.
Plugin DAV Login is installed OK.
Plugin AWstats reporting is installed OK.
Plugin Protected web directories is installed OK.
Using network interface venet0:0 for virtual IPs.
IPv6 addresses are available, using interface venet0:0.
Default IPv4 address for virtual servers is ...
Virtualmin could not work out the default IPv6 address for virtual servers on your system. You will need to update either the Network interface for virtual addresses or Default virtual server IP address fields on the module configuration page.
Default IP address is set to ..., which matches the detected external address.
Both user and group quotas are enabled for home and email directories.
All commands needed to create and restore backups are installed.
The selected package management and update systems are installed OK.
.. your system is ready for use by Virtualmin.

Website Options show FCGid.

Wonder why it doesn't pick up php70 and why it doesn't execute FCGid like the other VS's?

My suspicion is that the remi repo caused a configuration issue (we've seen a lot of problems with third party repositories), but that's just a guess, we can do some testing on that.

What is the output of this command:

find /etc/httpd | xargs grep -i sethandler
[root@server ~]# find /etc/httpd | xargs grep -i sethandler
grep: /etc/httpd: Is a directory
grep: /etc/httpd/logs: Is a directory
grep: /etc/httpd/run: Is a directory
grep: /etc/httpd/modules: Is a directory
grep: /etc/httpd/conf.d: Is a directory
/etc/httpd/conf.d/php.conf:#    SetHandler application/x-httpd-php
/etc/httpd/conf.d/php.conf:#    SetHandler application/x-httpd-php-source
grep: /etc/httpd/conf: Is a directory
grep: /etc/httpd/conf.modules.d: Is a directory
[root@server ~]#

if the remi repo caused a config issue for this virtual server, how come it didn't for the other virtual servers that are properly running php70?

Are you perhaps able to add a new test domain running PHP 5.4, and put a similar test.php script within it that we can use for comparison?

ok, when the dns propagation has settled, can get you the url

the loaded configuration file on the VS that's being set to mod_php is /etc/php.ini rather than /home/harreson/etc/php5/php.ini

If a domain is using mod_php rather than FCGID/CGI, it would indeed read the php.ini file from /etc.

What I'm seeing though is that this new domain you created that uses PHP 5.4 is correctly using FCGID/CGI, and not mod_php.

The first domain, the one experiencing the problem, is incorrectly using mod_php.

That could indicate a config problem in the Apache config.

Is there anything custom added to the Apache config that you need?

As one option would be to disable the Apache Website feature in Edit Virtual Server -> Enabled Features, and then re-enable it. That will cause it to re-create the config, which may resolve the issue.

i don't recall customizing the Apache config but it's been a while ago, so i might have forgotten.

regarding disabling and then re-enabling Apache, the VS that has the mod_php problem has 7 alias servers under it (wildcard domain). when i try to disable Apache, i can't because the other VS are using it.

this is the message i got when i attempt to disable one of the alias VS:

Are you sure you want to save the domain bluelotusmusic.org? The following features have been selected for deletion :
Apache website - All Apache directives in the virtual host will be removed.

does that seem okay? disable Apache for the 7 alias VS's and then for the main VS? and then re-enable them again.

Beautiful! That did the trick!

I disabled Apache Website for all the alias VS and then the top-level VS. Then re-enabled Apache Website and now test.php shows the correct FastCGI and PHP70. --> chown -R user:user uploads --> can now add Media Library items normally --> can now add Plugins and Themes without requiring FTP credentials

then re-enable Apache Website for all the alias VS.

Thank you! :-)

That's fantastic, I'm glad to hear that worked!

It sounds like something went awry with the Apache config, and re-writing it with a default config fixed things up.

Feel free to let us know if you have any additional questions!

Status: Active » Closed (fixed)