I am struggling with an issue on LEMP stack. I cannot make my nginx user to create directory via php script.
My stack is RHEL 7.2 NGINX MariadB PHP
I installed the stack successfully and used following code for creating directory in index.php
<?php
echo(exec("whoami"));
mkdir("test",0777,true);
$error=error_get_last();
echo $error['mssage'];
?>
Output nginx mkdir(): Permission denied
Nginx excecutes PHP
via nginx
user.
Applied 'chown -R nginx: nginx <working folder>'
Applied 'chmod -R 0777 <working folder>
But above script gives same permission denied error.
My plan is to install Wordpress and import sites to this web server. But since permission is denied on working folder of nginx , Wordpress is not able to create new directories or move content from one folder to other.
Set SELINUX to disabled or permissive in /etc/selinux/config
If SELINUX has to be Enforcing, use semanage to change the context of the MySQL datadir and its contents.
shell> sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
then you have SELinux on.
Other possible tips:
http://forums.mysql.com/read.php?20,591661 (mysqld service won't start after server move)
http://forums.mysql.com/read.php?20,568810 (MySQL LOAD DATA LOCAL INFILE)
http://forums.mysql.com/read.php?52,275498 (Can't connect to MySQL server on '192.168.1.197' (13))
http://forums.mysql.com/read.php?52,252406 (PHP Remote connection Issue)
check your nginx.conf file from /etc/nginx
and get the nginx username using
sudo nano /etc/nginx/nginx.conf
For example if the username is www-data then use
sudo chown -R www-data /home/www/ || /foldername/
then go to your file directory
cd /home/www/
check the permissions in shell using
ls -l
Now check the mkdir()
in your development
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.