Permissions denied when starting apache through webmin/virtualmin - php

I am trying to start my Apache server through both webmin and putty, but I am getting the same error codes.
Apache was running perfectly fine before we did a restart of our VPS, now all the services started except for Apache.
We are running CentOS, the main error we are getting is posted below:
May 23 21:56:47 www.mydomain.com httpd[6234]: AH00526: Syntax error on line 373 of /etc/httpd/conf/httpd.conf:
May 23 21:56:47 www.mydomain.com httpd[6234]: Wrapper /home/mydomain/fcgi-bin/php5.fcgi cannot be accessed: (13)Permission denied
Line 373: FCGIWrapper /home/vps78446/fcgi-bin/php5.fcgi .php
Line 374: FCGIWrapper /home/vps78446/fcgi-bin/php5.fcgi .php5
I have tried editing the permissions, looking at the files called by php5.fcgi, and anything else I could find on the internet.
getent passwd return:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
systemd-bus-proxy:x:997:994:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:996:993:systemd Network Management:/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
dovecot:x:97:97:Dovecot IMAP server:/usr/libexec/dovecot:/sbin/nologin
dovenull:x:995:992:Dovecot's unauthorized user:/usr/libexec/dovecot:/sbin/nologin
mysql:x:27:27:MariaDB Server:/var/lib/mysql:/sbin/nologin
mailman:x:41:41:GNU Mailing List Manager:/usr/lib/mailman:/sbin/nologin
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
named:x:25:25:Named:/var/named:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
clamupdate:x:993:991:Clamav database update user:/var/lib/clamav:/sbin/nologin
Kalgon:x:500:500::/home/Kalgon:/bin/sh
vitalitygaming:x:502:502:Main Site:/home/vitalitygaming:/bin/sh
vps78446:x:503:502:Main Site:/home/vps78446:/bin/sh
scgaminguser.vitalitygaming:x:506:502:SCGamingUser:/home/vitalitygaming/homes/scgaminguser:/bin/false
development.vitalitygaming:x:507:502:Development:/home/vitalitygaming/homes/development:/dev/null
dadenz.vitalitygaming:x:508:502:Dennis:/home/vitalitygaming/homes/dadenz:/dev/null

can you give us the permissions for those files,
open terminal enter cd /home/vps78446/fcgi-bin/ then ls -la
post results:
edit:
run the command below
sudo chown -R www-data:www-data /home/vps78446/fcgi-bin
try to run Apache after that

Related

PHP rename() permission denied via Apache (SELinux related)

I have a simple script that outputs Permission denied warning in the browser:
rename('/opt/web/test.tmp', '/opt/web/test.tmp1')
Script path is /opt/web/test_rename.php
/opt/, /opt/web/ and /opt/web/test_rename.php are 777 and have apache owner / group.
httpd process owner is apache
test.tmp is 777 and have apache owner as well
It works fine with cli.
What else could I do to make it work via apache?
The problem was with SELinux. It can block php rename function.
I've found the answer here: http://forums.fedoraforum.org/archive/index.php/t-111081.html
On the Fedora Core 3 Linux distribution, you may get a "failed to open stream: Permission denied in ..." message. In fact changing the permission of the directory will not work (even if you set to 0777).
It is because of the new SELinux kernel that allow apache user to write only in /tmp dir (I think). In order to solve the problem you must to disable the SELinux (at least for apache service) to allow the server to write in other directories. To do that, run the system-config-securitylevel app and disable the SE to apache service. Reboot your system and continue your work.

Permission denied in Apache instead of 777

I am having a hard time deploying a PHP website built using Grav on CentOS.
Whenever I try to open the website I get 500 Server Error. The logs say:
Uncaught exception 'RuntimeException' with message 'Creating directory '/var/www/html/glug_site/cache//compiled/files' failed on error mkdir(): Permission denied' in /var/www/html/glug_site/vendor/rockettheme/toolbox/File/src/File.php:420\nStack trace:\...
I followed the guide mentioned here but it didn't helped.
Then, I did chmod 777 -R glug_nith/ but still it doesn't work. I even logged into apache user using sudo -u apache bash to see if I am able to create folders and files inside myapp and I was successful. I tried deleting the .htaccess file to see if that would help but it didn't.
I cannot understand instead of having all the permission why its showing permission denied. Also I couldn't find any thing that might be blocking the permission. Please help.
try uncommenting the 12th line in ur .htaccess file
Modify this
# RewriteBase /
to
RewriteBase /

Permission denied while using PHP Mail using Postfix

