unable to create alias in apache - apache2

I'm new to Apache. Following a tutorial, I am trying to set an alias in Apache to look and serve files from a folder (project). Other than htdocs, this was my code to create alias:
<IfModule alias_module>
Alias /project/ "C:/project/"
Alias /project "C:/project"
</IfModule>
<Directory "C:/project">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
This doesn't work and when I type localhost/project/ in browser, the browser throws access forbidden.
How do I work around it?

You'll have to change your security settings on C:\xampp\apache\conf\httpd.conf
The directory diretive must be on this file or it will always show the forbidden error.

Related

Alias on apache2 on laradock on mac not working

I need to access video files on an external drive attached to my mac where I have a Laravel project hosted with laradock. I followed the instruction given in this tutorial.
So I put added the alias/directory lines in laradock/apache2/sites/default.apache.conf. Is that the correct file and location?
<VirtualHost *:80>
ServerName laradock.test
DocumentRoot /var/www/
Options Indexes FollowSymLinks
<Directory "/var/www/">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
Alias "/video" "/Volumes/DiskX/video"
<Directory "/Volumes/DiskX/video">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Then following the instruction I change ownership of the folder content in Terminal.
sudo chown -R www-data:www-data /Volumes/DiskX/video
sudo chmod -R g+rw /Volumes/DiskX/video
But got an error chown: www-data: illegal group name. So what is the correct group name on my environment? And is that change of ownership necessary if I only need read access to the video files?
When I place a image.png file inside the DiskX/video folder and try to access that image in a blade.php page in the project, the image is not displayed (404 error).
I also want to add that I need full access to read any file in any of all the nested folders inside video folder.
I would appreciate some help.

CakePHP can not find webroot/css/js files

I just download via svn controle version a CakePHP 2.5.2 app to a test server .
After database configuration, the app does not open the css files located at app/webroot dir (bootstrap, jquery, main.css).
Is the some aditional config parameter ?
I try changing the owner but did not work.
It looks like a mod_rewrite problem.
Make sure you have .htaccess in your DocumentRoot, and your Apache server is configured properly.
Everything is described in detail in the CookBook.
CakePHP 2.x URL Rewriting
Edit: As described in the comments, it was solved by the OP by replacing the Directory definition in the apache vhost configuration file (/etc/apache2/sites-available/default.conf) with the following:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo
Order Allow,Deny
Allow from all
</Directory>

Apache2 - Error 403 forbidden

I develop projects that I've located in /home/user/projects directory. This directory is chmod 777. The problem is that I'm always getting Error 403 Forbidden when I try to access this directory or any subdirectory. This is how my /etc/apache2/sites-available/000-default.conf looks like:
<VirtualHost *:80>
ServerName localhost
ServerAdmin user#user.com
DocumentRoot /home/user/projects
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options +FollowSymLinks
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/gtakacs/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
What's wrong with this? When I used /var/www as my document root, everything worked.
EDIT : try doing chmod -R 777 /home to make sure all your home is available (note that this solution is NOT RECOMENDED, having your project in /var/www would definitely be a better solution in my opinion)
(Can't comment so post reply)
Isn't there a config file in your project where you're supposed to set who can access the app? Check if you didn't forget to add your ip adress and domain name in this file.
When using Apache2 with Django framework (python), I had the same error, and it was because I forgot to add the domain name to authorized hosts.
You can also check access.log and error.log to have more detailed informations on what caused the error.
Command out:
#Order allow,deny
I had this issue before, the problem might be that your document root does not contain the described directories.

Create laravel configuration file apache web server

to delete the public folder from my url I have seen that I have to edit the apache configuration file, but since I also have projects that are not developed with laravel I saw that there is the possibility to create a custom configuration file. Where should I put this file?
You could set up a virtual host to serve as your laravel project like below.
Just edit your Apache's httpd-vhosts.conf file and add something like:
<VirtualHost *:80>
ServerName project-laravel
DocumentRoot "YOURPATH/apache2/htdocs/project-laravel/public"
<Directory "YOURPATH/apache2/htdocs/project-laravel/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also you would have to edit your hosts file and add a line
127.0.0.1 project-laravel
Then, restart Apache and enter the project-laravel into your browser bar.

Apache virtualhosts and default server not working as expected (serving incorrect content)

I've been playing around with this for a couple of hours and have come to the conclusion that asking someone is probably the best way forwards!
I have a fairly out-of-the-box apache install (I've added mod_security and mod_python) so not touched /etc/httpd/conf/httpd.conf
I have a number of domains all running as 's and each with its own individual config file. They are all working as expected except for the fact that any unrecognised hostname will serve the content from the first virtualhost (which I know is the expected behaviour as the content from the first virtualhost is served)
I would like to set up a default set of content to be served if someone reaches my server through an unknown hostname - but in doing so, the first site now also serves this default content which I can't seem to find a reason for.
All of the config files for the individual sites are located in /etc/httpd/conf.d/sites (so that the are not auto-included) and are then included through a file (/etc/httpd/conf.d/sites.conf) which I created - before trying to set up the default server, its content is this:
Include conf.d/sites/*.conf
I modified it to be this to try to get the default server working:
<VirtualHost _default_:80>
DocumentRoot /home/sites/DEFAULT
<Directory "/home/sites/DEFAULT">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Include conf.d/sites/*.conf
Just to re-iterate the problem - when the second version of sites.conf is active, the first VirtualHost also serves this content; the rest are fine. All of the sites' config files are syntactically correct and have no typos in the ServerNames.
(For reference, I have included the config file for the offending site - stored in /etc/httpd/conf.d/sites/DOMAIN.clintonmontague.co.uk.conf)
<VirtualHost *:80>
DocumentRoot /home/sites/clintonmontague.co.uk/www
ServerName clintonmontague.co.uk
LogLevel emerg
CustomLog /home/sites/clintonmontague.co.uk/_logs/access_log "combined"
<Directory "/home/sites/clintonmontague.co.uk/www">
AllowOverride none
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Sorry for the overly-long question!
Other info: Apache 2.2, CentOS 5, MediaTemple (dv)
If what you say in your answer is correct, then try this. Note the ServerAlias line which should work instead of the PHP code:
<VirtualHost *:80>
DocumentRoot /home/sites/clintonmontague.co.uk/www
ServerName clintonmontague.co.uk
ServerAlias www.clintonmontague.co.uk
LogLevel emerg
CustomLog /home/sites/clintonmontague.co.uk/_logs/access_log "combined"
<Directory "/home/sites/clintonmontague.co.uk/www">
AllowOverride none
allow from all
Options +Indexes
</Directory>
</VirtualHost>
Just for reference - it appears that the problem was because /etc/sysconfig/network reported my HOSTNAME as clintonmontague.co.uk (which happened to be the first domain alphabetically). Therefor, default included that domain name so the default content was being served.
Thought I'd post the answer in case anyone was having similar problems :)
Not possible to change this in MediaTemple (every time the (dv) restarts, it resets this value)
I fixed it by including this line in the default content's index.php
<?php
if ($_SERVER['SERVER_NAME'] == 'clintonmontague.co.uk' )
{
header ('Location: http://www.clintonmontague.co.uk/');
}
?>

Resources