Php ошибка permission denied in

I am trying to create a directory with PHP mkdir function but I get an error as follows: Warning: mkdir() [function.mkdir]: Permission denied in .... How to settle down the problem?

asked Mar 9, 2011 at 12:57

folos's user avatar

3

I know this is an old thread, but it needs a better answer. You shouldn’t need to set the permissions to 777, that is a security problem as it gives read and write access to the world. It may be that your apache user does not have read/write permissions on the directory.

Here’s what you do in Ubuntu

  1. Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user

    sudo chown -R www-data:www-data /path/to/webserver/www

  2. Next enabled all members of the www-data group to read and write files

    sudo chmod -R g+rw /path/to/webserver/www

The php mkdir() function should now work without returning errors

AnasSafi's user avatar

AnasSafi

5,0091 gold badge34 silver badges33 bronze badges

answered Feb 10, 2014 at 19:00

simpleengine's user avatar

simpleenginesimpleengine

2,7161 gold badge17 silver badges15 bronze badges

12

Late answer for people who find this via google in the future.
I ran into the same problem.

NOTE: I AM ON MAC OSX LION

What happens is that apache is being run as the user «_www» and doesn’t have permissions to edit any files. You’ll notice NO filesystem functions work via php.

How to fix:

Open a finder window and from the menu bar, choose Go > Go To Folder > /private/etc/apache2

now open httpd.conf

find:

User _www 
Group _www

change the username:

User <YOUR LOGIN USERNAME>

Now restart apache by running this form terminal:

sudo apachectl -k restart

If it still doesn’t work,
I happen to do the following before I did the above. Could be related.

Open terminal and run the following commands:
(note, my webserver files are located at /Library/WebServer/www. Change according to your website location)

sudo chmod 775 /Library/WebServer/www
sudo chmod 775 /Library/WebServer/www/*

answered Jun 25, 2012 at 15:34

Chris Ingis's user avatar

Chris IngisChris Ingis

6965 silver badges8 bronze badges

2

Don’t set permissions to 777 when using mkdir in PHP

Link only answers are not considered good practice on StackOverflow, but the advice that is given here should generally NOT be followed up.

I would like to revert to this great answer on a similar question. I quote:

Please stop suggesting to use 777. You’re making your file writeable by everyone, which pretty much means you lose all security that the permission system was designed for. If you suggest this, think about the consequences it may have on a poorly configured webserver: it would become incredibly easy to «hack» the website, by overwriting the files. So, don’t.

Community's user avatar

answered Dec 23, 2016 at 13:12

Wilt's user avatar

WiltWilt

41k12 gold badges149 silver badges202 bronze badges

I know that this thread is old, but perhaps this will help someone, one day.

The problem why PHP says «Permission denied» for mkdir() — wrong url path. So, to fix it, all you need it’s to obtain correct path. I did it this way:

<?php

$root = $_SERVER["DOCUMENT_ROOT"];
$dir = $root . '/somefolder/';

if( !file_exists($dir) ) {
    mkdir($dir, 0755, true);
}

?>

answered Feb 15, 2016 at 9:47

Boris's user avatar

BorisBoris

5315 silver badges12 bronze badges

1

Fix the permissions of the directory you try to create a directory in.

answered Mar 9, 2011 at 12:58

Erik's user avatar

ErikErik

88.2k13 gold badges198 silver badges189 bronze badges

1

You need to have file system permission to create the directory.

Example: In Ubuntu 10.04 apache (php) runs as user: www-data in group: www-data

Meaning the user www-data needs access to create the directory.

You can try this yourself by using: ‘su www-data’ to become the www-data user.

As a quick fix, you can do: sudo chmod 777 my_parent_dir

answered Mar 9, 2011 at 13:01

Jon Skarpeteig's user avatar

Jon SkarpeteigJon Skarpeteig

4,1087 gold badges34 silver badges53 bronze badges

3

I have this problem just now, my best solution I can give to you right now (despite that you didn’t include any of your code) would be:

  1. Check how you name your destination folder, eg: new_folder (sometimes this can cause error for permission as most hosts don’t allow names using underscore, dash, etc to be created at run time). It worked for me.
  2. If you were using recursive command to create sub-folders don’t forget to put 0755 (remember to include 0 at the start) to the mkdir command, eg:

    if(!file_exists($output)){
        if (!mkdir($output, 0755, true)) {//0755
            die('Failed to create folders...');
        }
    
    }
    

This is also worked for me just now.

answered Jan 19, 2013 at 13:54

arungisyadi's user avatar

arungisyadiarungisyadi

3732 silver badges8 bronze badges

2

This error occurs if you are using the wrong path.

For e.g:

I’m using ubuntu system and my project folder name is ‘myproject’

Suppose I have myproject/public/report directory exist and want to create a new folder called orders

Then I need a whole path where my project exists. You can get the path by PWD command

So my root path will be = ‘/home/htdocs/myproject/’

$dir = ‘/home/htdocs/myproject/public/report/Orders’;

if (!is_dir($dir)) {
   mkdir($dir, 0775, true);
}

It will work for you !! Enjoy !!

answered May 12, 2020 at 9:05

Umang Soni's user avatar

Umang SoniUmang Soni

5115 silver badges9 bronze badges

What the other thing you can do is go to: /etc/sudoers

There add the following line which gives the permission to that user
www-data ALL=(ALL:ALL) ALL
Why www-data ? this is because apache is running by this user name.

Incase if your user is different then try
username ALL=(ALL:ALL) ALL

This worked for me.

answered Oct 30, 2012 at 5:50

maxwells's user avatar

maxwellsmaxwells

5393 silver badges15 bronze badges

3

Since you are on a mac, you could add yourself to the _www (the apache user group) group on your mac:

sudo dseditgroup -o edit -a $USER -t user _www

and add _www user to the wheel group which seems to be what the mac creates files as:

sudo dseditgroup -o edit -a _www -t user wheel

answered Mar 25, 2014 at 19:56

SeanJA's user avatar

SeanJASeanJA

10.2k5 gold badges32 silver badges42 bronze badges

If you’r using LINUX, first let’s check apache’s user, since in some distros it can be different:

egrep -i '^user|^group' /etc/httpd/conf/httpd.conf 

Let’s say the result is «http». Do the folowwing, just remember change path_to_folder to folders path:

chown -R http:http path_to_folder
chmod -R g+rw path_to_folder

answered Mar 18, 2018 at 13:27

Marcelo Agimóvel's user avatar

Marcelo AgimóvelMarcelo Agimóvel

1,6582 gold badges20 silver badges25 bronze badges

check if its not a issue with umask

if (!function_exists('mkdir_r')) {
    /**
     * create directory recursively
     * @param $dirName
     * @param int $rights
     * @param string $dir_separator
     * @return bool
     */
    function mkdir_r($dirName, $rights = 0744, $dir_separator = DIRECTORY_SEPARATOR) {
        $dirs = explode($dir_separator, $dirName);
        $dir = '';
        $created = false;
        foreach ($dirs as $part) {
            $dir .= $part . $dir_separator;
            if (!is_dir($dir) && strlen($dir) > 0) {
                $created = mkdir($dir, $rights);
            }
        }
        return $created;
    }
}

