I’ve been trying to install Wordpress with limited success. Apache works fine, Mariadb works fine. Wordpress installs fine but I can’t add or delete plugins or themes. I’ve disabled DISALLOW_FILE_MODS in wp-config.php, changed file ownership and group to apache for /usr/share/wordpress and its contents, added apache to my group and me to the apache group, I’ve made sure curl is activated in php.ini but still I cannot delete plugins (except from the console) and get errors on the add new plugins and themes page about establishing a secure connection with wordpress. I’ve run out of things to try - any ideas would be more than welcome!
Could be an Selinux issue, I’m pasting a snipped that I found online, and I think it makes a lot sense
Recursively change the ownership of the /var/www/html directory to apache.
$ sudo chown -R apache: /var/www/html
You must grant SELinux write permissions to the /var/www/html/ directory.
$ sudo semanage fcontext --add --seuser system_u \
--type httpd_sys_rw_content_t '/var/www/html(/.*)?'
Recursively restore the default SELinux security contexts of the /var/www/htmldirectory.
$ sudo restorecon -RFv /var/www/html
Enable httpd_can_network_connectSELinux boolean value. When enabled, this boolean allows HTTP scripts and modules from initiating a connection to a network or remote port.
$ sudo setsebool -P httpd_can_network_connect on
Finally, double-check your directory permissions and SELinux contexts. This is what it should look like.
$ sudo ls -alhZ /var/www/html/
total 216K
drwxr-xr-x. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 564 Sep 26 19:09 .
drwxr-xr-x. 1 root root system_u:object_r:httpd_sys_content_t:s0 22 Sep 13 08:11 ..
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 0 Sep 26 18:59 .htaccess
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 405 Feb 6 2020 index.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 20K Jan 1 2023 license.txt
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 20 Sep 25 21:52 phpinfo.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 7.3K Jul 5 23:11 readme.html
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 7.1K May 13 03:05 wp-activate.php
drwxr-xr-x. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 2.8K Aug 29 19:44 wp-admin
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 351 Feb 6 2020 wp-blog-header.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 2.3K Jun 14 19:41 wp-comments-post.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 3.2K Sep 26 19:03 wp-config.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 3.0K Feb 23 2023 wp-config-sample.php
drwxr-xr-x. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 58 Sep 26 18:59 wp-content
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 5.6K May 31 00:18 wp-cron.php
drwxr-xr-x. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 9.6K Aug 29 19:44 wp-includes
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 2.5K Nov 27 2022 wp-links-opml.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 3.9K Jul 16 17:46 wp-load.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 49K Jul 17 18:48 wp-login.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 8.4K Jun 22 20:06 wp-mail.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 26K Jul 25 12:05 wp-settings.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 34K Jun 19 23:57 wp-signup.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 4.8K Jun 22 20:06 wp-trackback.php
-rw-r--r--. 1 apache apache system_u:object_r:httpd_sys_rw_content_t:s0 3.2K Jun 14 19:41 xmlrpc.php
Hi Flo
Many thanks for the suggestion - I executed these commands all without errors but Wordpress is still not able to delete or install plugins and themes. Strangely I’ve always been able to upload media and delete media.
Peter
Limited progress - if I set selinux into permissive mode I can delete plugins but still unable to establish secure connections with wordpress.org.
Set up WordPress following this method:
WordPress + LAMP on Fedora - #4 by vgaetera
Then allow customization like this:
sudo sed -i -e "/DISALLOW_FILE_MODS/s/true/false/" \
/etc/wordpress/wp-config.php
sudo semanage boolean -m -1 httpd_can_network_connect
sudo semanage fcontext -a -t httpd_sys_rw_content_t \
"/usr/share/wordpress/wp-content(/.*)?"
sudo restorecon -F -R -T 0 /usr/share/wordpress/wp-content
I tested this setup from scratch in a Fedora 39 VM.
I believe by default Wordpress will not touch it’s file system itself. You have to use other methods to do so, like (s)FTP, shell/console, etc.
I have this defined in wp-config.php file so I can run updates and such.
* Define File System Access */
define('FS_METHOD', 'direct');
/* That's all, stop editing! Happy blogging. */
SSL connections seem like something entirely different.
Have you tested that you can connect properly to the Wordpress API?
Issuing on the same systems as Wordpress is setup;
$ curl -v https://api.wordpress.org
This will determine if curl and https is functioning properly.
If that is working properly make sure that Wordpress knows about curl.
You can determine this by going to Site Health → Info and dropping down the Server tab and it should list the cURL version.
Hi Geoff - I think you may have hit on the problem. Curl to the wordpress api just times out from the console. I’ve tried ‘sudo setsebool -P httpd_can_network_connect 1’ but that doesn’t seem to have any effect. The site health tool just reports curl error 28 as expected so I guess curl is installed. It works to api.google.com so it looks like something is different with the wordpress api. Peter
Post the output:
nslookup api.wordpress.org
ping -c 3 api.wordpress.org
tracepath -n api.wordpress.org
curl -v https://api.wordpress.org/
Hi Thank you for your help! The results of running these commands is as follows:
nslookup api.wordpress.org
Server: 127.0.0.53
Address: 127.0.0.53#53
Name: api.wordpress.org
Address: 66.155.40.202
ping -c 3 api.wordpress.org
PING api.wordpress.org (66.155.40.202) 56(84) bytes of data.
— api.wordpress.org ping statistics —
3 packets transmitted, 0 received, 100% packet loss, time 2025ms
tracepath -n api.wordpress.org
?: [LOCALHOST] pmtu 1500
1: 192.168.40.1 6.841ms
1: 192.168.40.1 7.640ms
2: 192.168.40.1 3.804ms pmtu 1462
2: 100.64.24.4 9.251ms
3: 86.63.6.152 9.587ms
4: 86.63.13.89 9.226ms
5: 86.63.13.88 13.951ms
6: 86.63.13.69 9.857ms
7: 93.93.133.3 10.143ms
8: 93.93.133.7 8.944ms
9: no reply
10: 62.115.126.38 10.023ms asymm 13
11: 62.115.113.20 86.748ms asymm 16
12: 62.115.141.244 82.929ms asymm 15
13: 62.115.114.86 226.958ms asymm 12
14: 80.239.194.245 2253.566ms asymm 12
15: no reply
16: no reply
17: no reply
18: no reply
19: no reply
20: no reply
21: no reply
22: no reply
23: no reply
24: no reply
25: no reply
26: no reply
27: no reply
curl -v https://api.wordpress.org/
- processing: https://api.wordpress.org/
- Trying 66.155.40.202:443…
This looks like a problem with your resolver since the correct reply is different:
https://www.nslookup.io/domains/api.wordpress.org/dns-records/
Also check this to isolate the issue:
nslookup api.wordpress.org 8.8.8.8
grep -e wordpress /etc/hosts
resolvectl flush-caches
resolvectl query api.wordpress.org --no-pager
Many thanks - that was the problem - the wrong IP address for api.wordpress.org in /etc/hosts (not sure where the value came from - I guess I copied it from some install instructions somewhere). Replaced it with 198.143.164.251 and all was well. Thank you again - many days of frustration at an end.
This is what DNS is for – to keep a user from having an incorrect address stored locally.
I would suggest that you remove all ip addresses for internet hosts from your /etc/hosts file and allow dns to do its job in that area. For me I only use /etc/hosts for systems on my LAN that do not have dns supported host name & address pairs.
Thanks Jeff - good advice