I have two local web site project, localgoogle.com and localapple.com.
localgoogle.com files are in /home/vahid/dev/localgoogle
localapple.com files are in /home/vahid/dev/localapple
My OS is debian 8.5, I have apache2 installed.
I made /etc/apache2/sites-available/localgoogle.com.conf
and /etc/apache2/sites-available/localapple.com.conf
both linked to /etc/apache2/sites-enabled and enabled by a2ensite command.
This is localgoole.com.conf:
<VirtualHost *:80>
ServerName localgoogle.com
ServerAdmin webmaster#localgoogle.com
DocumentRoot /home/vahid/dev/localgoogle
ServerAlias www.localgoogle.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
localapple conf file follow above configuration rule.
I restarted apache2 service, but I don't know why and how to access this virtualhosts from browser!
I tried localhost/localgoogle.com in browser but It's return Not Found
You access the site directly as localgoogle.com from your browser. Make sure that the name resolves to your local ip address using hosts file or dns.
Related
I want to add a subdomain api.example.com on Apache2.
Here is my configuration file for the domain.
<VirtualHost *:80>
ServerName api.winity.pw
ServerAdmin webmaster#winity.pw
DocumentRoot /var/www/api
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I tried to access it without working, here is my DNS configuration on CloudFlare
When I try to access it, I find myself in the /var/www/public directory and not /var/www/api.
First when asking here.
Google the question
Search on StackOverflow
Make a relevant title for you Create subdomain in Apache2
Specify your operating system not your type of server**
Use 443 port over SSL by changing <VirtualHost *:80> to <VirtualHost *:443>.
If you receive an HTTP 525 - SSL Handshake failed error from CloudFlare, use Flexible SSL option.
This append when you use Full SSL and you don't have a valid SSL certificat on your server.
For fix this issue, change the SSL option to Flexible.
I have a server with an ip: XXX.XXX.XXX.XXX
In my server, i have several projects in the folder /var/www:
/var/www/project1
/var/www/project2/trunk/webroot
...
My 000-default.conf is like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Currently I access into them through the following url:
XXX.XXX.XXX.XXX/project1
XXX.XXX.XXX.XXX/project2/trunk/webroot
...
I have a domain that targets to my server
domain.com -> XXX.XXX.XXX.XXX
My intention is to create a subdomain for each project, and each subdomain points to the target folder of the project:
project1.domain.com -> XXX.XXX.XXX.XXX/project1
project2.domain.com -> XXX.XXX.XXX.XXX/project2/trunk/webroot
(I think the best solution will be that XXX.XXX.XXX.XXX/project2 targets directly to XXX.XXX.XXX.XXX/proyect2/trunk/webroot)
I have read that it will be great that each project has its own .conf file in apache, and enabling each site separately.
But I think that if I create a VirtualHost *:80 for each project (project1.conf, project2.conf) they will be in conflict and I dont know how to do it.
Can anybody help me?
Regards.
Virtual Host is the way to go... create one virtual host for each domain pointing to a folder on your server where to webpage is sotored.
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
</VirtualHost>
Etc... One VirtualHost for each domain / DocumentRoot convination
Soruce: https://httpd.apache.org/docs/current/vhosts/examples.html
##################### EDIT
I have tested it on my own server
Whithout touching the default.conf file I have created two new config files
root#raspberrypi:/etc/apache2/sites-available# pwd
/etc/apache2/sites-available
root#raspberrypi:/etc/apache2/sites-available#
Please ignore the default files I have not touched them I have just created two new files named project1.... and project2....
root#raspberrypi:/etc/apache2/sites-available# ls
000-default.conf project1_domain_com.conf
default-ssl.conf project2_domain_com.conf
root#raspberrypi:/etc/apache2/sites-available#
root#raspberrypi:/etc/apache2/sites-available# cat project*
<VirtualHost *:80>
DocumentRoot "/var/www/projects/project1/"
ServerName project1.domain.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/projects/project2/"
ServerName project2.domain.com
</VirtualHost>
root#raspberrypi:/etc/apache2/sites-available#
ENABLING SITES
root#raspberrypi:/etc/apache2/sites-available# a2ensite project1_domain_com.conf
Enabling site project1_domain_com.
To activate the new configuration, you need to run:
service apache2 reload
root#raspberrypi:/etc/apache2/sites-available# a2ensite project2_domain_com.conf
Enabling site project2_domain_com.
To activate the new configuration, you need to run:
service apache2 reload
root#raspberrypi:/etc/apache2/sites-available#
RELOAD APACHE
root#raspberrypi:/etc/apache2/sites-available# /etc/init.d/apache2 reload
[ ok ] Reloading apache2 configuration (via systemctl): apache2.service.
root#raspberrypi:/etc/apache2/sites-available#
################# SUBDOMAIN EDIT
For example I have a single server with an IP XXX.XXX.XXX.XXX that have multiple domains registered (15 domains now).
I have one virtual host entry for each domain that works this way:
domain1.example.com -> Load the domain1 web index.html page (without /nothing/else )
domain2.example.com -> Load the domain2 web index.html page hosted on another folder expecified on the second virtual host.
And finally ussing a2ensite or a2dissite I enable or disable the website as a web hosting provider do...
If for any reason you need that accessing the host domain3.something.com it redirects to domain3.something.com/something/diferent ... it should be done on your server ussing .htaccess file and its a entirely diferent question :D
I'm trying to get an SVN server up and running. CentOS 6.4, apache 2.2.15. More importantly, I need to have it running on https only. So I figure that I'll get ssl running first, as I've already tested it on port 80, and SVN works the way I want it to.
In /etc/httpd/ssl, I have ..
intermediate.crt wildcard.mycompany.com.crt wildcard.mycompany.com.key
We bought a wildcard certificate from GeoTrust, and I downloaded the intermediate.crt from their website. In /etc/httpd/httpd.conf, I have..
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin my.email#mycompany.com
ServerName hostname.mycompany.com
ErrorLog logs/error_log
CustomLog logs/access_log common
Redirect permanent / https://hostname.mycompany.com
</VirtualHost>
<VirtualHost hostname.mycompany.com:443>
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/wildcard.mycompany.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/wildcard.mycompany.com.key
SSLCertificateChainFile /etc/httpd/ssl/intermediate.crt
ServerName hostname.mycompany.com
ServerAdmin my.email#mycompany.com
ErrorLog logs/subversion-error_log
CustomLog logs/subversion-access_log common
</VirtualHost>
I can connect to the server, but my browser tells me that the certificate is untrusted. So I'm guessing that there's an error in the permissions, or perhaps in the format of the file?
I can't see anything in the logs.
I set this up at home on my own server, but wasn't using a wildcard certificate.
Anyone care to advise as to what's gone wrong?
Thanks.
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/.
Working on CentOS (specifically the Amazon EC2 Linux AMI). I have 2 virtual host on my apache, and I would like them to log on different rsyslog facilities, so I configured my hosts like this:
<VirtualHost *:80>
DocumentRoot /var/www/site1
ServerName www.site1.com
ServerAlias alias1
ErrorLog syslog:local1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/site3
ServerName www.site3.com
ServerAlias alias3
ErrorLog syslog:local3
</VirtualHost>
and in my rsyslog conf I set up 2 forwarding rules:
local1.* /logFile1
local3.* /logFile3
But everything goes into logFile1, as if the 2 virtualhost were sharing the syslog facilities. I can't understand what's happening.
Found by my self, there a note on apache docs (http://httpd.apache.org/docs/current/mod/core.html#errorlog) saying:
The facility is effectively global, and if it is changed in individual virtual hosts, the final facility specified affects the entire server.
sadly.