if (!function_exists('ensure_dir')) {
    /**
     * ensure directory exist if not create 
     * @param $dir_path
     * @param int $mode
     * @param bool $use_mask
     * @param int $mask
     * @return bool
     */
    function ensure_dir($dir_path, $mode = 0744, $use_mask = true, $mask = 0002) {
        // set mask 
        $old_mask = $use_mask && $mask != null
            ? umask($mask)
            : null;
        try {
            return is_dir($dir_path) || mkdir_r($dir_path, $mode);
        } finally {
            if ($use_mask && $old_mask != null) {
                // restore original
                umask($old_mask);
            }
        }
    }
}

answered Apr 15, 2018 at 12:50

ceph3us's user avatar

ceph3usceph3us

7,2373 gold badges36 silver badges42 bronze badges

After you install the ftp server with sudo apt-get install vsftpd you will have to configure it. To enable write access you have to edit the /etc/vsftpd.conf file and uncomment the

#write_enable=YES

line, so it should read

write_enable=YES

Save the file and restart vsftpd with sudo service vsftpd restart.

For other configuration options consult this documentation or man vsftpd.conf

answered Oct 1, 2018 at 20:47

mySun's user avatar

mySunmySun

1,5325 gold badges32 silver badges52 bronze badges

I did all I could to fix this issue and none of the above answers helped.
Finally restarting apache did the trick

sudo service apache2 restart

My system is running Ubuntu 20 with Samba sharing the directories that had the permission issue.

answered Feb 2, 2022 at 6:12

jdrake's user avatar

jdrakejdrake

3334 silver badges17 bronze badges

Try the following on ubuntu 22.04

sudo chown -R ubuntu:ubuntu /var/www/html
sudo chmod -R 755 /var/www/html

answered Oct 17, 2022 at 7:21

DragonFire's user avatar

DragonFireDragonFire

3,6442 gold badges36 silver badges50 bronze badges

В этой ошибке указано, что php скрипт, расположенный тут:
/var/www/www-root/data/www/xndaasdqfjqwm7b.xn--p1ai/vendor/yiisoft/yii2/helpers/BaseFileHelper.php
видимо пытается создать папку ( mkdir() line 488)

Так какой именно папке вы права задаете?
Посмотрите в коде/логах, какую папку он пытается создать и где и вот там уже и назначайте права.

подозреваю что проблема в овнере

А не-латинское имя папки Вас не смущает? Есть системы, которые очень нервно относятся к именам

в 99% случаях это не понимание всей системы прав линукс
В вашем случае это скорее всего владельцы файлов и группы
По мима 777 так же у файла есть владелец и группа
1. отвечает что этот юзер попадет в первую семерку
вторая за вторую
3 соотваетственно все левые
права на файлы выгледят реально так
index.php root:root 777
В вашем случае вы оперируете самой маской 777
но не забываете что вы даже не тот пользователь.
А апачь может например не иметь прав создавать в этой директории.
Так что сделайте ls - l
посмотрите права
Далее поменяйте владельца на правильного
так

chown -R bitrix:bitrix /home/bitrix/ext_www/site.ru

В вашем случае скорее всего этоwww-data:www-dataили apache:apache
-R -рекурсивно
Команда потенциально опасная и пишите ее всегда с полным путем а не «.» уж больно шустро она меняет права.
ДАлее если все решилось то не работайте от рута а от того полльзователя от кооторого работает сайт.
Ну или меняйте права постоянно.
А вот если не заработало то нужно знать еще о нескольких моментах
Есть еще дополнительные права и даже утилиты ограничивающие скажем специфические вещи, например разрешающие только дописывать. Или запрещающие удалять что-либо в этом каталоге но разрешающие создавать . это отдельная история.
В любом случае с вас ls -la текущей директории и такой же список с работоающей валидно
Так же есть специфические моды представления php которые запрещяют все что кроме 644 755, вплоть до 777 ;).

А опечатки нет?
Права 777 или 0777?
Должны быть с нулём, в восьмеричной системе )

Еще, как вариант, может быть, на родительской папке висят какие-то ACL? Что говорит такая команда:
getfacl <имя-папки-в-которой-Вы-создаёте-подпапку>?

Ok, I figured this out.

The main httpd log directory, /var/log/httpd, and all the logs in that directory are owned by root. But, those are the logs that httpd itself writes.

Apparently, the files read/written by PHP are under the auspices of the apache User and Group, as specified in /etc/httpd/conf/httpd.conf

User apache
Group apache

I chown‘ed the log file and directory that the log file is in, /var/log/httpd/shib_session_logs, to apache:apache. That didn’t quite solve the problem though, because the directory that hold the PHP log files, /var/log/httpd/shib_session_logs, was itself in a directory, /var/log/httpd, that had root only access. So, I was still getting permission denied. When I relaxed read permissions on that directory, everything started working.

I’ll be discussing this with some folks here, and ultimately, we’ll probably move the PHP log directory to another location, outside of /var/log/httpd, and reset the permissions on /var/log/httpd to 700.

Anyhow, it works!

Это скрипт:
<?

mkdir(‘/var/www/html/test’,’0111′);
system(«whoami»);

?>

phpinfo()
PHP Version => 5.2.6

