I have created 2 laravel applications in /home/azureuser directory.
I want to run multiple laravel applications on single ubuntu VM. I tried configuring virtual hosts but not able to make it work.
Below is the contents of /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName apitesting.cloudapp.net/demo
DocumentRoot /home/azureuser/demoapp/public
<Directory /home/azureuser/demoapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
SetEnv APPLICATION_ENV dev
LogLevel warn
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName apitesting.cloudapp.net/quiz
DocumentRoot /home/azureuser/quizapp/public
<Directory /home/azureuser/quizapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
SetEnv APPLICATION_ENV dev
LogLevel warn
</VirtualHost>
Not sure whether the above is correct.
It seem we cannot set the ServerName in the URL with a sub path param. As according your requirement, you can leverage the rewrite mod.
First, install apache rewrite mod via command: sudo a2enmod rewrite, then restart apache via: sudo service apache2 restart.
After that, modify the config file /etc/apache2/sites-enabled/000-default.conf, config the directory to the parent folder of your applications:
...
DocumentRoot /home/azureuser
ServerName apitesting.cloudapp.net
<Directory /home/azureuser>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
...
Then create a file named .htaccess in the root directory of your application, to redirect the incoming requests to your public folders, with the content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Related
I am using AWS Lamp apache service. Here htdocs folder is the default root directory. I have a folder named my-folder inside htdocs.
htdocs
my-folder
I want to set my-folder as a root directory.
But How?
I have edited /opt/bitnami/apache/conf/httpd.conf
Here are the edited codes in httpd.conf file.
# DocumentRoot "/opt/bitnami/apache/htdocs"
# <Directory "/opt/bitnami/apache/htdocs">
DocumentRoot "/opt/bitnami/apache/htdocs/my-folder"
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
But it doesn't work!
Please correct me.
Problem Solved
I just modified /opt/bitnami/apache/conf/vhosts/00_status-vhost.conf as below.
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias *
DocumentRoot /opt/bitnami/apache/htdocs/my-folder
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
#for https
<VirtualHost 127.0.0.1:443 _default_:443>
ServerAlias *
DocumentRoot /opt/bitnami/apache/htdocs/my-folder
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/server.key"
<Directory "/opt/bitnami/apache/htdocs/my-folder">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and it's working!
Documention provided by AWS Create A Virtual Host For A Custom Application
I want to load my Laravel 5.8 project with Virtual Host on XAMPP. So here is what I did:
I opened up C:\Windows\System32\drivers\etc\hosts and put this:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 local.nanoclub.ir
Then at C:\xampp\apache\conf\extra\httpd-vhosts.conf, I added this:
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And also added this to my project, public .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
But now when I want to run local.nanoclub.ir on browser, I get this:
So what's going wrong here? I used to access this local.nanoclub.ir correctly but now it loads this screen.
How to solve this issue?
You need to grant access to this directory.
You can grant this access in your virtual host definition or in the apache2.conf
In virtual host definition
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
# The missing one
Require all granted
</Directory>
</VirtualHost>
In apache2.conf
<Directory C:/xampp/htdocs/badges/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Notice: Don't forget to restart apache after changing configuration.
I have a website built based on PHP/HTML/CSS and which follow the MVC design pattern.
The website is the following : https://admin.site.com
It works well on Localhost. However, when I upload it to my apache2 server, I encounter a problem. It seems that the "/" get removed automatically after ".com" . As I need to be authentificated to access the website, I'm directly redirected to the login page but as the "/" has been removed, it is not working.
I get https://admin.site.comlogin/ instead of https://admin.site.com/login/
Before posting here, I tried to check everything but I run out of ideas.
Especially the fact that this same website works on a different subdomain that I initiated for testing : http://sub1.site.com
The only difference is that that this one does not have any SSL certificate but I don't know it's something that may cause the problem.
Here my different files in Apache2 server.
000-defaut.conf
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias sub1.site.com
DocumentRoot /var/www/sub1/interface/
<Directory /var/www/sub1/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
Redirect permanent "/" "https://admin.site.com"
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
defaut-ssl.conf
ServerAdmin contact#site.com
ServerName site.com
ServerAlias admin.site.com
DocumentRoot /var/www/site/interface/
<Directory /var/www/site/interface/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
...
</VirtualHost>
.htaccess
`# Remove the question mark from the request but maintain the query string
RewriteEngine On
# Uncomment the following line if your public folder isn't the web server's root
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,R]
Do you have any insight about why it is not working and the slash get removed ?
I solved my issue simply :
I have added a trailing slash at the end to the redirect permanent directive.
Redirect permanent "/" "https://admin.site.com/"
I had some conflict as well with some directive. So I removed all the Directory directive to my conf file and let them only on my apache2.conf .
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I'm using Ubuntu wizzy as my local server and then I set up domain there which are
domain.svr
api.domain.svr
adm.domain.svr
And here is the problem. I've create exactly same configuration for all of them but why only adm.domain.svr doesn't work? It's always response 404 when I goes to http://adm.domain.svr/site/dashboard/ but it's okay when I try http://api.domain.svr/site/dashboard/
Here is my configuration
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName domain.svr
DocumentRoot /home/shaf/web/domain.dev/frontend/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/frontend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName adm.domain.svr
DocumentRoot /home/shaf/web/domain.dev/backend/web
<Directory /home/shaf/web/domain.dev/backend/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-adm-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-adm-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin localhost#gmail.com
ServerName api.domain.svr
DocumentRoot /home/shaf/web/domain.dev/api/web
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/shaf/web/domain.dev/api/web>
Require all granted
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /home/shaf/log/domain-api-error.log
LogLevel warn
CustomLog /home/shaf/log/domain-api-access.log combined
</VirtualHost>
and here is my .htaccess which I placed on every domain web folder
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Please give me advice about this, I really have no idea.
Your ServerName domain.svr is wrong. Apache can not route it. Try to rename it to adm.domain.svr
I just solve this by duplicate another directory to adm and try it but fail, so I create another 1 host so I have 4 host. 1 is duplicate for adm and it's work perfectly. I still didn't know what happen but seems only that folder didn't read the htaccess and I'm sure of it because I already try to swap sub domain but only adm folder doesn't read the htaccess file.
So here is my conclusion and I don't know this is correct or not but apache has cache of htaccess so I need to hard refresh the apache (only restart apache doesn't work because I already tried it several times and nothing happen) so maybe you need to restart your OS / Server and if you doesn't want it, try my way.
I keep trying to configure it so that the domain symfony.local would link to the app_dev.php, but I also keep getting forwarded to the xampp page.
My hosts file is:
127.0.0.1 symfony.local
My httpd-vhost is:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:\xampp\htdocs\testAS\web"
DirectoryIndex app_dev.php
<Directory "C:\xampp\htdocs\testAS\web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
I'm using Windows 8. Appreciate any feedback.
I assume it's a fairly recent version of xampp? There is a new directive "Require local" that popped up a few years ago. I remember being stumped by it.
<Directory "C:/home/ahundiak/zayso2016/cerad3/web">
## Options Indexes FollowSymLinks
AllowOverride All
Require local ## Add This
</Directory>
<VirtualHost *:80>
ServerName local.api.zayso.org
DocumentRoot "C:/home/ahundiak/zayso2016/cerad3/web"
</VirtualHost>
I am not an expert on configuring this. The above works for me using the Symfony 2 .htaccess file.
may be it issue of your hosts file entry of symfony.local and local ip address or may between them only TAB(on keyboard) require ...
OR if above answer not work follow below
please follow this link Click Here it help you solve your issue of not show symfony project