I am use apache with virtual host as my server. I also use yeoman to generate angular app template. For some reason, when I launch my site, I can see the index page but the console gave me 403 forbidden errors all on bower components like bootstrap, angular.js...etc. I am not sure what I did wrong. Can someone help? Thanks!
my V-host file
<VirtualHost *:80>
ServerAdmin myname#gmail.com
DocumentRoot "/Users/John/testproject/app"
ServerName testproject.localhost
ErrorLog "/private/var/log/apache2/testproject-error_log"
CustomLog "/private/var/log/apache2/testproject-access_log" common
<Directory "/Users/John/testproject/app">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
My project structure.
testproject
app
bower_components <-symlink
bower_components
angular <----403 error
bootstrap <----403 error
...etc
Gruntfile.js
Bower.json
My url on the browser
testproject.localhost
Thanks for the help!
You need to move your project under /var/www/ directory as /User directory is not accessible to apache2 and after moving folder check permission
and set permission to 777
sudo chmod -r 755 folder_path
if still don't work set it to
sudo chmod -r 777 folder path
and restart apache2. Also don't forget to change path in apache2 config file.
Related
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.
In the past month I work on pure php laravel framework which the project is already done and running on live. This month our team asking for revising the project to reactjs with laravel php framework. Which the development stage is already done this past few weeks. Our team trying to deploy in production in which they encounter one problem when we access the website Ex. www.myproject.com the page show the root project folder it look like this.
Note: That my project is fresh and we not configure anything to htaccess.
The scenario before i deploy the project:.
npm install
then
npm run production
to get the final index.js file which will contain all the code bundled
Package.json:
Webpack.config.js
Web server
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
<Directory "/var/www/appname/public">
Options FollowSymLinks
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Source
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
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.
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