System => Linux localhost.localdomain 2.6.27.5-117.fc10.i686 #1 SMP Tue Nov 18 12:19:59 EST 2008 i686
Build Date => Sep 13 2008 11:11:43
Configure Command => ‘./configure’ ‘—build=i386-redhat-linux-gnu’ ‘—host=i386-redhat-linux-gnu’ ‘—target=i386-redhat-linux-gnu’ ‘—program-prefix=’ ‘—prefix=/usr’ ‘—exec-prefix=/usr’ ‘—bindir=/usr/bin’ ‘—sbindir=/usr/sbin’ ‘—sysconfdir=/etc’ ‘—datadir=/usr/share’ ‘—includedir=/usr/include’ ‘—libdir=/usr/lib’ ‘—libexecdir=/usr/libexec’ ‘—localstatedir=/var’ ‘—sharedstatedir=/usr/com’ ‘—mandir=/usr/share/man’ ‘—infodir=/usr/share/info’ ‘—cache-file=../config.cache’ ‘—with-libdir=lib’ ‘—with-config-file-path=/etc’ ‘—with-config-file-scan-dir=/etc/php.d’ ‘—disable-debug’ ‘—with-pic’ ‘—disable-rpath’ ‘—without-pear’ ‘—with-bz2’ ‘—with-curl’ ‘—with-exec-dir=/usr/bin’ ‘—with-freetype-dir=/usr’ ‘—with-png-dir=/usr’ ‘—with-xpm-dir=/usr’ ‘—enable-gd-native-ttf’ ‘—with-t1lib=/usr’ ‘—without-gdbm’ ‘—with-gettext’ ‘—with-gmp’ ‘—with-iconv’ ‘—with-jpeg-dir=/usr’ ‘—with-openssl’ ‘—with-png’ ‘—with-expat-dir=/usr’ ‘—with-pcre-regex=/usr’ ‘—with-zlib’ ‘—with-layout=GNU’ ‘—enable-exif’ ‘—enable-ftp’ ‘—enable-magic-quotes’ ‘—enable-sockets’ ‘—enable-sysvsem’ ‘—enable-sysvshm’ ‘—enable-sysvmsg’ ‘—enable-track-vars’ ‘—enable-trans-sid’ ‘—enable-yp’ ‘—enable-wddx’ ‘—with-kerberos’ ‘—enable-ucd-snmp-hack’ ‘—with-unixODBC=shared,/usr’ ‘—enable-memory-limit’ ‘—enable-shmop’ ‘—enable-calendar’ ‘—enable-dbx’ ‘—enable-dio’ ‘—without-mime-magic’ ‘—without-sqlite’ ‘—with-libxml-dir=/usr’ ‘—with-xml’ ‘—with-system-tzdata’ ‘—enable-force-cgi-redirect’ ‘—enable-pcntl’ ‘—with-imap=shared’ ‘—with-imap-ssl’ ‘—enable-mbstring=shared’ ‘—enable-mbstr-enc-trans’ ‘—enable-mbregex’ ‘—with-ncurses=shared’ ‘—with-gd=shared’ ‘—enable-bcmath=shared’ ‘—enable-dba=shared’ ‘—with-db4=/usr’ ‘—with-xmlrpc=shared’ ‘—with-ldap=shared’ ‘—with-ldap-sasl’ ‘—with-mysql=shared,/usr’ ‘—with-mysqli=shared,/usr/bin/mysql_config’ ‘—enable-dom=shared’ ‘—with-dom-xslt=/usr’ ‘—with-dom-exslt=/usr’ ‘—with-pgsql=shared’ ‘—with-snmp=shared,/usr’ ‘—enable-soap=shared’ ‘—with-xsl=shared,/usr’ ‘—enable-xmlreader=shared’ ‘—enable-xmlwriter=shared’ ‘—enable-fastcgi’ ‘—enable-pdo=shared’ ‘—with-pdo-odbc=shared,unixODBC,/usr’ ‘—with-pdo-mysql=shared,/usr’ ‘—with-pdo-pgsql=shared,/usr’ ‘—with-pdo-sqlite=shared,/usr’ ‘—enable-json=shared’ ‘—enable-zip=shared’ ‘—with-readline’ ‘—enable-dbase=shared’ ‘—with-pspell=shared’ ‘—with-mcrypt=shared,/usr’ ‘—with-mhash=shared,/usr’ ‘—with-tidy=shared,/usr’ ‘—with-mssql=shared,/usr’
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
additional .ini files parsed => /etc/php.d/dbase.ini,
/etc/php.d/dom.ini,
/etc/php.d/eaccelerator.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/xmlreader.ini,
/etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini,
/etc/php.d/zip.ini

PHP API => 20041225
PHP Extension => 20060613
Zend Extension => 220060519
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
IPv6 Support => enabled
Registered PHP Streams => php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters => string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

_______________________________________________________________________

Configuration

PHP Core

Directive => Local Value => Master Value
allow_call_time_pass_reference => On => On
allow_url_fopen => On => On
allow_url_include => Off => Off
always_populate_raw_post_data => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
asp_tags => Off => Off
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => no value => no value
default_mimetype => text/html => text/html
define_syslog_variables => Off => Off
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 6143 => 6143
expose_php => On => On
extension_dir => /usr/lib/php/modules => /usr/lib/php/modules
file_uploads => On => On
highlight.bg => <font style=»color: #FFFFFF»>#FFFFFF</font> => <font style=»color: #FFFFFF»>#FFFFFF</font>
highlight.comment => <font style=»color: #FF8000″>#FF8000</font> => <font style=»color: #FF8000″>#FF8000</font>
highlight.default => <font style=»color: #0000BB»>#0000BB</font> => <font style=»color: #0000BB»>#0000BB</font>
highlight.html => <font style=»color: #000000″>#000000</font> => <font style=»color: #000000″>#000000</font>
highlight.keyword => <font style=»color: #007700″>#007700</font> => <font style=»color: #007700″>#007700</font>
highlight.string => <font style=»color: #DD0000″>#DD0000</font> => <font style=»color: #DD0000″>#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/share/pear:/usr/share/php => .:/usr/share/pear:/usr/share/php
log_errors => On => On
log_errors_max_len => 1024 => 1024
magic_quotes_gpc => Off => Off
magic_quotes_runtime => Off => Off
magic_quotes_sybase => Off => Off
mail.force_extra_parameters => no value => no value
max_execution_time => 0 => 0
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
memory_limit => 32M => 32M
open_basedir => no value => no value
output_buffering => 0 => 0
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 16K => 16K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
register_globals => Off => Off
register_long_arrays => Off => Off
report_memleaks => On => On
report_zend_debug => Off => Off
safe_mode => Off => Off
safe_mode_exec_dir => no value => no value
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
serialize_precision => 100 => 100
short_open_tag => On => On
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
variables_order => EGPCS => EGPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
y2k_compliance => On => On
zend.ze1_compatibility_mode => Off => Off

bz2

BZip2 Support => Enabled
Stream Wrapper support => compress.bz2://
Stream Filter support => bzip2.decompress, bzip2.compress
BZip2 Version => 1.0.5, 10-Dec-2007

calendar

Calendar support => enabled

ctype

ctype functions => enabled

curl

cURL support => enabled
cURL Information => libcurl/7.18.2 NSS/3.12.1.1 zlib/1.2.3 libidn/0.6.14 libssh2/0.18

date

date/time support => enabled
«Olson» Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => Europe/Moscow

Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => no value => no value

dom

DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.7.1
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled

eAccelerator

eAccelerator support => enabled
Version => 0.9.5.2
Caching Enabled => false
Optimizer Enabled => false

