Unable to acess site on port 80 via apache2? - alibaba-cloud

I have installed CMS and using the following configuration
<VirtualHost *:8080>
ServerAdmin admin#example.com
DocumentRoot /var/www/html/chamilo
ServerName 127.0.0.1
<Directory /var/www/html/chamilo/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have also tried different configurations
<VirtualHost *:80>
I have given Servername 127.0.0.1, localhost, 0.0.0.0 but none of them seems accessible.
Any help is appreciated... Thanks

Allow Port 80 Rule
Add a rule to the security group of the instance allowing PORT 80 on 0.0.0.0/0 CIDR Block and it should work.

I would suggest reviewing port 80 in your security groups and simply running curl.
curl http://localhost

Related

How to set up a virtual host on ubuntu

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>

Access forbidden either read protected or not readable

Currently I have multiple laravel project in my htdocs and configured like this
<VirtualHost *:0903>
DocumentRoot "C:/xampp/htdocs/svs_web_application/public"
ServerName localhost
</VirtualHost>
<VirtualHost *:0904>
DocumentRoot "C:/xampp/htdocs/api_tk/public"
ServerName localhost
</VirtualHost>
<VirtualHost *:0905>
DocumentRoot "C:/xampp/htdocs/svs_api/public"
ServerName localhost
</VirtualHost>
listen 0903
listen 0904
listen 0905
I can access these projects and do some stuffs.
Not until when I configured another laravel project with this kind of setup
<VirtualHost *:0902>
DocumentRoot "C:/xampp/htdocs/pinoytravelreseller/public"
ServerName localhost
</VirtualHost>
listen 0902
And I got this kind of error
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server
Tried to include this setup
<VirtualHost *:0902>
DocumentRoot "C:/xampp/htdocs/pinoytravelreseller/public"
ServerName localhost
<Directory "C:/xampp/htdocs/pinoytravelreseller/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
listen 0902
But still doesn't work is there any configuration do I need to do?
is there any files on that folder,
can you access by the way like localhost:902/demo.php,
demo.php just a php which say a 'hi',
if it cannot run and say 'hi' well,
I think you need to check is there any htaccess file on the root of project folder

How to point two website in windows wamp server with same ip

I have two websites www.test1.com and www.test2.com.I hosted both sites in windows wampp server with same IP called xx.xxx.xx.xx .But while opening both sites www.test1.com is comming.Here www.test1.com files are in 'test1' folder and www.test2.com are in 'test2' folder.
I Tried virtual host in wampp...but its not working...
This is my \wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test1"
ServerName test1
ServerAlias test1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test2"
ServerName localhost
ServerAlias test2.com
<Directory "c:/wamp/www/test2">
AllowOverride All
Require local
Require all granted
Allow from all
</Directory>
</VirtualHost>
This is my C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 localhost
127.0.0.1 test1.com
127.0.0.1 test2.com
Both your domain names are going to the site defined first in the httpd-vhost.conf file because that is the default behaviour when Apache cannot find a site requested in the host definitions. It normally means you have done something wrong in the defining of your VHOSTS.
Your host definitions are a little wrong, and you are mixing Apache 2.2 and 2.4 security syntax which often causes problems, try these
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
<Directory "C:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test1"
ServerName test1.com
ServerAlias www.test1.com
<Directory "c:/wamp/www/test1">
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/test2"
ServerName test2.com
ServerAlias www.test2.com
<Directory "c:/wamp/www/test2">
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
Now so that you can see the sites locally on the WAMPServer PC the hosts file should look like this. Remember, these entries only effect the PC containing the HOSTS file, and have no effect on internet access or the ability of a remote user to use these domain name.
# IPV4 loopback
127.0.0.1 localhost
127.0.0.1 test1.com
127.0.0.1 test2.com
# IPV6 loopback
::1 localhost
::1 test1.com
::1 test2.com
The first line needs to be
NameVirtualHost *:80

Setting up more Virtual Hosts on Webmin

i bought VPS and i installed 3 websites. All websites are loading files from one directory( but i set the different while i was creating ).
After putting DNS without making Virtual Hosts, site already loads default web site(first one), after creating virtual host, still the same.
<VirtualHost *>
DocumentRoot /home/svezatebe-online.com/www/
ServerName svezatebe-online.com
<Directory "/home/svezatebe-online.com/www/">
allow from all
Options FollowSymLinks
</Directory>
ServerAlias www.svezatebe-online.com
</VirtualHost>
<VirtualHost *>
ServerName wasdlife.com
<Directory /home/wasdlife.com/www>
allow from all
Options None
</Directory>
ServerAlias www.wasdlife.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /home/online-vesti.net/www
ServerName online-vesti.net
<Directory "/home/online-vesti.net/www">
allow from all
Options None
</Directory>
</VirtualHost>
I would consider some examples from: https://httpd.apache.org/docs/2.4/vhosts/examples.html especialy try to adjust your config according to example below:
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
For testing you can try to do a quick changes in your hosts file to try localy instead of having to do a DNS changes like mentioned at the link above:
Creating virtual host configurations on your Apache server does not
magically cause DNS entries to be created for those host names. You
must have the names in DNS, resolving to your IP address, or nobody
else will be able to see your web site. You can put entries in your
hosts file for local testing, but that will work only from the machine
with those hosts entries.

After adding vhosts definiation xamppfiles/htdocs is invisible on http , but still accessible through https

I have vhost like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName local.testing.com
DocumentRoot "/Users/myname/Sites/myapp"
DirectoryIndex index.html
<Directory /Users/myname/Sites/myapp>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
hots files
127.0.0.1 localhost
127.0.0.1 local.testing.com
::1 localhost
after enabling this vhost , i am unable to access any of the sites under xampp/htdocs through http. But they are accessible through https
when I access localhost it shows directory listing for :"/Users/myname/Sites"
plz help me sort out this issue ,
thanks in advance
so the issue was that we need a virtual host for localhost e. g like this SOQ
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
ServerAlias localhost
ServerName localhost
</VirtualHost>

Resources