Alias on apache2 on laradock on mac not working - apache2

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.

Related

403 Forbidden after changing DocumentRoot

So, I've tried running a domain, a sub domain and another domain on one machine. I've set up a conf file for every site:
<VirtualHost *:80>
ServerName websitea.com
ServerAlias www.websitea.com
DocumentRoot /var/www/html/weba
</VirtualHost>
<Directory /var/www/html/weba>
Order allow,deny
Allow from all
Require all granted
</Directory>
The same folder config can be found in apache2.conf as well (I tried experimenting with it) and it's the same config across all sites.
The issue is that after putting this DocumentRoot and disabling 000-default.conf I get 403 forbidden.
What I've tried doing so far:
Changing owner to www-data:www-data
Changing perms to 755/777
Putting the directory configurations in
apache2.conf or the website's conf putting all sites in 1 file
all kinds of directory settings (Options Indexes FollowSymLinks,
AllowOverride none/all, Require all granted, Allow from all, Order
Allow,Deny)
but none would work...
EDIT: I found out that the website goes to /www/var/html/ even though the domain is set to get to /www/var/html/weba, DocumentRoot pretty much does nothing in the configurations.
It seems you created a new virtual host configuration file on this path /etc/apache2/sites-available/
you need to enable the website virtual host conf file, for example, id website virtual host conf file name is 'websitea.conf'
then you need run below command
sudo a2ensite websitea.conf

Unable to deploy angularjs app in apache webserver using virtual hosts

This is on Mac OS X El Captain
I am trying to deploy a web application built in Angularjs on Apache web server.
The folder is created in /Users/username/Sites/7MinutesWorkout
For the same in order to enable virtual host, i uncommented the below line from httpd.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf
Also in httpd-vhosts.conf, included the below snippet
<VirtualHost *:80>
DocumentRoot "/Users/<username>/Sites/7MinutesWorkout"
ServerName 7MinutesWorkout.com
ServerAlias www.7MinutesWorkout.com
ServerAdmin <username>#dummy.com
ErrorLog "/private/var/log/apache2/7MinutesWorkout.com_error_log"
CustomLog "/private/var/log/apache2/7MinutesWorkout.com_access_log" common
<Directory>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Also made entry in /etc/hosts as
127.0.0.1 7MinutesWorkout.com
127.0.0.1 www.7MinutesWorkout.com
Restarted apache by the command sudo apachectl restart
But when i try to access the site, i get the error page, this site cannot be reached.
On executing the command
apachectl configtest
gives the output as AH00526: Syntax error on line 47 of /private/etc/apache2/extra/httpd-vhosts.conf:
Directory directive requires additional arguments
There is only one entry as of now in the httpd-vhosts.conf as specified above.
Please suggest
I think your issue is with the Require all granted which needs to be present.
Here is the relevant part of my config, which works
<Directory>
Options Indexes FollowSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
# onlineoffline tag - don't remove
Order Allow,Deny
Allow from all
# Allow from 127.0.0.1
# Allow from ::1
# Allow from localhost
</Directory>

error apache2 chmod 777 only works

I have my first server and i don't undeststand many things.
First, i've created one user called guillaume and create a specific folder in /home/web and put my website in there and it works BUT...
i've created a second website and it's work but only with chmod 777
i've made chmod -R guillaume:guillaume *
and chmod -R 777 *
but if i do
chmod -R 755 *
i've an error 500, file cannot be writed...
So i don't understand why i don't change permissons to 755, on my first domain it works well.
there is my vhosts:
<VirtualHost *:80>
ServerName bio.dev2prod.fr
ServerAdmin guillaume.batier#gmail.com
DocumentRoot /home/guillaume/web/bio.dev2prod.fr/public
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory /home/guillaume/web/bio.dev2prod.fr>
Options FollowSymLinks
Require all granted
Order allow,deny
allow from all
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
what am i doing wrong ?
PS: i put my user to www-data group ? it that good ?
Thanks and sorry for my bad english, i'm french..
PS: i'm using laravel 5 so the document root is in /public folder
The problem could be caused by several issues. So let me ask a few questions.
(if I'm not totally wrong) the first <Directory> directive points to the root directory. wich might not directly relate to your problem but are you sure to map any file? I guess it should be same as <DocumentRoot>
The <DocumentRoot> should be the base directory for the particular vhost. So the <Directory> path should normaly belong to a sub directory of the DocumentRoot.
If you wan't to use directories from outside the DocumentRoot mod_alias might be worth looking at.
Alias /somalias/ /path/to/somewhere/else
Hope this helps you a bit.

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.

How to fix ERROR: Site domain.com does not exist, while adding subdomain to apache2?

I'm trying to add subdomains to my home server.
svn.domain.com
trac.domain.com
Due to dynamic IP I use dyndns service, on top of that I have domain.com hosted somewhere else. I created CNAME for subdomains on remote host to point to my user.dyndns.org domain.
So now when I visit either of subdomains: trac or svn, I see "It works!" message.
This done, I created two virtual host files under /etc/apache2/sites-enabled
file1: svn.domain.com and file2: trac.domain.com
contents:
<VirtualHost *:80>
ServerName trac.domain.com
DocumentRoot = /var/www/trac/repos
<Directory /var/www/trac/repos>
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And
<VirtualHost *:80>
ServerName svn.domain.com
DocumentRoot = /var/svn/repos
<Directory /var/svn/repos>
Order allow,deny
allow from all
</Directory>
</VirtualHost>
But I get error: ERROR: Site trac.domain.com does not exist!
what am I doing wrong?
I had this problem when upgrading from Apache 2.2 to Apache 2.4. The (ridiculous) solution was to ensure all files end with .conf, or a2ensite would ERROR: Site example does not exist!.
Also, when linked manually in sites-enabled, they would not even load without the .conf extension.
I also came across the same problem when I upgraded from Apache 2.2 to 2.4; all my virtual hosts suddenly broke and while trying to search for why this was the case, I stumbled across this question.
It turns out the reason is because of a difference between my old apache2.conf and the new apache2.conf. My old Apache 2.2 conf file had the line
Include sites-enabled/
whereas my new Apache 2.4 conf file had the line
IncludeOptional sites-enabled/*.conf
Lo and behold, when I changed the line to
IncludeOptional sites-enabled/
everything went back to normal.
Try moving the files to /sites-available. Then run a2ensite svn.domain.com and a2ensite trac.domain.com and reload Apache.
if you type a2ensite. it will prompt. Which sites do you want to enable (ie., after you put a .conf file in the sites-available and link it from sites-enabled.
a2ensite expect the full name of the conf file with the .conf extension
a2ensite ONLY accepts .conf files, so copy all sites in sites-available so the have a .conf extension (renaming didn't work itconfused the linkssomehow), erase the original files from sites-available AND sites-enabled. use a2ensite on the new files (you don't need to add .conf) and it all works, with our without the *.conf in /etc/apache2/apach2.conf
There must be some "memory" of the original file even when it is renamed -the symbolic link renames also, butthe erases & enabling "new" .con files works and you can then use a2dissite and a2ensite as before
1) remove all default site inside sites-enable
a2dissite <site-configuration-file-name>
2) take a closed look at your config file: start with a minimum properties like:
<VirtualHost [Domain]:80>
ServerAdmin webmaster#localhost
ServerName [Domain]
DocumentRoot [webAppPath]
<Directory [webAppPath]>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/my_domain_name_error.log
CustomLog ${APACHE_LOG_DIR}/my_domain_name_access.log combined
</VirtualHost>
My solution for local server name is replacing:
sudo a2ensite serverName
with
sudo a2ensite serverName.conf

Resources