Directive => Local Value => Master Value
eaccelerator.allowed_admin_path => no value => no value
eaccelerator.cache_dir => /var/cache/php-eaccelerator => /var/cache/php-eaccelerator
eaccelerator.check_mtime => 1 => 1
eaccelerator.compress => 1 => 1
eaccelerator.compress_level => 9 => 9
eaccelerator.content => shm_and_disk => shm_and_disk
eaccelerator.debug => 0 => 0
eaccelerator.enable => 1 => 1
eaccelerator.filter => no value => no value
eaccelerator.keys => shm_and_disk => shm_and_disk
eaccelerator.log_file => /var/log/httpd/eaccelerator_log => /var/log/httpd/eaccelerator_log
eaccelerator.name_space => no value => no value
eaccelerator.optimizer => 1 => 1
eaccelerator.sessions => shm_and_disk => shm_and_disk
eaccelerator.shm_max => 0 => 0
eaccelerator.shm_only => 0 => 0
eaccelerator.shm_prune_period => 0 => 0
eaccelerator.shm_size => 0 => 0
eaccelerator.shm_ttl => 3600 => 3600

exif

EXIF Support => enabled
EXIF Version => 1.4 $Id: exif.c,v 1.173.2.5.2.25 2008/03/12 17:33:14 iliaa Exp $
Supported EXIF Version => 0220
Supported filetypes => JPEG,TIFF

filter

Input Validation and Filtering => enabled
Revision => $Revision: 1.52.2.42 $

Directive => Local Value => Master Value
filter.default => unsafe_raw => unsafe_raw
filter.default_flags => no value => no value

ftp

FTP support => enabled

gd

