I've tried everything, so I am forced to create this post.
I have changed the htdocs folder permissions
sudo chmod 644 /Applications/XAMPP/xamppfiles/htdocs/
I have changed the httpd.conf file replacing a daemon by my user:
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User amldesign
Group daemon
</IfModule>
This happened from one day to the next...
what's happening here?
Related
The Apache configuration below makes all PHP scripts to run as the user www belonging to the group www.
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User www
Group www
</IfModule>
I have tried the following:
User: <?php system('whoami'); ?>
Group: <?php system('id -gnr $(whoami)'); ?>
However, both are for Linux and Mac systems only. How can those values be retrieved for Windows systems also?
Using PHP, how to get the values of the User and the Group that Apache is running as?
I am using Fedora 24 on VirtualBox to host a small PHP web app. I am trying to append text into a file that is in the same local directory as the PHP file (/var/www/html/). No matter what kind of permissions or ownerships I try to set onto the directory (html/) or the file I constantly get "Permission denied in /var/www/html/pdf.php on line 21" errors.
Is there any configuration settings in my php.ini file that I need to enable to allow editing of files? I've even tried setting the directory and file to chmod 777 just to see if it would give me access but even that is being rejected.
EDIT: I have also tried creating directories and files in other locations with the same results. I tried to have Apache run the mkdir and touch commands with the same results.
EDIT 2: At the request of the comment left to my initial question. Here is the ownership information for the target directory:
ls -l /var/www/html/
drwxrwxr-x. 2 apache apache 4096 Nov 23 21:28 docs
The ownership information for the file:
-rwxrwxr-x. 1 apache apache 1381 Nov 28 17:47 pdf.php
Try assigning to www-data:nobody
chown -R www-data:nobody *, check apache group on your httpd.conf.
Verify /var/html perms to 775 at least.
Spent a lot of time looking for this answer but it's all in bits and pieces and no one every posts a solution (well most of the time) so here is my solution and it's used on various web control panels as well.
install and use MOD_RUID2
Install PHP with CLI (this is standard on newer versions)
In your HTTPD.CONF file in the virtual hosts, you'll add the following, replacing username with the user's login name, and usergroup with the user's group (These are usually the same)
<IfModule !mod_ruid2.c>
SuexecUserGroup username usergroup
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid username usergroup
RGroups #none
</IfModule>
An example of a Virtual host conf is:
<VirtualHost *:443>
DocumentRoot "/home/imtheuser/public_html"
ServerName imtheuser.com
<IfModule !mod_ruid2.c>
SuexecUserGroup imtheuser imtheuser
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid imtheuser imtheuser
RGroups #none
</IfModule>
<Directory "/home/imtheuser/public_html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
This will allow apache/php to write to a directory owned by the user. It's much safer then setting your chmod to 0777.
I want to create a file in /etc/nginx/sites-enabled/ php, I have tried many times but php will not let think I've already modified the /etc/sudoers and I put them user ALL: NOPASSWD: ALL and still not it works someone can tell me the why?
$result= shell_exec('sudo -u root mkdir /etc/nginx/myfile');
my file /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults exempt_group=sudo
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias NGINXVHOST = /bin/ln, /bin/mkdir
# User privilege specification
# root ALL=(ALL:ALL) ALL
root ALL= (ALL) NOPASSWD:ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL) NOPASSWD:ALL
vagrant ALL=(ALL) NOPASSWD:ALL
subdominio ALL=(ALL) NOPASSWD:ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
please help!!!
The proper way to achieve this objective is for your PHP page to create an entry in a task queue. That entry need only contain the new domain for the virtual host. Then you should have another process runnning as root which can check that hostname and create the nginx records as needed.
If you are not using any task queue at the moment, this can be achieved by a simple cron job as well. Just put an entry in your database with the vhost name. Then have a cron job check that table every minute and make the nginx records.
I am trying to use unlink to delete a file I currecntly have the below code:
unlink(Yii::getAlias('#webroot') . $userprofile->avatar);
The path is correct as I have used echo within the view to check and it point to the correct file that I wish to delete, however I get the below error:
unlink(/Applications/MAMP/htdocs/advanced/Final Prototype): Operation not permitted
Could this be a permissions thing in terms of not being the owner if so how can I check, do I need to do chmod on the file or some directories?
Note: Working on Mac OS X and using MAMP
Change the owner of web directory and its files to your web server user (e.g. www-data for apache).
In apache you can find the user and group on *inx systems, from httpd.conf by looking for User or Group. For example my httpd.conf file on arch linux is:
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User http
Group http
</IfModule>
So with this config you can run chown -R http:http web on root of Yii project.
If the problem was persistent, also you need to change permissions of web folder for having write rule on user and group (chmod -R 755 web may be a temporary solution for this. You must move your files to an upload folder and change permission of that to 755).
I am trying to create a folder chmod it to 777 but I'm unable to it. It always reverts changes to:
File Permissions: 341 Owner/Group: 48 48
It only happens when I try to create a folder using PHP. I use Laravel's mkdir function. (Ref: http://laravel.com/api/class-Laravel.File.html) It works normally if I create folder with FTP.
As asked on other (probably duplicate) topics;
This script outputs:
<?php echo "UID = " . getmyuid() . ", User = " . get_current_user(); ?>
//Output: UID = 502, User = TestUser
I use directadmin as panel and safe_mode is off.
What should I do?
in your httpd.conf file change those 2 lines to any user and group you want.
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch...
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User _www
Group _www
then restart your apache on linux like system by typing ;
sudo /usr/sbin/apachectl restart
on windows I dont know.