I have a PHP (Wamp) server that should host two different domains.
Each domain has a different certificate files (.crt .key)
I am trying to edit the httpd-ssl.conf file to configure each domain certificate.
However, I cannot define the correct filter in the virtual host header. Only this filter works:
VirtualHost default:443
Which basiclly means that all domain are directed to one default certificate (And I need each one to direct to a different certificate)
I want to configure it so each domain will use a different filter. Example:
VirtualHost domain1.com:443
VirtualHost domain2.com:443
But this does not work. When I configure it like this, neither of the domains get the certificate.
I am only trying to edit the httpd-ssl file, should I also edit other files?
Thanks
Solution:
You need to create 2 virtual hosts with their two respective ServerName directives (ServerName domain1.com and ServerName domain2.com). Do not use , usually <VirtualHost *:443> is what you need. The VirtualHost directive determines on which IP address to listen, not the name. If you put a domain name inside it's going to resolve it to an IP address on server startup, something you do not want for various reasons. See this answer on Serverfault for an example configuration.
https://serverfault.com/questions/744960/configuring-ssl-with-virtual-hosts-under-apache-and-centos/745285#745285
Related
I have a client and I need to execute a curl script on it's server but I get a 404 error.
First I tried the other suggestions I've found on other solutions here (adding headers, cookies...)
After that I asked for a SSH access to be able to check more and that's what I've found:
The only URL that doesn't returns a 404 is the home http://aksentropis.com and it doesn't return the homepage's content it just return
<html><body><h1>It works!</h1></body></html>
So I've decided to investigate where this text could be and I've found it on another completely different directories using grep:
./usr/src/httpd-2.4.23/docs/docroot/index.html:1
./usr/local/apps/apache2/www/htdocs/index.html:1
I've entered those directories and they only contain the index.html file
But, the main folder for public_html is on:
/home/admin/public_html
How can I fix that, or what should I do? I only have a ssh root access.
Update: if I call the url from another server it just works...
Update: I've found the DocumentRoot in the apache was misconfigured.
It was pointing to
DocumentRoot "/usr/local/apps/apache2/www/htdocs"
and I've updated it to
DocumentRoot "/home/admin/www"
Now it loads the php but it doesn't execute it. Why is that?
It looks to me like the vhost for this site isn't configured to accept your requests. This could either mean from your location, or using the port you're using.
It could be a matter of your source location. A Require, Allow from or Deny from directive inside your vhost can manage access control.
Apache Docs: Access Control
Perhaps a proxy (such as a load balancer or firewall) usually intercepts port 443 and 80 traffic and redirects it to other ports, and your vhosts are configured to listen to those other ports. Right now all traffic (from your curl location, most likely localhost) appears to be directed to the default apache site, and paths relative to that index file.
Please check the virtual host configuration for this site. It can usually be found in /etc/apache2/sites-enabled/. If the VirtualHost block for that site contains a colon followed by a number, then that's the port number this block is applied to:
<VirtualHost aksentropis.com:1234>
DocumentRoot "/home/admin/public_html"
</VirtualHost>
In the above example the server would be configured to listen to port 1234, which means there's usually something that's between external traffic and the server. Apache Docs: Binding to Addresses and Ports
I have looked everywhere for something on this but can't seem to find anything.
After setting up the CNAME record of a domain (i.e. user_domain.com) to point to my own example.com, what would be the next step? How would I get it to point to example.com?
I believe that I will need to do something on my end in order to handle these domains but I can't find any tutorials on how to do so.
The error that is received when visiting user_domain.com is:
user_domain.com’s server DNS address could not be found.
For the record, I am using Ubuntu, Apache and PHP. Would something need to be done to the .htaccess file?
CNAME
www example.com
Overall
I am trying to let users point their own domain to example.com
What would be the next step after setting up the CNAME record?
I would appreciate any help, thanks!
You either have to:
Configure your Apache with name-based virtual hosts and have it listen explicitly for the new domain via the ServerAlias directive.
Or:
Configure your Apache for IP-based hosts. It will serve the example.com content for whatever domain name is pointed at it.
Or:
Configure your Apache with name-based virtual hosts and have it listen implicitly for the new domain by making sure example.com is the first vhost listed in the config. This will make example.com the "default" service for IP-based requests. (Not 100% sure about this one, but this is how I recall Apache behaving.)
I have the following problem.
I have two domains: www.domain1.de and www.domain2.de
I also have path is on Jelastic server where to find my PHP page
myphpsite.jelastic.dogado.eu.
Now I wanted to do the following.
1) If I go to www.domain1.de, then should address bar of the Web Browser
www.domain1.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu.
2) When I go to www.domain2.de, then should address bar of the Web Browser
www.domain2.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu / admin /.
so
1) www.domain1.de -> myphpsite.jelastic.dogado.eu
2) www.domain2.de -> myphpsite.jelastic.dogado.eu / admin /
The first one I can do by CNAM Record
But we can I solve the second problem without frames?
thank you
This is just a matter of configuring Apache VirtualHosts (assuming that you're using Apache), or Nginx Server Blocks (if you're using Nginx). Leo's link can help you with either of them, within a Jelastic context (where to find those config files etc.): http://docs.jelastic.com/multiple-domains-php
Here's a quick example for Apache:
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT
ServerName domain1.de
ServerAlias www.domain1.de
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT/admin
ServerName domain2.de
ServerAlias www.domain2.de
</VirtualHost>
You might also wish to define different log files for each domain etc.
There are many possibilities, and since Jelastic gives you direct access to the server config. files you can configure almost anything that you could want here. It's just a matter of reviewing the Apache (or Nginx) docs and trying it out.
Notes:
Beware that the Jelastic default configuration defines a wildcard to catch all requests. You need to place your custom configuration before that (either literally, or via an include), or else overwrite the default VirtualHost configuration block - otherwise your config. will not have any effect.
The above example handles HTTP only. If you need to handle HTTPS, you need to configure this separately. (e.g. :443 instead of :80)
Remember that you need to restart Apache (or Nginx) for config. changes to take effect.
See also:
Apache VirtualHost Documentation
Nginx Server Blocks Documentation
I'm trying to create a copy of an existing Magento website on my localhost for developing purposes.
I followed all the steps listed here: Copy ec2 files to local
I also created a fake domain for my localhost so that there’s a “.” in it as I read somewhere this is required by magento. So now my localhost fake URL is something like: www.mysite.local
I have XAMPP installed on OS X 10.9.1 and I placed the magento filesystem as follows:
/Applications/XAMPP/xamppfiles/htdocs/magento/
In the database I added the local URL as follows:
update core_config_data
set value = ‘http://www.mysite.local/’
where config_id = 6;
and on local.xml I entered the following parameters:
<host><![CDATA[localhost]]></host>
<username><![CDATA[myusername]]></username>
<password><![CDATA[mypassword]]></password>
<dbname><![CDATA[mydatabase]]></dbname>
where localhost is just localhost, myusername is the username for the db I restored on my local XAMPP server, mypassword is the password for that same db, mydatabase is the name of the same db.
Still, when I browse to www.mysite.local/magento/ or www.mysite.local I don’t see anything appear.
What am I doing wrong?
Thank you so much!
If you're using a local server, here's some basic trouble shooting to help you debug:
Firstly, is the local server active? Can you visit http://localhost without it displaying server not found? If you can't, your local server is most not running. Try firing up xampp and launching Apache.
Secondly, it seems you're trying to create a virtual host for your local server. That's great! Virtual hosts allow you to create individual URLs for projects on the same server. E.g. http://myproject.dev.
However, you first need to make sure that the server understands what you're doing.
You will need to create a virtual host in your server if you haven't already.
I see you're using xampp. What you need to do is navigate to your xampp install, and edit your apache/conf/extra/httpd-vhosts.conf file, which is the file xampp recommends you use solely for virtual hosts.
Reading: Setting Up Virtual Hosts for XAMPP
For example, in Apache, a hosts config file may look like this:
# Base
<VirtualHost *:80>
DocumentRoot "X:/"
ServerName localhost
</VirtualHost>
# Project - Some Project of Mine
<VirtualHost *:80>
DocumentRoot "X:/projects/myproject/public"
ServerName myproject.dev
ErrorLog X:/projects/myproject/logs/apache.error.log
CustomLog X:/projects/myproject/logs/apache.access.log common
php_value error_log X:/projects/myproject/logs/php.error.log
</VirtualHost>
(navigating to myproject.dev displays the files in my X:/projects/myproject/public directory)
This answer is not to explain virtual hosts to you however. There are plenty of amazing resources online to help you get started with setting up your own.
Don't forget to restart your server when you add a virtual host!
If this is already set up, is your computer's hosts file set up to point to your server?
Your hosts file on your computer is used to tell it to do certain actions when you enter a matching url in your browser.
Reading: The Hosts File and what it can do for you
Reading: How to Edit Your Hosts File
For example, using the apache conf file settings above, my hosts file must also include:
# My project - Localhost
127.0.0.1 myproject.dev
It tells my computer to send the request to my local server (at localhost) when I use the URL myproject.dev. The local server then picks up the request, sees that you're accessing myproject.dev and checks if it has any virtual hosts matching that name. Well, whaddya know, it does! It then looks at the DocumentRoot setting for the location of the server files, and continues the process. Think of your hosts file as a local DNS of sorts.
If you've just added the site to your hosts file, it may take a few minutes to start resolving correctly. Wait a little, clear your browser cache and try again.
Finally, if these steps are done, and you're receiving nothing, it may be a server configuration problem, or a .htaccess issue.
If you're running on windows, you can check your event log for apache server errors. If you have set up logging on the virtual host, you can check those files to see if it's picking up your requests, and what it's doing with them if it is.
Most issues after that point will at least yield a visible error in your browser (or a blank page).
I hope this helps!
Also checking the magento error logs could tell you what the issue is, assuming it's actually hitting magento at all at this point.
As Sean mentioned above, one of the most common problems I've seen when copying a magento site is accidentally omitting the .htaccess file - make sure it's present in your site root.
If you tested your site before making the change to core_config_data, then you can also try deleting everything in var/cache and var/session. Also make sure that the web user has write permissions on var.
Regards
Hans
I have a website where I want users that sign up to get their own subdomain. This subdomain is virtual, and every subdomain uses the same web server files.
I use PHP and Apache, and I know about Virtual Hosts, but I'm wondering where I need to put the vhosts code. First, I don't have access to httpd.conf. Second, I want this to be done automatically upon registration.
I've read about virtual hosts, but didn't find anything that answers my questions. Is there anyone who can explain me how all this works together, or know where I can find my answers?
Can you tell apache to read an extra .conf file? (traditionally you store your vhosts in httpd-vhosts.conf)
if so, add something like the following and restart your webserver
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /abs/path/to/webroot
ServerName domainname.com
ServerAlias *.domainname.com
<Directory /abs/path/to/webroot>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
then in php, you can see which subdomain the user is requesting by inspecting:
$_SERVER['HTTP_HOST']
ie. if the user requests http://user1.domainname.com/index.php
$_SERVER['HTTP_HOST'] will have user1.domainname.com
you can then explode('.', $_SERVER['HTTP_HOST']) to inspect each segment.. etc.
You will need 3 thing for this:
1.
Set your DNS for *.yourDomain.com
2.
Add the ServerAlias directive to the apache configuration for this domain:
ServerName www.yourDomain.com
ServerAlias *.yourDomain.com yourDomain.com
Also make sure that you apache server has UseCanonicalName set to on (this is the default)
3.
Grep the subdomain name with PHP:
$nameChunks = explode('.', $_SERVER['HTTP_HOST']);
$subDomainName = $nameChunks[count($nameChunks) - 3];
(inspired by Janek's comment)
IF your Apache instance is configured for * aliasing, then there is no need to create a virtual named host - You can fake it with PHP by evaluating $_SERVER['HTTP_HOST'].
To determine if your Apache instance will handle it, edit your local /etc/hosts file (or windows equivalent - %SystemRoot%\system32\drivers\etc\hosts) so that the desired virtual name is pointing to your server.
For instance
# An example HOSTS file.
192.168.1.4 testserver testserver.com subdomain.testserver.com secondname.com
This assume that 192.168.1.4 is the IP of your server. Everything after that are alias's that the server can be called.
Then, as Janek suggested create a page that will echo $_SERVER['HTTP_HOST'] to see if it capturing the name correctly. If so, then all that is required is a DNS change and Apache can remain unchanged.
Otherwise without access to Apache.conf (this kind of implies that you don't have access to a lot of things) this will be difficult to pull off. The programming won't be - but the implementation will be.
Here's why:
Apache by default will serve up virtual hosts. But you do need access to the server's conf directory (often located in /etc/httpd/conf.d/) so you can create the virtual host "include" file (IF the Apache configuration is setup to include it - most recent installs should be).
You will need to be able to cycle Apache (restart). Without this the Virtual Host changes won't take affect.
You will need to be able to change the DNS. You can always change your local /etc/hosts file - but in order for visitors to get to your site, you'll need to be able to push through a DNS change. (Which may instantaneous - or it may take 24 hours to propagate).
The scripting certainly can be done (see Cpanel and WHM)
You will first of all need to setup the DNS server to resolve any subdomains to your main IP address, i.e. *.domain.com will have to resolve to your server's IP address. Then the web server needs to handle all incoming requests regardless of subdomain as well, invoking some PHP script. The PHP script can then simply figure out what domain was requested from the $_SERVER['HTTP_HOST'] header and act accordingly.
You're not actually "creating subdomains upon user registration".