Apache website permissions under Centos 7 - php

I have a site in dir /home/nbo/mysiteA. (nbo is the user)
I've create a new dir structure /var/www/mysiteB/public_html
public_html is a symlink to /home/nbo/mysiteA
httpd.conf settings:
Listen 82
<VirtualHost *:82>
ServerName mysite.com
DocumentRoot /var/www/mysiteB/public_html/
DirectoryIndex index.php
<Directory "/var/www/mysiteB/public_html/">
Options +FollowSymLinks -SymLinksIfOnwerMatch
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
When I test the website I get a 403 error (Forbidden You don't
have permission to access /index.php on this server.)
I've already tried to add the nbo user to apache group.
I've already tried to change the ownership of the entire site to apache user.
What I'm missing?

Related

whoami returns apache instead of root

I'm trying to serve an application from location /usr/local/administer/. There is a index.php file inside /usr/local/administer/index.php inside that index.php file is the following code
echo exec('whoami');
The result from the above code is apache however the result should be root as per my configuration in the vhost using mod-ruid2
administer.conf
The following is the configuration that I'm currently working with.
<Directory /usr/local/administer/web>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /usr/local/administer/
ServerName administer.com
ServerAlias www.administer.com
RMode config
RUidGid root root
RGroups root
</VirtualHost>
Any suggestions or advise?
As Mike 'Pomax' Kamermans has mentioned in the comment that not to run any task via PHP with root user. You'll get into trouble. If you are logged-in as root and running whoami via PHP then root won't show up. I'm not sure why this is happening. A possible solution in my preference is:
Create another user
Replace root with the new username
Restart Apache

drupal website locahost subdirectories pages 404 error

I have created a virtual host for a drupal website on Windows 10 using Bitnami (WAMPstack),
and when start the website , i can access to the home page only but not to sub pages or sub-directories.
in the windows etc folder i did update the hosts file and added
127.0.0.1 website.local
also edited the httpd.conf enabled the virtual host
(Include conf/extra/httpd-vhosts.conf)
also edited the httpd-vhosts file : added the follwoing
<Directory C:/vhosts>
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/Bitnami/wampstack-7.1.15-0/apache2/htdocs/website/"
ServerName website.local
</VirtualHost>
when i start browsing the site and click on any subpage i got a 404 (Not Found)
please advise.
Seems like you are missing some directives on the directory level. Here is a config that works that basically follows https://www.drupal.org/node/953296#comment-9866119
<VirtualHost *:80>
DocumentRoot /home/myrepo/mydocroot
ServerName mysite.localhost
<Directory /home/myrepo/mydocroot >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
You might need to activate the mod_rewrite in apache.
Edit the httpd.conf and search for "#LoadModule rewrite_module modules/mod_rewrite.so" remove the "#". Save and restart the apache.

Downloaded Files Are Not Working on Apache DocumentRoot

I'm serving my pages with Apache 2.4 on a Ubuntu Mate OS. I've been building a system that allows my clients to download many files from a directory which has been created by each one of them at the moment they sign in.
Apache DocumentRoot is /var/www/public_html and Downloads process works fine in it but by the time I create a folder CLIENTS (absolute path: /var/www/public_html/CLIENTS/) file downloads arent working as they should. There`s just a message saying "Failed - No File" on incoming files.
I've already changed Directory permissions with chown on Linux, changed masks as well as checked Apache configuration using Directory directives but no results! Apache settings below:
VIRTUAL HOST CONFIGURATION
<Directory /var/www/public_html/CLIENTS/>
Options -Indexes +FollowSymLinks +Multiviews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
APACHE2.CONF
<Directory /var/www/public_html/CLIENTS/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
LINUX PERMISSIONS
drwxrwxrwx 3 www-data www-data public_html

403 Forbidden error on Genymotion

I installed genymotion emulator on my PC and I want to access my WAMP local server to it and I ran ipconfig on my cmd so I got this IP_address 192.168.56.1 but the problem is that I always get this error
403 Forbidden
You don't have permission to access / on this server
I tried all the answers given in this question yet none solved my problem.
I am running
Mysql 5.5.8,
PHP 5.3.5 and
Apache 2.2.17
Please do anyone know how I can fix this error?
#KANAYOAUSTINKANE. This is my code or the Subdomain
<Virtualhost *:80>
DocumentRoot "C:/wamp/www/mobile"
ServerName localhost
ServerAlias m.local host
</Virtualhost>
Please help me out, I have been so disturbed
Okay, here is a solution.
First step
Change the location of your virtual host and add a / at the end like this
DocumentRoot "C:/wamp/www/mobile/"
Second step
Go to your httpd.conf file located at C:/camp/bin/apache/Apache2.2.17/conf/httpd.conf the go to the line that has Listen 80 and change it to Listen *:80 this will make it to listen to any IP address
Finally
You go to the end of your httpd.conf file and add this
# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
# Tells Apache to serve your mobile pages to "m.localhost"
<VirtualHost 127.0.0.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
#Here you duplicate the code for your mobile site to also accept your IP address which is 192.168.56.1
<VirtualHost 192.168.56.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
Tested and working. Please don't forget to mark the answer

Forbidden 403: Able to access localhost but unable to access folders within

I am able to access localhost and a folder inside it (http://localhost/ariaconfig/) but am unable to go further.
I am trying to access /Library/WebServer/Documents/ariaconfig/rest
I have given access permission of read and write and also made the folder shared (using mac).
In my httpd.conf :
have altered these lines but of no use.
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks Includes ExecCGI
MultiviewsMatch Any
Order deny,allow
AllowOverride All
Require all granted
</Directory>
In my httpd-vhosts.conf have added:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /Library/WebServer/Documents
ServerName localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>
In error_log getting error as:
Cannot serve directory /Library/Webserver/Documents/ariaconfig/rest/: No matching DirectoryIndex (index.html,index.html,index.php,index.html,index.php) found, and server-generated directory index forbidden by Options directive
Thanks.
I think there is a spelling mistake in your httpd-vhosts.conf
DocumentRoot /Library/WebServer/Documents
this should be Webserver instead of WebServer S should be small as per your rules
If thats not the case , please check index.html or index.php persist in your Document Root , If not please create it with some dummy html file . That would be the starting point for any web browser .
Check out this wiki article on webserver directory index
Added Options +Indexes in httpd.conf.

Categories