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>
Related
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>
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.
I have a Centos server, and I'm trying to configure php and apache, but I just can't get anything to work.
I'm have the next relevant info on my httpd.conf:
Listen 8088
Listen 8089
ServerName 192.168.124.243:8088
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *:8089
<VirtualHost *:8089>
ServerAdmin webmaster#bitacora.com
DocumentRoot /root/bitacora/public
ServerName bitacora.com
ServerAlias www.bitacora.com
DirectoryIndex index.php
ErrorLog /root/bitacora/log/bitacora-error_log
CustomLog /root/bitacora/log/bitacora-access_log common
<Directory "/root/bitacora/public">
Options Indexes FollowSymLinks
AllowOverride None
Require All
</Directory>
</VirtualHost>
My /var/www/html folder is empty, I only have remote access to the server, and I'm modifying configuration files through ssh and adding files through ftp.
When I type http://192.168.124.243:8088/ I get the default apache page, since I have nothing inside my html folder.
But if I try to access my virtualhost through http://192.168.124.243:8089/ I get the You don't have permission to access / on this server error and I get the Directory index forbidden by Options directive: /var/www/html/
error on my log file.
I read many post about this error and they mostly suggest adding Indexes to the /var/wwww/html directory, but it is there, and I have added the ports to the firewall exception, I've been trying to configure this thing for hours without success.
I have tried many many things, mainly many differents attempts on the httpd.conf file, but nothing seems to work.
Any ideas?
EDIT:
So it seems that the Directory index forbidden by Options directive: /var/www/html/ has no relation, I added an empty index.html to the /var/www/html folder and the error is gone, BUT I still get the You don't have permission to access / on this server error.
Now I've searched and played around cannot get my head around what is going on.
I am unable to install a local webserver (XAMPP or w/e) onto this laptop, so I am hoping to have a play with Laravel 4 directly on my dedicated box.
I have a Linux box (Debian) with Apache, Composer and PHP 5.4.4 installed. Plenty of other websites up and running on this.
I have installed Laravel 4, via Composer directly into a directory: public_html/dev/
Apache is set-up so the sub-domain dev.mydomain.com points to this directory.
Going to dev.mydomain.com, or dev.mydomain.com/public/ (anything in-fact) gives me a 403 Forbidden error.
My apache config file:
<VirtualHost (my ip)>
ServerAdmin webmaster#localhost
ServerName dev.mydomain.com
DocumentRoot /home/user/public_html/dev
Options -Indexes -FollowSymLinks -MultiViews
</VirtualHost>
I've tried chmod 777 to public, the document root to /home/user/public_html/dev/public but with no luck.
Unless I'm missing the point of something here, or some security problem (since working on a live server isn't great) then please tell me, I'm probably being a noob.
Try this
<VirtualHost *:80>
DocumentRoot /home/user/public_html/dev/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/user/public_html/dev/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
You had -FollowSymLinks, and i assume this applies to also the rewrite rule that comes default with laravel. (.htaccess file) removing the -Follosymlinks would have fixed it for you too i presume.
I am trying to install PHP-Laravel in Windows 8 and I am using Xamp server(localhost). I am following Installing Laravel guide.
According to this guide I am making virtual host using following code :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
//Where "C:/xampp/htdocs/TssApp/public" is path of Laravel public folder
and I have also added following line in in etc/hosts
127.0.0.2 TssApp
After doing necessary steps mentioned in this tutorial when I type "http://TssApp" , it always redirect to "http://tssapp/xampp/" instead of Laravel Home page. I don't know if I am missing any thing.
Note: I can access laravel home page at "http://localhost/tssapp/public/" but want
to use "http://TssApp" link to access my application.
Please help me regarding this issue.
Thanks .
Do you have NameVirtualHost * in your virtual-hosts configuration?
You'll need to restart Apache after any changes to either /etc/hosts or your virtual-hosts configuration files
Try adding the code to C:\xampp\apache\conf\extra\httpd-vhosts.conf instead of adding it to your own conf file. As far as I know xampp will ignore it unless its in the vhosts file.
You could try this.
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\TssApp\public"
ServerName tssapp
<Directory "C:\xampp\htdocs\TssApp\public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Although you should put your files in the xampp directory and not the htdocs directory, so your files should be C:\xampp\TssApp\public, This would stop people from visiting htdocs which is a public folder and getting access to your application.
According to the documentation (that you point to), you should write
<VirtualHost 127.0.0.2>
and not
<VirtualHost *:80>
Could you try that and restart your computer/server?
Add in:
Allow from all
after
AllowOverride all
The end result should be:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Allow from all
</Directory>
</VirtualHost>
Also make sure you are editing the file "httpd-vhosts.conf" found in:
C:\xampp\apache\conf\extra