GD Support => enabled
GD Version => bundled (2.0.34 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.3.7
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XPM Support => enabled
XBM Support => enabled

gettext

GetText Support => enabled

gmp

gmp support => enabled
GMP version => 4.2.2

hash

hash support => enabled
Hashing Engines => md2 md4 md5 sha1 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru gost adler32 crc32 crc32b haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5

iconv

iconv support => enabled
iconv implementation => glibc
iconv library version => 2.9

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

json

json support => enabled
json version => 1.2.1

libxml

libXML support => active
libXML Version => 2.7.1
libXML streams => enabled

mbstring

Multibyte Support => enabled
Multibyte string engine => libmbfl
Multibyte (japanese) regex support => enabled
Multibyte regex (oniguruma) version => 4.4.4
Multibyte regex (oniguruma) backtrack check => On

mbstring extension makes use of «streamable kanji code filter and converter», which is distributed under the GNU Lesser General Public License version 2.1.

Directive => Local Value => Master Value
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => ISO-8859-1 => no value
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value

mcrypt

mcrypt support => enabled
Version => 2.5.8
Api No => 20021217
Supported ciphers => cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes
Supported modes => cbc cfb ctr ecb ncfb nofb ofb stream

Directive => Local Value => Master Value
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => 5.0.77
MYSQL_MODULE_TYPE => external
MYSQL_SOCKET => /var/lib/mysql/mysql.sock
MYSQL_INCLUDE => -I/usr/include/mysql
MYSQL_LIBS => -L/usr/lib/mysql -lmysqlclient

Directive => Local Value => Master Value
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => no value => no value
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off

mysqli

MysqlI Support => enabled
Client API library version => 5.0.77
Client API header version => 5.0.67
MYSQLI_SOCKET => /var/lib/mysql/mysql.sock

Directive => Local Value => Master Value
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.reconnect => Off => Off

openssl

OpenSSL support => enabled
OpenSSL Version => OpenSSL 0.9.8g 19 Oct 2007

pcntl

pcntl support => enabled

pcre

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 7.8 2008-09-05

Directive => Local Value => Master Value
pcre.backtrack_limit => 100000 => 100000
pcre.recursion_limit => 100000 => 100000

PDO

PDO support => enabled
PDO drivers => mysql, sqlite

pdo_mysql

PDO Driver for MySQL, client library version => 5.0.77

pdo_sqlite

PDO Driver for SQLite 3.x => enabled
PECL Module version => 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.3 2007/12/31 07:20:10 sebastian Exp $
SQLite Library => 3.5.9

posix

Revision => $Revision: 1.70.2.3.2.18 $

Reflection

Reflection => enabled
Version => $Id: php_reflection.c,v 1.164.2.33.2.50 2008/03/13 15:56:21 iliaa Exp $

session

Session Support => enabled
Registered save handlers => files user eaccelerator
Registered serializer handlers => php php_binary wddx

Directive => Local Value => Master Value
session.auto_start => Off => Off
session.bug_compat_42 => Off => Off
session.bug_compat_warn => On => On
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => Off => Off
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => no value => no value
session.entropy_length => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.hash_bits_per_character => 5 => 5
session.hash_function => 0 => 0
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/session => /var/lib/php/session
session.serialize_handler => php => php
session.use_cookies => On => On
session.use_only_cookies => Off => Off
session.use_trans_sid => 0 => 0

shmop

shmop support => enabled

SimpleXML

Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.39 $
Schema support => enabled

sockets

Sockets Support => enabled

SPL

SPL support => enabled
Interfaces => Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilterIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RegexIterator, RuntimeException, SimpleXMLIterator, SplFileInfo, SplFileObject, SplObjectStorage, SplTempFileObject, UnderflowException, UnexpectedValueException

standard

Regex Library => Bundled library enabled
Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i

Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
safe_mode_allowed_env_vars => PHP_ => PHP_
safe_mode_protected_env_vars => LD_LIBRARY_PATH => LD_LIBRARY_PATH
url_rewriter.tags => a=href,area=href,frame=src,input=src,form=fakeentry => a=href,area=href,frame=src,input=src,form=fakeentry
user_agent => no value => no value

sysvmsg

sysvmsg support => enabled
Revision => $Revision: 1.20.2.3.2.7 $

tokenizer

Tokenizer Support => enabled

wddx

WDDX Support => enabled
WDDX Session Serializer => enabled

xml

XML Support => active
XML Namespace Support => active
libxml2 Version => 2.7.1

xmlreader

XMLReader => enabled

xmlwriter

XMLWriter => enabled

xsl

XSL => enabled
libxslt Version => 1.1.24
libxslt compiled against libxml Version => 2.7.2
EXSLT => enabled
libexslt Version => 1.1.24

zip

Zip => enabled
Extension Version => $Id: php_zip.c,v 1.1.2.43 2008/01/18 00:51:38 pajoye Exp $
Zip version => 1.8.11
Libzip version => 0.8.0-compatible

zlib

ZLib Support => enabled
Stream Wrapper support => compress.zlib://
Stream Filter support => zlib.inflate, zlib.deflate
Compiled Version => 1.2.3
Linked Version => 1.2.3

Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value

Additional Modules

Module Name
dbase
readline
sysvsem
sysvshm

Environment

Variable => Value
HOSTNAME => localhost.localdomain
TERM => xterm
SHELL => /bin/bash
HISTSIZE => 1000
QTDIR => /usr/lib/qt-3.3
USER => apache
LS_COLORS => no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:eek:r=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:eek:w=34;42:st=37;44:ex=00;32:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.tbz2=00;31:*.bz=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.mng=00;35:*.pcx=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.svg=00;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
CCACHE_DIR => /var/cache/ccache
SUDO_USER => root
SUDO_UID => 0
USERNAME => root
MAIL => /var/spool/mail/root
PATH => /usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/sbin:/bin:/usr/sbin:/usr/bin
INPUTRC => /etc/inputrc
PWD => /var/www/html
CCACHE_UMASK => 002
LANG => ru_RU.KOI8-R
SSH_ASKPASS => /usr/libexec/openssh/gnome-ssh-askpass
HOME => /root
SUDO_COMMAND => /bin/su apache
SHLVL => 2
LOGNAME => apache
CVS_RSH => ssh
LESSOPEN => |/usr/bin/lesspipe.sh %s
SUDO_GID => 0
G_BROKEN_FILENAMES => 1
_ => /usr/bin/php

PHP Variables

Variable => Value
_SERVER[«HOSTNAME»] => localhost.localdomain
_SERVER[«TERM»] => xterm
_SERVER[«SHELL»] => /bin/bash
_SERVER[«HISTSIZE»] => 1000
_SERVER[«QTDIR»] => /usr/lib/qt-3.3
_SERVER[«USER»] => apache
_SERVER[«LS_COLORS»] => no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:eek:r=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:eek:w=34;42:st=37;44:ex=00;32:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.tbz2=00;31:*.bz=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.mng=00;35:*.pcx=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.svg=00;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
_SERVER[«CCACHE_DIR»] => /var/cache/ccache
_SERVER[«SUDO_USER»] => root
_SERVER[«SUDO_UID»] => 0
_SERVER[«USERNAME»] => root
_SERVER[«MAIL»] => /var/spool/mail/root
_SERVER[«PATH»] => /usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/sbin:/bin:/usr/sbin:/usr/bin
_SERVER[«INPUTRC»] => /etc/inputrc
_SERVER[«PWD»] => /var/www/html
_SERVER[«CCACHE_UMASK»] => 002
_SERVER[«LANG»] => ru_RU.KOI8-R
_SERVER[«SSH_ASKPASS»] => /usr/libexec/openssh/gnome-ssh-askpass
_SERVER[«HOME»] => /root
_SERVER[«SUDO_COMMAND»] => /bin/su apache
_SERVER[«SHLVL»] => 2
_SERVER[«LOGNAME»] => apache
_SERVER[«CVS_RSH»] => ssh
_SERVER[«LESSOPEN»] => |/usr/bin/lesspipe.sh %s
_SERVER[«SUDO_GID»] => 0
_SERVER[«G_BROKEN_FILENAMES»] => 1
_SERVER[«_»] => /usr/bin/php
_SERVER[«PHP_SELF»] => —
_SERVER[«SCRIPT_NAME»] => —
_SERVER[«SCRIPT_FILENAME»] =>
_SERVER[«PATH_TRANSLATED»] =>
_SERVER[«DOCUMENT_ROOT»] =>
_SERVER[«REQUEST_TIME»] => 1243516911
_SERVER[«argv»] => Array
(
[0] => —
)

_SERVER[«argc»] => 1
_ENV[«HOSTNAME»] => localhost.localdomain
_ENV[«TERM»] => xterm
_ENV[«SHELL»] => /bin/bash
_ENV[«HISTSIZE»] => 1000
_ENV[«QTDIR»] => /usr/lib/qt-3.3
_ENV[«USER»] => apache
_ENV[«LS_COLORS»] => no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:eek:r=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:eek:w=34;42:st=37;44:ex=00;32:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.tbz2=00;31:*.bz=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.mng=00;35:*.pcx=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.svg=00;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
_ENV[«CCACHE_DIR»] => /var/cache/ccache
_ENV[«SUDO_USER»] => root
_ENV[«SUDO_UID»] => 0
_ENV[«USERNAME»] => root
_ENV[«MAIL»] => /var/spool/mail/root
_ENV[«PATH»] => /usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/sbin:/bin:/usr/sbin:/usr/bin
_ENV[«INPUTRC»] => /etc/inputrc
_ENV[«PWD»] => /var/www/html
_ENV[«CCACHE_UMASK»] => 002
_ENV[«LANG»] => ru_RU.KOI8-R
_ENV[«SSH_ASKPASS»] => /usr/libexec/openssh/gnome-ssh-askpass
_ENV[«HOME»] => /root
_ENV[«SUDO_COMMAND»] => /bin/su apache
_ENV[«SHLVL»] => 2
_ENV[«LOGNAME»] => apache
_ENV[«CVS_RSH»] => ssh
_ENV[«LESSOPEN»] => |/usr/bin/lesspipe.sh %s
_ENV[«SUDO_GID»] => 0
_ENV[«G_BROKEN_FILENAMES»] => 1
_ENV[«_»] => /usr/bin/php

-~{}~ 02.06.09 16:39:

В общем дело решилось так:
— поставил Fedora-8 и все заработало!

Непонятно в чем дело в Fedora-10! Но все работает.

Nebiros

41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

1

14.10.2017, 13:13. Показов 5344. Ответов 12

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

пытаюсь с помощью скрипта создать директорию и мне высвечивает ошибку «Warning: mkdir(): Permission denied in»

PHP
1
2
$p='/var/www/html/test/1/';
if(!file_exists($p)) if(!mkdir($p,0777,true)) echo 'error';

при этом на саму папку test стоят права 777, и плюс точно такой же скрипт лежит в другой папке но запускается с крона и создает директорию, облазил форумы но нужного решения данной проблемы не нашел, подскажите что делать в данной ситуации?

Добавлено через 51 минуту
Решил проблему задав в права в линуксе не chmod 777 test.php а chmod -R 777 test.php, но теперь созданные директории имеют владельца не root а www-data, это может быть проблемой? Никто не сможет ли со стороны изменить что либо?



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 13:15

2

Цитата
Сообщение от Nebiros
Посмотреть сообщение

Никто не сможет ли со стороны изменить что либо?

Права 777 — меняй кто хочешь чего хочешь



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 13:21

 [ТС]

3

Цитата
Сообщение от Jewbacabra
Посмотреть сообщение

Права 777 — меняй кто хочешь чего хочешь

тогда что установить чтобы изменения могли быть только от моих скриптов? 700 не дает таких прав как и 770

Добавлено через 2 минуты
Если честно до сих пор не пойму что значит выполнение скриптов всем, если я только имею доступ к руту и только я могу загружать физически файлы на сервер, то если на файлах и будет стоять 777 их же кроме меня никто не сможет изменить? или я не так это понимаю?



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 13:45

4

Цитата
Сообщение от Nebiros
Посмотреть сообщение

то если на файлах и будет стоять 777 их же кроме меня никто не сможет изменить?

Считается использование прав 777 дурным тоном. Помимо пользователя, из под которого ты работаешь в системе есть множество других, от имени которых работают различные службы, неплохо задавать права таким образом, чтобы доступ к определенным файлам мог получить тот кому это нужно.
Если речь идет о php файлах, то сама цифра 7 в правах на любой из позиций уже не верно, за исключением некоторых ситуfций.



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 13:50

 [ТС]

5

Цитата
Сообщение от Jewbacabra
Посмотреть сообщение

Считается использование прав 777 дурным тоном. Помимо пользователя, из под которого ты работаешь в системе есть множество других, от имени которых работают различные службы, неплохо задавать права таким образом, чтобы доступ к определенным файлам мог получить тот кому это нужно.
Если речь идет о php файлах, то сама цифра 7 в правах на любой из позиций уже не верно, за исключением некоторых ситуfций.

так а как правильно если мне вот в данной ситуации нужно чтобы скрипт создавал директорию и файлы а кроме прав 777 больше никак не получается?

Добавлено через 2 минуты

Цитата
Сообщение от Nebiros
Посмотреть сообщение

Помимо пользователя, из под которого ты работаешь в системе есть множество других

что значит в системе есть множество других если доступ к руту а то есть к серверу есть только у меня ?



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 13:55

6

Цитата
Сообщение от Nebiros
Посмотреть сообщение

так а как правильно если мне вот в данной ситуации нужно чтобы скрипт создавал директорию и файлы

Значит для пользователя от имени которого выполняется php для директории, внутри которой нужно создавать файлы были права на запись.

Цитата
Сообщение от Nebiros
Посмотреть сообщение

что значит в системе есть множество других

Даже из этой темы видно что по крайней мере кроме рута есть еще один пользователь — www-data

Цитата
Сообщение от Nebiros
Посмотреть сообщение

созданные директории имеют владельца не root а www-data



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 14:00

 [ТС]

7

Цитата
Сообщение от Jewbacabra
Посмотреть сообщение

Даже из этой темы видно что по крайней мере кроме рута есть еще один пользователь — www-data

вот я и сам не понял как это, на всех исполняющих файлах стоит владелец root, только тот скрипт который выполняется кроном создает папку с владельцем root а тот который можно сказать я запускаю вручную (перезагружая страницу он запускается при вызове библиотеки) создается папка с владельцем www-data

При это как я уже писал выше если права дать так chmod 777 test.php то будет ошибка доступа, а если chmod -R 777 test.php то будет работать но создавать с владельцем www-data

Не совсем понимаю логику эту прав…



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 14:08

8

Цитата
Сообщение от Nebiros
Посмотреть сообщение

вот я и сам не понял как это, на всех исполняющих файлах стоит владелец root

Не важно какой у них владелец. Их выполняет php от имени www-data.

Цитата
Сообщение от Nebiros
Посмотреть сообщение

тот скрипт который выполняется кроном создает папку с владельцем root

А крон задача выполняется от пользователя root.

Цитата
Сообщение от Nebiros
Посмотреть сообщение

если права дать так chmod 777 test.php то будет ошибка доступа, а если chmod -R 777 test.php то будет работать но создавать с владельцем www-data

Неверный вывод. Флаг -R тут не при чем



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 14:11

 [ТС]

9

Цитата
Сообщение от Jewbacabra
Посмотреть сообщение

Неверный вывод. Флаг -R тут не при чем

если флаг не причем то почему без него не работает а с ним работает?
Я так понял нужно где то искать полное описание начиная от настроек в апаче и до исполнения…



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 14:13

10

Цитата
Сообщение от Nebiros
Посмотреть сообщение

если флаг не причем то почему без него не работает а с ним работает?

Не зная точной последовательности твоих действий тяжело ответить. Флаг R на файл вообще смысла не имеет



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 14:16

 [ТС]

11

Цитата
Сообщение от Jewbacabra
Посмотреть сообщение

Не зная точной последовательности твоих действий тяжело ответить.

Последовательность простая, при заходе пользователя на страницу настроек проверяется есть ли файл с настройками, если его нету то создать его, ну и записать в него то что нужно…

собственно это я и пытаюсь сделать, пользователь зашел, тем самым запустился скрипт, проверил, создал, записал…



0



Эксперт PHP

4845 / 3857 / 1599

Регистрация: 24.04.2014

Сообщений: 11,317

14.10.2017, 14:23

12

Цитата
Сообщение от Nebiros
Посмотреть сообщение

Последовательность простая, при заходе пользователя на страницу настроек проверяется есть ли файл с настройками, если его нету то создать его, ну и записать в него то что нужно…

Не, какие именно команды были выполнены с какими правами доступа, и т.д. Тяжело будет восстановить все ситуацию



0



41 / 42 / 16

Регистрация: 23.03.2010

Сообщений: 3,079

14.10.2017, 14:27

 [ТС]

13

я давал права 777 двум папкам, в одной крон создает директории в другой можно сказать вручную, только там я давал права chmod 777 test.php и все работает ок, а тут только с флагом -R, вот как то так.

Вот теперь и думаю, на стадии разработки еще ладно, все работает то, но вот когда уже будет запущен проект полностью, не будет ли это так называемыми уязвимыми дырами…



0




1

3

На локальной машине (линукс минт) организовал хостинг.

PHP выдает ошибку: PHP Warning: fopen(/var/..../section_pub_id.html): failed to open stream: Permission denied in ....

Ошибка, конечно, гуглится, но дают советы выставить права 777. Я считаю что это как-то не правильно, потому, что:

Захожу на купленный виртуальный хостинг по ssh и смотрю там права:

drwxr-xr-x 2 webuser customers 4096 Apr 23 17:52 .
drwxr-xr-x 3 webuser customers 4096 Jul 25  2014 ..
-rw-r--r-- 1 webuser customers 2779 May  7 16:22 section_pub_id.html

(тоесть никаких 777, и при этом все работает)

Теперь на локальной машине:

drwxr-xr-x 2 yadfeshhm yadfeshhm 4096 апр.  23 18:08 .
drwxr-xr-x 3 yadfeshhm yadfeshhm 4096 янв.  13 19:34 ..
-rw-r--r-- 1 yadfeshhm yadfeshhm 2571 апр.  23 18:08 section_pub_id.html

При установке вебсервера нагугливались советы по выставлению прав на папки и файлы проекта, которые я применил:

sudo find . -type d ! -perm 755 -exec chmod 755 {} ;
sudo find . -type f ! -perm 644 -exec chmod 644 {} ;

У меня подозрения, что я как-то неправильно поставил пых?

Answer by Cal Townsend

I am trying to create a directory with PHP mkdir function but I get an error as follows: Warning: mkdir() [function.mkdir]: Permission denied in …. How to settle down the problem?,Fix the permissions of the directory you try to create a directory in.,You need to have file system permission to create the directory.,The problem why PHP says «Permission denied» for mkdir() — wrong url path. So, to fix it, all you need it’s to obtain correct path. I did it this way:

find:

User _www 
Group _www

change the username:

User <YOUR LOGIN USERNAME>

Now restart apache by running this form terminal:

sudo apachectl -k restart

Open terminal and run the following commands:
(note, my webserver files are located at /Library/WebServer/www. Change according to your website location)

sudo chmod 775 /Library/WebServer/www
sudo chmod 775 /Library/WebServer/www/*

Answer by Noah Patterson

Some further information: if I comment this code, manually create the posts folder and then try to upload a file I get an error saying that the destination path is not writable.,

with most web servers it is www-data on Ubuntu. Who owns /opt/lampp/htdocs/www/my-site/public/uploads ? Note it is a bit of a security risk to allow php rw access.

– Panther

Sep 29 ’15 at 21:23

,Connect and share knowledge within a single location that is structured and easy to search.,Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.

As per your comment, ls -l /opt/lampp/htdocs/www/my-site/public/uploads doesn’t exists, so you should call mkdir() passing the recursive parameter:

$dir = '/uploads/posts';
if (!is_dir($dir)) {
    mkdir($dir, 755, true);
}

Answer by Elijah Knox

You have to add sudo word before your command line.,The user that you are trying to make the directory with either does not have permissions to make a directory in that location, or you simply need to add the word sudo before the command. ,Try adding sudo first and see what the response is. Either the directory will be created as you want, or you do not have sudo permissions meaning that you need to login as someone with sudo permissions and make the directory.,However, once you have logged in as a user that does have the permissions required to make a directory there you could change the permissions of the file path so that the original user you tried could make a directory there, which can be accomplished using the chmod command.

Check out the user and group you are running you WebServer.
Then you should change user and group owner:

chown user:group  /opt/bitnami/apps/joomla/htdocs/templates/g5_hydrogen/custom/

Answer by Crew Cabrera

chown -R www-data:www-data /path/to/webserver/www,Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user,Make sure all files are owned by the Apache group and user. In Ubuntu it is the www-data group and user
chown -R www-data:www-data /path/to/webserver/www,Example: In Ubuntu 10.04 apache (php) runs as user: www-data in group: www-data

find:

User _www 
Group _www

change the username:

User <YOUR LOGIN USERNAME>

Now restart apache by running this form terminal:

sudo apachectl -k restart

Open terminal and run the following commands:
(note, my webserver files are located at /Library/WebServer/www. Change according to your website location)

sudo chmod 775 /Library/WebServer/www
sudo chmod 775 /Library/WebServer/www/*

Answer by Ellen Moran

This is another very common error when creating directories using mkdir command.,If I try creating a subdirectory now, I will get the mkdir: cannot create directory – permissions denied error:,This time there were no errors, and ls command can show you that indeed you have a directory called /tmp/newtry now:,The reason for this error is that the user you’re running the mkdir as, doesn’t have permissions to create new directory in the location you specified.

[email protected]:~$ mkdir /tmp/try
mkdir: cannot create directory – File exists

Answer by Miracle Rosario

add «www» group and add your user to this group
sudo groupadd www
sudo usermod -a -G www ec2-user
,add «www» group and add your user to this group,set ownership and write permissions,Working narrower solution inside Homestead-Box:

add «www» group and add your user to this group

sudo groupadd www
sudo usermod -a -G www ec2-user

Answer by Freyja Black

www-data must have write access to the entire tree. ,You can execute chown -R www-data:yourgroup /var/www/html/pluto-php, where yourgroup is the group name of your user (avoid root for security reasons). If you don’t specify your groupname, you won’t be able to write and read in the data directory.,Next add the right permissions by executing chmod -R 775 /var/www/html/pluto-php.,namei -mo /var/www/html/pluto-php/public/

in my phpinfo configuration, i see the following:

User/Group  www-data(33)/33

In my directory /var/www/html/pluto-php/public/ I see the following for the data directory inside this path:

4 drwxrwxrwx 2 www-data www-data 4096 Sep 19 23:25 data

I also see the following for the pluto-php directory

4 drwxr-xr-x  8 root root  4096 Sep 16 21:49 pluto-php

I set the owner and group for the data dir to www-data. Somehow, after all of this, I still get this error in my php code when running a php script which creates a directory inside the data directory:

Warning: mkdir(): Permission denied in /var/www/html/pluto-php/vendor/pluto/src/Pluto/Stdlib/FilesystemUtils.php on line 32

Here is my process list

    [email protected]:/var/www/html# ps aux | grep apache
    root      3234  0.0  0.6 409908 37092 ?        Ss   Sep28   0:09 /usr/sbin/apache2 -k start
    www-data  8516  0.3  0.2 410888 16988 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    www-data  8517  0.0  0.1 409940 10632 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    www-data  8518  0.0  0.1 409940 10632 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    www-data  8519  0.0  0.1 409940 10632 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    www-data  8520  0.0  0.1 409940 10632 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    www-data  8521  0.0  0.1 409940 10632 ?        S    10:41   0:00 /usr/sbin/apache2 -k start
    root      8523  0.0  0.0  21292  1088 pts/1    S+   10:41   0:00 grep --color=auto apache

When trying to open a file using fopen(), you might see an error saying permission denied as follows:

Warning: fopen(log.txt): failed to open stream:
  Permission denied in /var/www/html/app.php on line 2

This error frequently occurs on a Linux system because of two things:

  1. The protection of SELinux
  2. The owner of the folder of the file you try to open is root

To resolve this issue, you can try to disable SELinux first.

Disabling SELinux to fix fopen() issue

To disable SELinux, run the following command from your terminal:

The setenforce command will disable SELinux until you reboot the system.

If you still get the permission denied error with fopen(), try to change the owner of the file and directory that you want to access.

Change directory owner to solve fopen() issue

Most often, the fopen() function tries to access a file using the web server user.

This means PHP will use apache user when you have Apache server, or nginx when you have Nginx server.

When the root is the owner of the file you tried to access, it will cause the permission denied error.

Check the owner of your file by running ls -l command from the terminal:

$ ls -l log.txt
-rwxrwxrwx  4 root root 4096 Sep 15  2021 log.txt

To enable access with fopen(), you need to change the owner of the file you want to access.

Run the chown command to change the file owner as follows:

chown apache:apache log.txt
# or
chown nginx:nginx log.txt

Sometimes, you also need to change the owner of the directory where the file is located.

This is because access to some directories are restricted only to the owner.

In my case, the full URL of the file is /var/log/httpd/ so I change the directory httpd owner as follows:

chown apache:apache /var/log/httpd

Keep in mind that changing owners and permissions in your system may introduce security issues.

When possible, it’s better to move the files and directories that you need access to another location.

Create a new directory that can be accessed by PHP fopen() and put all files you need in that directory.

And that’s how you solve the PHP fopen() permission denied error. I hope this tutorial has been useful for you 🙏

Recently I moved a site from Ubuntu to Centos and began to notice that users were displayed a blank response page after performing transactions. The Apache logs had these messages.

[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354
[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica-Bold.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354
[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica-Bold.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354
[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica-Bold.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354
[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354
[Mon Jul 15 02:15:58 2013] [error] [client 173.24.242.72] PHP Warning:  file_put_contents(/home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/fonts/php_Helvetica.afm): failed to open stream: Permission denied in /home/sridhar/public_html/mysite.com/public/pgway_icici/dompdf/lib/class.pdf.php on line 2354

Checking ls -lZ for each of these directories I had the following outputs

[root@i-8941-35408-VM pgway_icici]# ls -lZ dompdf
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t ChangeLog
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t dompdf_config.inc.php
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t dompdf.php
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t HACKING
drwxr-xr-x  1001 1001 user_u:object_r:httpd_sys_content_t include
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t INSTALL
drwxr-xr-x  1001 1001 user_u:object_r:httpd_sys_content_t lib
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t LICENSE.LGPL
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t load_font.php
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t README
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t TODO
[root@i-8941-35408-VM pgway_icici]# ls -lZ dompdf/lib
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t class.pdf.php
drwxr-xr-x  1001 1001 user_u:object_r:httpd_sys_content_t fonts
drwxr-xr-x  1001 1001 user_u:object_r:httpd_sys_content_t res
[root@i-8941-35408-VM pgway_icici]# ls -lZ dompdf/lib/fonts
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Courier.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Courier-Bold.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Courier-BoldOblique.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Courier-Oblique.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t dompdf_font_family_cache
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t dompdf_font_family_cache.dist
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Helvetica.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Helvetica-Bold.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Helvetica-BoldOblique.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Helvetica-Oblique.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Times-Bold.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Times-BoldItalic.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Times-Italic.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t Times-Roman.afm
-rw-r--r--  1001 1001 user_u:object_r:httpd_sys_content_t ZapfDingbats.afm

Not sure what could be wrong. Would appreciate any suggestions to resolve this.

asked Jul 16, 2013 at 16:56

sridhar pandurangiah's user avatar

1

These files are not owned by apache, so, you’ll need to chmod the fonts/*.afm files to +w to other in order to give write permissions to apache (chmod 666 fonts/*.afm). Alternatively, give the ownership to apache (chown apache fonts/*.afm).

Might also want to set proper file ownership to all of these. As it seems to be unable to find the username to these user# 1001.

answered Jul 16, 2013 at 17:07

Grumpy's user avatar

@mmattel

oC 4.5.5 on Ubuntu 12.04, external storage via smb

When I start the server (reboot) or restart apache, in some circumstances I can for a long time not logon. I do not even get a web response from owncloud. Looking to apaches error log I saw, following error:

—> PHP Warning: mkdir(): Permission denied in /mnt/www/owncloud/lib/cache/fileglobal.php on line 14, referer: https://www.xxxxxxx/owncloud/settings/admin.php

This error message is not really useful, because you do not know why in detail the error was raised. Parsing the code of fileglobal.php, the statement mkdir in line 14 is the root cause. I changed the code to following printing the «cache_dir» which causes the error:

                    if(!mkdir($cache_dir)) {
                            error_log(print_r($cache_dir,true));
                    }

This prints out in addition the path and file to be created causing the error.

—> /mnt/www/php/tmp/owncloud-50f983ecb3047/, referer: https://www.xxxxxxx/owncloud/settings/admin.php

Trying to look to the path, I found out, that the folder «php» in /mnt/www/ did not exist…
oC was fresh installed, nothing has been «tweaked» in the www path of oC.

Actions:

1.) expanding the code in fileglobal.php line 14 from mkdir($cache_dir) to catch and print more details of the raising error to the apache error log

2.) expanding the mkdir command to recursive creation
(http://php.net/manual/de/function.mkdir.php)

Code suggestion:

                    if(!mkdir($cache_dir, 0, true)) {
                            error_log(print_r($cache_dir,true));
                    }

3.) creating during the install a php and tmp folder in the ./owncloud directory and set the permissions properly

Best Regards
Martin

@RandolfCarter

Can you check your php settings? To me the /mnt/www/php/tmp/ path somehow looks like a php temp path…

@mmattel



Copy link


Contributor


Author

I did a check and to my shame, the upload_tmp_dir in php.ini had a wrong path set :-(
Maybe because of playing around for testing…

But anyway, changing the code from normal mkdir to my suggestion would help in those cases identifying the cause of the mistake because of logging the path. Could be easily implemented before oC5.

I will also do an update on #1273 because I completely reinstalled from scratch leaving nothing over and did further tests.

@karlitschek

@mmattel Does this bug still exist with the latest ownCloud RC1 ?

@mmattel



Copy link


Contributor


Author

Yes it does.
I just deleted the oC instance and the php folder
/mnt/www/owncloud (content deleted)
/mnt/www/php (folder php deleted)
Then I downloaded the latest oC master (core, apps, r3dparty) from github) , uploaded it to the owncloud directory and finalized the installation.

Checking the apache log everything looks fine
Checking the oC log, I get the error as above:

{«app»:»PHP»,»message»:»mkdir(): No such file or directory at /mnt/www/owncloud/lib/cache/fileglobal.php#14″,»level»:2,»time»:1362317650}

In the meanwhile I know the cause, because the/a php folder in www root is missing and/or does not have the right permissons set to be accessed from apache/oC. This can happen, if you link your original www folder to a different place but forget the php directory.

The outcoming oC log entry is confusing. I made a code suggestion above which I tried and it worked, but I made no pull request, as I have to read how to do that first because I never did that before (shame) and I have limited time (excuse).

With my suggestion above, the error will not go away, but you can see where the problem is located, and then fixing is more easy.

I post created the php dir in /mnt/www (/mnt/www/php) and checked again the log — permission denied
{«app»:»PHP»,»message»:»mkdir(): Permission denied at /mnt/www/owncloud/lib/cache/fileglobal.php#14″,»level»:2,»time»:1362318397}

Then I corrected the permissions and all went fine

@jancborchardt

I’m closing this issue because it has been inactive for a few months. This probably means that the issue is not reproducible or it has been fixed in a newer version.

Please reopen if the error still persists with the latest stable version (currently ownCloud 5.0.9) and then please use the issue template. You an also contribute directly by providing a patch – see the developer manual. :)

Thank you!

@lock
lock
bot

locked as resolved and limited conversation to collaborators

Aug 22, 2019

Понравилась статья? Поделить с друзьями:
  • Php ошибка 500 как вывести
  • Php ошибка 404 не найдено
  • Php ошибка 200 что это
  • Phpmyadmin ошибка конфигурация уже существует настройка отключена
  • Php отобразить ошибки на странице