Wednesday, June 27, 2018

Tuesday, June 26, 2018

PHP / CentOS 7Connect DATABASE Error TYPE: 2002: Permission denied


9
down voteaccepted

I had the same issue after getting a new CentOS 7 box, running SELinux. I could connect to my remote MySQL DB server from the command line, but Drupal (and test PHP scripts) could not.

The issue turned out to be the SELinux security policies.

By default, the policy httpd_can_network_connect_db is disabled (meaning that your web server cannot contact a remote DB.)

Check this via:

getsebool -a | grep httpd

If httpd_can_network_connect_db is Off, enable it via:

setsebool -P httpd_can_network_connect_db 1

(The -P flag makes the change permanent, so the setting survives a reboot.)



Nginx php html permission denied

After searching , I found it.It's all deals with SELINUX which is a security feature. when using ls -Z

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_content_t:s0 www

change this to

drwxrwxrwx. ec2-user root system_u:object_r:httpd_sys_rw_content_t:s0 www

using cmd

chcon -R -t httpd_sys_rw_content_t /var/www


Centos 7 reset root/ any user lost password / lockout due to cant remember password

1. Need to be in front of the terminal. (Physically if not vm). 2. Reboot the server 3. Press 'e' in the GRUB2 boot screen. 3. bunch...