Unable to load created virtual host in the browser - laravel

I want to create a virtual host for a laravel site. I followed the steps until sudo a2ensite www.staysure-wb.local.conf and it displays as the site is enabled. Site www.staysure-wb.local already enabled
But when I open the browser as www.staysure-wb.local it doesn't work.
I tried these commands after enabling site too. But it doesn't load in the browser.
sudo systemctl restart apache2
sudo service apache2 reload
sudo service apache2 restart
Here is my www.staysure-wb.local.conf file.
<VirtualHost *:80>
ServerName staysure-wb.local
ServerAlias *.staysure-wb.local
DocumentRoot /home/mayuri/Documents/projects/staysure-wb/public
<Directory /home/mayuri/Documents/projects/staysure-wb/public>
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.28:443>
SSLEngine on
ServerName staysure-wb.local
ServerAlias *.staysure-wb.local
DocumentRoot /home/mayuri/Documents/projects/staysure-wb/public
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
ErrorLog ${APACHE_LOG_DIR}/error.log
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#Header set X-Frame-Options SAMEORIGIN
<Directory /home/mayuri/Documents/projects/staysure-wb/public>
php_admin_flag engine on
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
RewriteOptions Inherit
Require all granted
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The site is available in /etc/apache2/sites-available as follows.
-rwxr-xr-x 1 root root 1240 Mar 26 10:02 www.staysure-wb.local.conf*
Here is the entry what I wrote in the hosts file:
126.0.0.1 localhost
127.0.0.28 www.staysure-wb.local
0.0.0.0 account.jetbrains.com
0.0.0.0 www.jetbrains.com
0.0.0.0 https://account.jetbrains.com:443
0.0.0.0 www-weighted.jetbrains.com
1.2.3.4 account.jetbrains.com
1.2.3.4 http://www.jetbrains.com
1.2.3.4 www-weighted.jetbrains.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
When I try to load www.staysure-wb.local in the browser url bar, it returns to Google search bar as follows. image
Help me to load the site in the browser. Thank you.

If you are sharing a screenshot of the error message that's more helpful to answer.
Did you use vagrant? If yes, The following steps are helpful to you.
Add the content in /etc/apache2/sites-available/www.staysure-wb.local.conf
Make ensure the project folder path is correct or not
<VirtualHost *:80>
DocumentRoot "/vagrant/locify/web"
ServerName locify.local
<Directory "/vagrant/locify/web">
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
Enable the conf file
sudo a2ensite www.staysure-wb.local.conf
Enable rewrite module
sudo a2enmod rewrite
Add the host entry in your local hosts file
<IP address> www.staysure-wb.local

Related

localhost is showing index of when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf

I installed apache with brew and changed port 8080 to 80. when I accessed localhost this shown me a page "it works!" and that page is located in /usr/local/var/www directory with file name index.html but when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf file.
<VirtualHost *:80>
DocumentRoot "/Users/ranaamir/projects/sample/yii2/backend/web"
ServerName yii2.example.be
ServerAlias yii2.example.be
<directory "/Users/ranaamir/projects/sample/yii2/backend/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</directory>
ErrorLog "/usr/local/var/log/httpd/vjfBackenderror.log"
CustomLog "/usr/local/var/log/httpd/vjfBackendaccess.log" common
</VirtualHost>
and restart the service with sudo apachectl -k restart command and this host also added in /etc/hosts.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 yii2.example.be
Then I access localhost or yii2.example.be both are showing a page where only one line mentioned Index of /.
if I remove code of block <VirtualHost *:80> from httpd-vhosts.conf then again localhost host showing correct index.html.
why my project not running on the virtual-host url instead of index of /?
Any help would be so appreciated!!
I have resolved this issue, I made little change in httpd.conf file where we have to mentioned which type of file they will be process first so I just added index.php in the code block of dir_module.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
I hope this will save your time and minimize your stress. :)

AWS EC2 LAMP Vhosts all point to same folder