I have installed postfix and dovecot properly and did all configurations as per this guide: http://www.krizna.com/ubuntu/setup-mail-server-ubuntu-14-04/
But when I try sending mail via terminal like:
sudo php -r "mail('xyz#xyz.com', 'test', 'test');"
It gives me the error
sh: 1: /etc/postfix: Permission denied
I tried doing chmod -R 777 to the /etc/postfix directory and I still get the same error.
What should I do to get this working? I just want to send mail from my server to other mails like Gmail (i.e. xyz#xyz.com to abc#gmail.com)
I have even configured the mx records and a records in my dns manager.
If I see the Postfix log, I have this:
Feb 2 12:30:33 myhost postfix/pickup[16695]: ED7A120FD3: uid=33 from=<www-data>
Feb 2 12:30:33 myhost postfix/cleanup[4891]: ED7A120FD3: message-id=<20160202173033.ED7A120FD3#xyz.com>
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual lookup error for "xyz#xyz.com"
Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: ED7A120FD3: virtual_alias_maps map lookup problem for xyz#xyz.com -- message not accepted, try again later
I am using PHP 7 running Apache 2 on Ubuntu 14.04
(Note: Postfix and dovecot seems to be working cause I did telnet as given in the tutorial and got the correct response.)
You forgot to run sudo postmap /etc/postfix/virtual.
Got my problem solved. The permission error occured only when accessing Postfix from terminal. It works when accessed from PHP script.
Moreover, I had to modify PHP.ini sendmail path which I set as /etc/postfix before.

"End of script output before headers" on CentOS, but working on other LAMP stacks

I've set up a Centos 6 + CPanel 11 VPS, and everything is as it was out of the box. I've installed Phorum 5.2.20 in the public_html directory, but Phorum is causing an error 500. The error log reports:
[Mon Jul 27 11:21:57.770447 2015] [core:error] [pid 14342] [client x.x.x.x:42531] End of script output before headers: admin.php
The code works fine on my Debian LAMP server (and several other non-Centos/CPanel LAMP stacks I've used to test this), and Wordpress and some other stuff runs fine on the CentOS machine.
I've tried other code too, and it works on my other servers, but doesn't work on CentOS. Phorum is the only code that matters, so I made question focuses on that. I'm also reluctant to edit the core files of Phorum.
Any ideas?
Fixed: Permission Issue
I have also faced the same issue after installing fresh installation on VPS, later I found It's a permission issue, Directory should be 755 and files should be 644 then only it works.
sudo chmod -R 755 projectfolder
sudo chmod -R 644 index.php //projectfiles
I think there is an issues with the php handler. Can you please try to change your php handler through WHM >>Service Configuration >> Configure PHP and suEXEC and check your URL again.
For me the error was caused by file permissions. Luckily it was just the one file causing it so I used the same permissions as the working .php files and it worked.
In my case 644 worked with enough permission to run and not too much to trip the security settings.
I had same error for more than a day finally i found out that accidentally my /home/mysite_username/fcgi-bin/php7.0.fcgi file owner and group was changed to root. Restoring owner to mysite_username solved this issue. (I'm using Virtualmin)
Fix permissions from User Account Menu of CWP.

Apache Server Throwing 500 Internal Server Error

I had a LAMP application running wordpress and I deleted the whole directory and replaced with new files - php based.
Now, when I go to view my server running CentOS - it just shows a 500 Internal Server error.
I've tried:
restarting server
restarting apache service itself
both completed successfully, but this didn't fix anything. Now, I do not know where to go from here.
apache logs # /usr/local/apache/logs/error_log on apache:
[Tue Apr 22 11:12:15 2014] [error] [] SoftException in Application.cpp:357: UID of script "index.php" is smaller than min_uid
I found the fix myself, this wasn't an error with Mysql at all, but rather a permissions issue with the index.php file I had.
The error, which I found in /usr/local/apache/logs/error_log was:
:is smaller than min_uid Premature end of script headers: index.php
To fix, I did this:
ls -l in the directory causing the issue (mine was public_html)
You should see the index file (e.g. index.php) that should be causing the issue. It is due to a root user having the only permission to the file and not your CPanel (or system) username. (note this system/cpanel name)
Run the following within the errorneous directory(Note: this command must be run within all subdirectories of the primary errorneous directory.):
sudo chown yoursystemuserhere:yoursystemgroupuserhere index.php
or to apply to the whole directory (thanks to #Prix):
sudo chown -R user:group /folder
You're all set.
Further literature here: http://www.inmotionhosting.com/support/website/general-server-setup/uid-smaller-than-min-uid
I hope this helps someone else in the future.
I had similar symptoms on my cPanel VPS - I was able to use easyApache to recompile Apache and PHP which fixed the problem for me.
(I realise my problem was slightly different to yours, but it may be helpful for people in the future who have the same problem I had).
chown -R user.usergroup /path_to_the_directory
Will resolve this. It is basically permission issues.
just install wordpress latest version make sure you have atleast php version 5.3 and above also look global register variable if it off or just delete htacess file from server and see what will happens
generally 500 internal server gives when file permission is missing so you should delete htacess file

Categories