I've created and installed Apache on amazon EC2 few times before.
But this time I cannot seems to get apache to run the code that I put on a Volume I created and mounted on /data1/
I use the following 000-default.conf in my /etc/apache2/sites-available that is already enabled
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
RewriteEngine On
ServerAdmin webmaster#localhost
#DocumentRoot /var/www/html/web
DocumentRoot /data1/proj/ba/web
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /data1/proj/ba/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
And I get http://ec2-54-197-1-250.compute-1.amazonaws.com/
Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at
ec2-54-197-1-250.compute-1.amazonaws.com Port 80
I tried
sudo adduser $USER www-data
sudo chown -R www-data:www-data /data1/proj
sudo chmod -R g+rw /data1/proj
and also other variation of these cmds
Now the strange thing is that if I change the DocumentRoot to /var/www/html/web
and create a symlink sudo ln -s /data1/proj/ba/web/ /var/www/html/web
than it is working! this is ok for now but in the future it might be a problem for me.
Any idea what i'm doing wrong?
here is the new format:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName myproj.co.il
ServerAlias www.myproj.co.il
RewriteEngine On
ExpiresActive On
CustomLog /var/log/apache2/access.log vhost_combined
DocumentRoot /data1/projects/myproj/
<Directory /data1/projects/myproj/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
<FilesMatch "\.(gif|jpg|png|js|css)$">
ExpiresDefault "access plus 1 month"
</FilesMatch>
</Directory>
</VirtualHost>
Note the Require all granted line that replaced the
Order allow,deny
allow from all
Related
I'm looking for a way to use multiple DocumentRoots on the local Apache server of MacOs Monterey. localhost works very well but for the other locations I have an error "Forbidden You don't have permission to access this resource."
I tried to use VirtualHost but it doesn't work
httpd.conf
ServerName localhost:80
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options None
Require all granted
</Directory>
Include /private/etc/apache2/other/*.conf
extra/httpd-vhosts.conf
# Virtual Hosts
Listen 80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin example#example.com
DocumentRoot "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur"
ServerName iut.local
# ServerAlias iut
ErrorLog "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur/crash_log/Error"
CustomLog "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur/crash_log/Custom" common
<Directory "/Users/TooikLeChevalier/Documents/IUT/S3/Prog-Web-Serveur">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin example#example.com
DocumentRoot "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev"
ServerName eclypsegames.local
ErrorLog "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev/crash_log/Error"
CustomLog "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev/crash_log/Custom" common
<Directory "/Users/TooikLeChevalier/Documents/Perso/EclypseGames/Local_Dev">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
../hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 iut.local
127.0.0.1 eclypsegames.local
I have enclosed with you all the documents that could be useful in solving my problem.
Thanks in advance for your help
I am trying to make to move to use Ubuntu for developing. I am working on an exciting Laravel project that is due to go live at the end of the month. I have cloned the repro and now trying to set up a virtual host ( my understanding is that you need this for the site work properly locally ). I have followed this video: https://www.youtube.com/watch?v=lkLAJd-Wb80&t=6s. But all I am getting is a 404 page not found. Hope someone can help with this.
<VirtualHost *:80>
<Directory /var/www/html/myapp/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName myapp.test
ServerAdmin info#myapp
DocumentRoot /var/www/html/myapp/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have also added myapp to the hosts file.
You missed the public directory while defining the path in <Directory>. It should be something like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin info#myapp
ServerName myapp.test
ServerAlias myapp.test
DocumentRoot /var/www/html/myapp/public
<Directory /var/www/html/myapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Hope this helps you.
Could you try with listening to 80 port like below?
Listen 80
<VirtualHost *:80>
<Directory /var/www/html/myapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName myapp.test
ServerAdmin info#myapp
DocumentRoot /var/www/html/myapp/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My virtual host configuration is like bellow where I used 8080 port.
Listen 8080
<VirtualHost *:8080>
ServerAdmin info#gmail.com
DocumentRoot "D:/appinstall/htdocs/www/app-test-server/public"
ServerName localhost
ErrorLog "logs/app-test-server.log"
CustomLog "logs/app-test-server.log" common
</VirtualHost>
I have set up apache virtual host and have a site with below config (the website is working well):
NB: The domain names below fictitious.
<VirtualHost *:80>
ServerName www.bill.test.com
ServerAlias bill.test.com
Redirect / https://bill.test.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.bill.test.com
ServerAlias bill.test.com
DocumentRoot /applications/www/bill.test.com/public_html/public
SSLEngine on
SSLCertificateFile /home/user1/ssl_certificate/test.com/wildcard_eneoapps_com.crt
SSLCertificateKeyFile /home/user1/ssl_certificate/test.com/wildcard_eneoapps_com.key
SSLCertificateChainFile /home/user1/ssl_certificate/test.com/DigiCertCA.crt
ErrorLog /applications/www/bill.test.com/error.log
CustomLog /applications/www/bill.test.com/requests.log combined
<Directory "/applications/www/bill.test.com/public_html/public">
AllowOverride All
</Directory>
</VirtualHost>
Also, on this server I have an API located in the directory below:
/applications/www/html/ebill-api
Now when I try to call this API in the code, I get the error below:
Client error: `POST http://12.ipp.106.21/ebill-api/public/api/login' resulted in a `404 Not Found` response:\n
My httpd.conf file looks like below:
DocumentRoot "/applications/www/html"
#
# Relax access to content within /var/www.
#
<Directory "/applications/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
Please help as I am new to configuring apache and confuse why this doesn't work. I was able to call an API on a separate
server but I don't understand why calling this one which is on thesame server as the website is not working.
Since you have the Laravel api in a subfolder, you should adjust the APP_URL in your .env file to be http://12.ipp.106.21/ebill-api/public/
Try this change. See if it help.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot C:/Users/user/Desktop/WebsiteDesign
ServerName testproject
<Directory "C:/Users/user/Desktop/WebsiteDesign">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I have gone to C:\xampp\apache\conf\extra\httpd-vhosts.conf and changed the values.
After making the changes I went to C:\Windows\System32\drivers\etc\host
Also following all these steps I stopped and started Apace Service from the XAMPP control panel. Still it's not working. I have also given the httpd-vhost.conf file. Can someone please guide me to configure step by step. my xampp version is 3.2.2
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry
about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot C:/Users/user/Desktop/WebsiteDesign
ServerName testproject
<Directory "C:/Users/user/Desktop/WebsiteDesign">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Issue:
I have Laravel running on Apache 2.4.9 and my domains are organized as follows:
beta.domain.com => /var/www/beta
www.domain.com => /var/www/live
The beta subdomain has basic authentication. Everything is working as expected except when I started poking around the apache2 error logs. I get the following error message:
AH01797: client denied by server configuration:
/var/www/beta/public/index.php, referer: https://beta.domain.com/
My setup:
Here is my setup:
<VirtualHost *:80>
# Redirect all http traffic to https
Redirect 301 / https://www.domain.com/
</VirtualHost>
<VirtualHost *:443>
# some SSL setup for www here
ServerName www.domain.com
DocumentRoot /var/www/live/public
<Directory /var/www/live/public>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv ENVIRONMENT "live"
</VirtualHost>
<VirtualHost *:443>
# some SSL setup for beta here
ServerName beta.domain.com
DocumentRoot /var/www/beta/public
<Directory /var/www/beta/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
# allow from one ip
Allow from xxx.xxx.xxx
Satisfy any
AuthUserFile /path/to/htpasswd/.htpasswd
AuthName "Password required"
AuthType Basic
Require valid-user
</Directory>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnv ENVIRONMENT "beta"
</VirtualHost>
Failed attempts:
I've found several differing answers for this, none of which worked for me. These are the ones that seem the most convincing, but again they didn't work for me.
Replacing <Directory> with <Location> tags (http://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicprovider) - the errors were gone, but I lost basic authentication
Using Require all granted instead of Order allow/deny - this also
removed basic authentication for me. Also not sure if this makes
sense in my scenario.
Because I'm using Apache 2.4+, I changed
Order allow, deny
Allow from all
to simply
Require all granted
This fixes the error message, but to allow for basic authentication on the beta subdomain, I also had to remove Satisfy any
So the set up for beta would be changed to this:
<Directory /var/www/beta/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
# removed in 2.4
# Order allow,deny
# allow from one ip
Require ip xxx.xxx.xxx
# No longer require Satisfy any in 2.4
# Satisfy any
AuthUserFile /path/to/htpasswd/.htpasswd
AuthName "Password required"
AuthType Basic
Require valid-user
</Directory>