Requirement is to create two website
www.example1.com
www.example2.com
with the same codebase and database without copying it to another directory or importing the sql file.
Is it possible through just pointing it based on domain name and using .htaccess file.
Any help or hints is appreciated.
Yes you can. Start by placing all of your project files on the same directory, for the sake of this example let's call it /var/www/example
Then go to /etc/apache2/sites-available and create two .conf files:
example1.conf: Virtual Host Configuration for www.example1.com
example2.conf: Virtual Host Configuration for www.example2.com
The contents of the two configuration files:
example1.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example1.com
</VirtualHost>
exampl2.conf
<VirtualHost *:80>
DocumentRoot "/var/www/example"
ServerName www.example2.com
</VirtualHost>
As you can see both of them refer the same directory as Document Root but listen to different URLs.
After you're done creating those files don't forget to run the following commands on your terminal:
a2ensite example1.conf
a2ensite example2.conf
and finally,
service apache2 reload
Related
I've added 127.0.0.1 my.pro to my hosts file
and add below code to httpd-vhosts
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/ci4/public"
ServerName my.pro
ErrorLog "logs/myproject-error_log"
CustomLog "logs/myproject-access_log" common
</VirtualHost>
the problem is i can't reffer to my assetes. assetes and project index page are in defferent directories.
-ci4
--public
---index.php
--assets
---css
C:/xampp/htdocs/ci4/public is project root and i locate assetes in C:/xampp/htdocs/ci4/assetes .
when I try to load a CSS file with this resource http://my.pro/assets/css/style.css it shows 404 error.
I know apache tries to load file from C:/xampp/htdocs/ci4/public/assets/css/style.css which doesn't exist.
but I have no idea how to fix it!
Hello I'm trying to run project using newest symfony on my localhost.
What i already did:
I added this to my vhosts file in Xampp.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "F:\Programy\XAMP\htdocs\Anka\web"
ServerName Anka
DirectoryIndex app_dev.php
ErrorLog "logs/vark.local-error.log"
CustomLog "logs/vark.local-access.log" common
</VirtualHost>
I added this in my hosts file in Windows\System32...
127.0.0.1 Anka
This is what i see after typing
anka\
In my browser.
My localhost website
And when i click on web i see this:
web
Can somebody help me what else i should do to see normal Symfony index page?
Try http://anka/app_dev.php or http://anka/web/app_dev.php
Also You can Change the directory to this one with the application and run:
php bin/console server:run
Then access http://localhost:8000/ in your browser
Like this:
https://symfony.com/doc/current/setup.html#running-the-symfony-application
First of all - ServerName value is case-sensitive, to Apache is not really recognizing request as this VirtualHost and you're getting listing of root directory.
Use http://Anka url, or change ServerName Anka to ServerName anka and 127.0.0.1 Anka into 127.0.0.1 anka.
Next thing is that you have some errors in your code and PHP cannot find AnkaBundle\AnkaBundle class. You're probably missing an autoloader, but that's only my guess. Not enough information to be sure.
I am very new to magento and php and i am trying to create a virtual host url for my magento site.
Currently the url is
http://localhost:8080/Magento/
And if i create any website i have to use url's such as below
http://localhost:8080/Magento/website1
http://localhost:8080/Magento/website2
...
After referring to several examples such as this http://sawmac.com/xampp/virtualhosts/ i have managed to configure my files such as below
Step 1:
In the file C:\Windows\System32\drivers\etc\hosts i have append the below mapping
127.0.0.1 clientA.local
Step 2:
And in the file C:\xampp\apache\conf\extra\httpd-vhosts.conf i have append the below code
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs\magento"
ServerName clientA.local
<Directory "C:\xampp\htdocs\magento">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
After step 1 typing typing clientA.local:8080/magento opens localhost:8080/magento
But step 2 doesn't change anything.
I want to do something as below
clientA.local should open http://localhost:8080/Magento/website1
clientB.local should open http://localhost:8080/Magento/website2
...
I have tried changing the Document root , directory in several ways nothing helped.
If any one has any idea on this senario please contribute here.
thanx
I am developing a website where if a user enters any sub-domain the system changes to look within a specific folder within root. I can get to the files correctly, however because the document root is looking for /server-path/ as the root, none of my files, images etc work.
Here is my file structure if this helps:
For www.main-website.com,
The Server doc root = /server-path/
For subdomain.main-website.com
system looks at -> /server-path/folder/
The Server Doc Root still = /server-path/ - however I need this to now equal /server-path/folder as the DOC ROOT.
I have tried the following with no success:
Setting the $_SERVER['DOCUMENT_ROOT'] to equal /server-path/folder
Adding a php.ini file into the folder root with the following line:
doc_root = "/server-path/folder"
I'm not very competent with Apache or server changes so any help / suggestions would be welcomed.
You can set different document roots by using VirtualHost
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.main-website.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName subdomain.main-website.com
# Other directives here
</VirtualHost>
Tipically this content should be included into a .conf file inside /etc/httpd/conf.d/
I want to create virtual hosts for my project in zend framework. I have frontend and backend (admin) functionality. I created the virtual host for my frontend functionality with necessary configuration and it running properly.
Example: In /etc/apache2/sites-available I created the file roomstays and my code is in var/www folder.
<VirtualHost *:80>
DocumentRoot "/var/www/roomstays/public"
ServerName localhost
#This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/roomstays/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And it running properly with localhost.
Now I have admin i.e.backend code and as previous one I want to run this code. I put my newer code into same var/www directory with named roomstaysback. My question is how to create virtual host for this backend code. I want to run both frontend and backend side code.
Please give me any solution I am completely new in it thanks.....
You can handle both front end and back end from same virtual host. zend framework provides the concept of modules. Here is one example. Have a look
Setup multi modules in Zend Framework v1.9 with 13 steps
and the detailed one is here
Using a Conventional Modular Directory Structure
1.Create a conf file for virtual host
$sudo gedit /etc/apache2/sites-available/HOST_NAME.conf
2.then paste following contents to this file
<VirtualHost *:80>
ServerName www.HOST_NAME.com (set host name here)
DocumentRoot /var/wwww/HOST_FOLDER (point to host path )
</VirtualHost>
Add host name
$sudo gedit /etc/hosts
Then paste following contents
127.0.0.1 www.HOST_NAME.com
enable the site
$sudo a2ensite HOST_NAME.conf
Restart apache server
$sudo service apache2 reload
The process is over and you can browse www.HOST_NAME.com :)