Apache alias directive - php

I am trying to set up simpleSAML.php but I am running into an issue with the Apache Alias directory. I have successfully used Alias so that when the user visits domain.com/auth then it uses the folder /var/saml/www.
However, for some reason it just lists the contents of the folder /var/saml/www rather than running the index.php file.
I have included the relevant virtual host below.
<VirtualHost *:80>
ServerAdmin helpdesk#domain.com
DocumentRoot /var/www/html/open
ServerName open.domain.com
ErrorLog logs/open.domain.com-error_log
CustomLog logs/open.domain.com-access_log common
Alias /auth/ /var/saml/www
Alias /auth /var/saml/www
<Directory /var/saml/www>
Options All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

You can add the following line to your config:
AddType application/x-httpd-php .php
This way apache knows it has to parse the files using php.
P.S. I think you may have to restart Apache rather than a reload.
Update
As Alfabravo commented:
Agree. He also needs to check the DirectoryIndex directive and add index.php to it

Related

Need some assistance with my apache2 site config file

I'm trying to get apache2 to point to a PHP based application (word press in this case but the config needs to be generic enough to work for any php application).
and it either displays some basic HTML file access page or errors with "You don't have permission". I don't really know apache and I don't know PHP at all. Here's my current site_config file as it stands(with retractions replaced with ):
<VirtualHost *:80>
ServerAdmin <app_user>#localhost
ServerName amazonaws.com/<app_name>
ServerAlias *.amazonaws.com/<app_name>
DocumentRoot /home/<app_user>/<app_location>/staging/current
<Directory /home/<app_user>/<app_location>/staging/current >
AllowOverride All
Options -Indexes
Order allow,deny
Allow from all
</Directory>
LogLevel error
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I would also like to make it so you can have multiple websites on the same box but I'm not sure how to change the VirtualHost arg *:80 to account for that, I just get loads of ignoring errors.
I also have the following line in my apache2.conf:
DirectoryIndex index.php index.html
Folder permissions are set to 0755 for all files & folders in the project directory
output of apache2 -v:
Server version: Apache/2.4.7 (Ubuntu)
P.s. I know nothing about PHP and very little about apache2 so for this, speak to me as a total noob.
To solve The first problem I had to change the following lines:
Order allow,deny
Allow from all
to:
Require all granted
this finally allowed apache to allow users access to the folders, the second thing was to add an alias:
Alias /<app_name> "/home/<app_user>/<app_location>/staging/current"
and it started working as expected so now my site config looks like:
Alias /<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
<Directory "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current">
AllowOverride All
Options -Indexes
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "/<app_name>"/home/<app_user>/<app_name>/<app_environment>/current"
ErrorLog "/var/log/apache2/<app_name>.error_log"
CustomLog "/var/log/apache2/<app_name>.access_log" combined
</VirtualHost>

Configure htaccess to symfony project

I have a hosting with my personal project in Symfony2 installed it inside a folder "public_html", then when I want to access to my project I have to write the next
url: "mydomian.net/myprojectSymfony/web/", instead of "mydomain.net".
If I just write mydomain.net the server shows me the directory "public_html" with all folders inside him. How can I write my .htaccess file to solve this problem?
I tried with Redirect 301 but I don't know if the right way.
In my opinion the best approach is to configure your apache vhost as explained there:
http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
<VirtualHost *:80>
ServerName mydomain.net
ServerAlias www.mydomain.net
DocumentRoot /var/www/myprojectSymfony/web
<Directory /var/www/myprojectSymfony/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

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.

Set static Laravel URL to domain name I purchased

I need to set my url for my site to appear as mydomain.com/ and have apache recognize that as the webroot.
Currently my url looks like:
###.###.##.##/laravel/public
and I want it to become:
mydomain.com/
This is the first site I've worked on from scratch, so I'm not completely sure what information I should include here.
Current apache httpd.conf:
NameVirtualHost *:80
NOTE: NameVirtualHost cannot be used without a port specifier
(e.g. :80) if mod_ssl is being used, due to the nature of the
SSL protocol.
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for requests without a known
server name.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/html/foo_bar/public
ServerName foo.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
<Directory /var/www/html/foo/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
First you'll need to edit your httpd.conf (usually located somewhere like /etc/apache2/conf).
Look for a line like <Directory "/var/www">. This is telling apache the root directory from which you want to work. /var/www in your case will be whatever directory laravel/public is living in on your websever currently.
If you change that line to <Directory "/var/www/laravel/public"> (assuming /var/www is where your laravel app is), save the file and restart apache, then you should be serving mydomain.com from inside laravel/public.

install CakePHP on Mac osx: apache problems

First time cake user and I'm having real apache problems. For some reason the .htaccess is trying to find
File does not exist: /Library/WebServer/Documents/Users
but there is no such directory as Users. I have tried setting up the following also:
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80 >
DocumentRoot "/Users/username/Sites/mysite/app/webroot"
ServerName mysite.dev
ServerAlias www.mysite.dev mysite.dev *.mysite.dev
<Directory "/Users/username/Sites/mysite/app/webroot">
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 mysite.dev
/etc/apache2/users/username.conf
<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
That also hasn't worked, but with a different error Failed opening required 'cake/libs/cache/file.php'
Although I'd rather not use virtual hosts, and just run it off localhost
Seems like the solution that worked for me was to edit /etc/apache2/users/username.conf and add this at the top:
DocumentRoot "/Users/username/Sites"
And the default cakePHP download now runs ok.
Looks like Apache is trying to find your webroot in a different location--the default location, if memory serves. If you want to use virtual hosts (which would be my recommendation, for whatever it's worth), ensure that the NameVirtualHost directive is uncommented. By default, it's commented out:
NameVirtualHost *:80
If you'd prefer not to use virtual hosts for whatever reason, ensure that the NameVirtualHost is commented out (your <VirtualHost> blocks will be ignored) and change the DocumentRoot value to the proper directory:
DocumentRoot "/Users/username/Sites/mysite/app/webroot"
That should tell Apache to look in the right place.

Categories