I would like to have multiple domains going to the same EC2 instance. All will have same IP. I have setup multiple vhost files as domain1.com and domain2.com. I do not have anything special in any htaccess files or in the vhost files. I have the domains through GoDaddy, they are pointed to the EC2 IP. The issue I have is that both domain 1 and 2 go to the same folder and show the same index.html in the browser.
As per https://help.ubuntu.com/lts/serverguide/httpd.html I see that httpd.conf does not exist anymore and I do not see anything in apache2.conf for ghosts.
(As you can see the commented out things I have tried)
* NOT using rout 53, I do not want to use this, unless I have too*
vhost files:
(domain 1)
#SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
SSLStaplingCache shmcb:${APACHE_RUN_DIR}/ssl_stapling_cache(128000)
<VirtualHost *:80>
ServerAdmin me#localhost
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLUseStapling on
RewriteEngine on
#RewriteRule domain1.com\/$ http://domain1.com [NC]
RewriteCond %{SERVER_NAME} =domain1.com [OR]
RewriteCond %{SERVER_NAME} =domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
(domain 2)
<VirtualHost *:80>
ServerAdmin me#gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/html/domain2.com
# ServerPath "/domain2.com/"
# RewriteEngine On
# RewriteRule "^(/domain2.com/.*)" "/html/domain2.com$1"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/domain2.com>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#RewriteEngine on
#RewriteRule domain2.com\/$ http://domain2.com/index.php [NC]
</VirtualHost>
default-ssl.conf file:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin me8#gmail.com
ServerName domain1.com
DocumentRoot /var/www/html/domain1.com
*********** EDIT ****************
apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
sudo apachectl configtest
Syntax OK
I have completed "sudo a2ensite" command on vhost files and restarted apache after them
******* EDIT ****************
in hosts:
127.0.0.1 localhost
127.0.1.1 domain1.com
127.0.1.2 domain2.com
You should provide more details:
What Instance/LAMP are you using?
Are you configuring vhost correctly?
For Bitnami stacks, for example, you should add the correct add the following line to the end of /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf:
Include "/path to your configuration file.conf”
restart apache:
$sudo /opt/bitnami/ctlscript.sh restart apache
For plain Ubuntu,(after having apache installed) you should include your configuration file as below:
/etc/apache2/sites-available/example.com.conf
ensure to enable your virtual host file:
$sudo a2ensite example.com.conf
restart apache:
$sudo service apache2 restart
So, after making a new instance I was able to set up multiple vhosts.They are all working. The issue must have been the let's encrypt cert. I will backup my configuration and try let's encrypt on this the instance. I will report my findings to this posting. Thank you all for your help on this.

TYPO3 Frontend access on localhost (BE access working fine)

after successfully installing XAMP and then typo3 on my Mac, I set up a virtual host to avoid typing long URL when working on TYPO3.
I uncommented the http.conf line dealing with http-vhosts.conf so that I could set up virtual hosts, then I added my virtual host (called typo3dev) in httpd-vhosts.conf and I finally edited my hosts file accordingly.
So far so good, BUT now the issue that I'm having is that while pointing to the BE ( with http://typo3dev/typo3/ ) works just fine (I am able to log in and have fun in there), I cannot see the Frontend:
When pointing my browser to http://typo3dev/ , I get redirected to http://typo3dev/get-started/ where I get a Page Not Found error
Looking at the server error logs in I get that
$[Thu Jun 21 12:39:20 2012] [error] [client 127.0.0.1] File does not exist: /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1/get-started
By the way, my hosts file looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 typo3dev
my httpd-vhosts.conf like that:
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>
DocumentRoot "/Applications/XAMPP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
</VirtualHost>
Thank you very much in advance for any help/ comment/ advice
Cheers
This looks like a RealURL/Apache configuration problem to me. Make sure that you allow .htaccess in your Apache configuration ...
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
... or configure the RewriteRules directly in the VirtualHost section.
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
RewriteEngine On
RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)$ - [L]
RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</Directory>
</VirtualHost>
Remember to reload / restart Apache after making changes to the configuration.
It's seems to me like you have installed the wrong package. Install only the source package because all other package is for demo. Also if you can avoid Apache. It's complicated and bloated. I can recommend lighttpd. It's much easier to configure especially with virtual domains.

HTTP to HTTPS Apache Rewrite not working

I have an apache2 server running on Ubuntu that I am toying with to step my sys admin skills up. I've been trying to set up a webserver with HTTPS throughout the entire site. Currently, If I go to https://mysite.com it works just fine. I've tried a few different redirect rules to make all connections to the site be forced to HTTPS, but I'm having no luck. Can anyone point out my mistake here?
httpd.conf:
NameVirtualHost *:443
<VirtualHost *:443>
ServerName mysite.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
SSLEngine on
SSLOptions +FakeBasicAuth -StrictRequire +ExportCertData
SSLCertificateKeyFile /etc/ssl/crt/myserver.key
SSLCertificateFile /etc/ssl/crt/mysite_com.crt
SSLCertificateChainFile /etc/ssl/crt/mysite.ca-bundle
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig Options FileInfo Limit
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<IfModule !mod_rewrite.c>
LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
ports.conf:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Any help is greatly appreciated!
Finally figured it out... It wasn't my rewrite rule that wasn't working, but rather a conflict with the proxy I was using (cloudflare). For those in a similar situation, you have to create a "Page Rule" within the cloudflare dashboard, otherwise it will ignore you Apache rules.

Wampserver can't get Named Virtual hosts to work

Using wampserver I can't get named virtual hosts to work. I've edited the httpd.conf to use the
Include conf/extra/httpd-vhosts.conf
I've added the domain to my system32/driver/etc/hosts file. I've edited the httpd-vhosts.conf file and everything seems to work except now localhost is unavailable. The domain I setup (test123.com) works fine, hitting 127.0.0.1 works fine, but hitting localhost hangs. There is nothing relevant in the error logs and no mention of it in the access logs. Here is how I have edited httpd-vhosts.conf:
#
# Virtual Hosts
#
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName test123.com
ServerAlias *.test123
# Folder where the files live
DocumentRoot "D:/Projects/html/test123"
# A few helpful settings...
<Directory "D:/Projects/html/test123">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
What am I doing wrong?
Finally figured it out. In httpd.conf I had to change
Listen 80
to
Listen *:80

Resources