I have a problem in setuping the vhost in linux.
I have this code in my httpd.conf
<VirtualHost *:80>
DocumentRoot /data/APACHE/html/mypage
ServerName main.store.com.ph
ServerAlias branch1.store.com.ph branch2.store.com.ph
</VirtualHost>
Now I am accessing the mtr_s6.giftregistry.com.ph and mtr_s7.giftregistry.com.ph link in my browser but it redirects to another online page. Should I need to put these links in the linux hosts file and also to the Windows?
What I want is if I access the link main.store.com.ph it will redirect to the directory /data/APACHE/html/mypage and also to the other links branch1.store.com.ph and branch2.store.com.ph all of these links are /data/APACHE/html/mypage
Related
I would like to create a web platform where each customer get its own site like uservoice.com
Example:
Main website : uservoice.com
Customer 1: cust1-subdomain.uservoice.com
Customer 2 : cust2-subdomain.uservoice.com
The objective is that the customer can enter its site via its own url & login page.
Does anyone know how to do that? How to avoid a sub-directory by subdomain and copy all the files? I am looking for a clean and scalable solution.
I think the solution is a name-based virtual host.
For example the domain cust2-subdomain.uservoice.com will display the content located in a different folder than your DocumentRoot but the address will be unchanged. The server will recognize the domain and send the appropriate content.
If you are using apache: You will need to uncomment this line in the httpd.conf file if not already uncommented:
Include conf/extra/httpd-vhosts.conf
Then you should edit /usr/local/apache2/conf/extra/httpd-vhosts.conf.
<VirtualHost *:80>
ServerAdmin you#uservoice.com
DocumentRoot "/usr/local/apache2/docs/uservoice.com"
ServerName uservoice.com
ServerAlias www.uservoice.com
ErrorLog "logs/uservoice.com/error_log"
CustomLog "logs/uservoice.com/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin cust2#uservoice.com
DocumentRoot "/users/customers/cust2/WWW"
ServerName cust2-subdomain.uservoice.com
ServerAlias www.cust2-subdomain.uservoice.com
ErrorLog "logs/cust2/error_log"
CustomLog "logs/cust2/access_log" common
</VirtualHost>
The first section is for your site and the second one for cust2's site. So cust2 will put his site into the WWW folder located in his home directory. You will put your content in your old DocumentRoot. (You will need to customize /usr/local/apache2/conf/extra/httpd-vhosts.conf).
I have 3 websites running on a cloud server, with the default Apache httpd.conf setting . I have uncommented the NameVirtualHost and configured the 3 websites from VirtualHost, after set up the DocumentRoot and ServerName for each, all worked perfectly but only the site within the default Directory is working for mod-rewrite, which I used for SEO URLs. The other 2 sites are located just one level above the /var/www/html, and are in the subfolder of /var/www/websites/site1, site2. I've tried to use RewriteBase in the .htaccess file to make this work but no success, and I have no idea where in the httpd.conf file I can make any changes to get things right. Please help, thanks.
If I understand you correctly you wish to have 3 separate websites running on 1 Apache server and then be able to have rewrites working on all of them.
You are on the right track using VirtualHosts. You need to stick to using a separate VirtualHost for each website you intend to host.
Given a folder structure as follows
/var/www/
- /websites
-- /site1
-- /site2
-- /site3
You can then setup 3 VirtualHosts for each of your 3 sites:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain1.tld
DocumentRoot /var/www/websites/site1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.tld
DocumentRoot /var/www/websites/site2
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.tld
DocumentRoot /var/www/websites/site3
</VirtualHost>
Hope this helps.
I'm pretty new in webserver management. So I rented this server, and setup a LAMP server with MySql and everything is alright in that sense.
The problem is now that I have two different domains (say www.domain1.com, www.domain2.org), and I want each of them to load the website content from a different folder on my server.
How can I do that?
I tried to google some relevant terms, but I couldn't find what that's called.
Thank you for any efforts.
If you use Apache2, you can use the ServerName directive in the VirtualHost configuration:
<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /folder1
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
DocumentRoot /folder2
</VirtualHost>
I'm having issues redirecting my http://domain.co.uk to http://www.domain.co.uk . I'm pretty new to working with apache and linux so this is what i have done so far. Hopefully there is an obvious mistake that can be fixed easily.
In my attempt to get the redirect working I found a few tutorials saying that i should do it via the virtualhost file so i edited the existing virtual host file that i initially set up for the site in
/etc/apache2/sites-available/domain.co.uk
I have added a new block to the top of this file so it now looks like this:
<VirtualHost *:80>
ServerName domain.co.uk
Redirect permanent / http://www.domain.co.uk/
</VirtualHost>
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin#domain.co.uk
ServerName www.domain.co.uk
ServerAlias domain.co.uk
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/simon/public/domain.co.uk/public/
# Log file locations
LogLevel warn
ErrorLog /home/simon/public/domain.co.uk/log/error.log
CustomLog /home/simon/public/domain.co.uk/log/access.log combined
</VirtualHost>
After editing this file I restarted Apache and tried out the site but http://domain.co.uk is giving me "failed to open the page - cannot reach the server". http://www.domain.co.uk is still working fine.
Is this the right place for this <virtualhost> block? I have seen some mention of putting virtual host info in the httpd.conf file but I haven't been able to find this file in my installation of apache.
Any help would be great.
try this one and restart Apache
<VirtualHost *:80>
ServerName domain.co.uk
ServerAlias *.domain.co.uk
RedirectMatch permanent /(.*) http://www.domain.co.uk/$1
</VirtualHost>
I have a Linode server running Ubuntu 11 and Apache2 and I'm trying to get a subdomain working. This is my mywebsite file in sites-available folder. I've tried putting the top part in its own file testing.mywebsite and reloading apache2 with no luck.
<VirtualHost *:80>
DocumentRoot /home/user2/www
ServerName testing.mywebsite.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin email#gmail.com
ServerName mywebsite.com
ServerAlias *.mywebsite.com
ServerAlias 192.155.90.135
#Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/user/public/mywebsite/www
#Log file locations
LogLevel warn
ErrorLog /home/user/public/mywebsite/log/error.log
CustomLog /home/user/public/mywebsite/log/access.log combined
</VirtualHost>
I have a website up and running and apache can find all the files in /home/user/public/mywebsite/www but when I go to the testing subdomain, my browser can't find it. I'm pretty unfamiliar with apache2, so any help is appreciated. Thanks.
Are your DNS records configured to point your computer at the desired hostname to your server's IP address when it resolves? Or, are you overriding with editing /etc/hosts?
I am somewhat unsure what "my browser can't find it" means, so please clarify if the above questions don't get you closer to your problem. It would be worth checking your log files for Apache in your specified paths and /var/log/apache2/.