我收到此错误不知道原因SQLSTATE[HY000] [2002] Permission denied
,这里是我尝试上传我的文件example.com
。
This happens because selinux avoids db connections from the httpd server to the remote db server. To solve it you need to access your server through ssh or just open a console if you have pretencial access and do the following:
You must check in the SELinux if port 80 is managed in. You can check it by typing # semanage port -l | grep http_port_t
# semanage port -l | grep http_port_t
for a list and check:
http_port_t tcp 443, 488, 8008, 8009, 8443, 9000
If you need to add the required port, just type:
# semanage port -a -t http_port_t -p tcp 80
Type the command to ckeck once again:
# semanage port -l | grep http_port_t
.
http_port_t tcp 80, 443, 488, 8008, 8009, 8443, 9000
Then you should notify SELinux you want to allow network connections from the httpd server to the db remote server, setting the boolean variables that set it:
# service httpd stop
# setsebool httpd_can_network_connect 1
# setsebool httpd_can_network_connect_db 1
# service httpd start
Now your httpd service should be capable to get data from the db server.
I hope that can be useful for the gang that searches solve errors like this.
进入 .env 文件并将 DB_HOST=127.0.0.1 更改为 DB_HOST=localhost
May I am late to answer this question but what worked for me are the commands. I ran into same issue and then I ran the following commands.
Provide permissions:
chmod -R 777 .
(though not recommended)
Run setup upgrade command
php bin/magento setup:ugrade
and finally compile command
php bin magento setup:di:compile
也许你需要像这样关闭你的selinux
setenforce 0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.