I am trying to host website true Apache2 here what I did
I created files
/var/www/html/s0mesite.com/html/
/var/www/html/s0mesite.com/html/index.php
after I created /etc/apache/sites-available/s0mesite.com.conf file and wrote this there
<VirtualHost>
ServerAdmin admin#s0mesite.com
ServerName s0mesite.com
ServerAlias www.s0mesite.com
DocumentRoot /var/www/html/s0mesite.com/html
</VirtualHost>
after I wrote sudo a2ensite s0mesite.com.conf then sudo a2dissite 000-default.conf
then I reloaded Apache,
after I edited and added this line in /etc/hosts
83.xxx.xx.5 s0mesite.com
The interesting for me wast that when I ping domain it shows the right IP but when I load it in browser it endless loads, why is this?
Any help appreciated, This was something new to me and I hurried up to test it.
Related
I install Drupal 7.56 in my PC with MAMP. After installation complete, drupal admin screen appears.
Then, I create virtual host named "cast.dev".
When I type "cast.dev" in browser, it does not show anything and only shows "It works !".
I also create a front page. It does not show also. Could anyone tell me which part am I need to do more? Thanks .
Try to add the follwing
<VirtualHost *:80>
ServerName myproject.local
ServerAdmin webmaster#localhost
DocumentRoot /home/user/path/to/myproject_folder
<Directory /home/user/path/to/myproject_folder>
Require all granted
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then restart your Apache using the following command.
sudo service apache2 restart
Set up localhost file by adding the following code on the 'hosts' file from 'etc'.
127.0.0.1 myproject.local
For this,edit hosts using gedit with the following command :
sudo gedit /etc/hosts
At the moment I have this config in /etc/apache2/ports.conf:
NameVirtualHost *:80
Listen 80
All works fine, but I want to change it to:
NameVirtualHost 127.0.0.1:80
Listen 127.0.0.1:80
However after restarting apache, it displays the following error message:
[warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts
So I've updated the website VirtualHost file under /etc/apache2/sites-available/foo.com:
Original:
<VirtualHost *:80>
...
</VirtualHost>
Updated:
<VirtualHost 127.0.0.1:80>
...
</VirtualHost>
But after restarting apache, it shows the default apache2 index.html that is in /var/www instead of the project under /var/www/foo
This is the only enabled VirtualHost on the server.
Also here is my /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 debian
<publicIP> <foo.com> <serverhostname>
The host OS is Debian 7.
Any suggestions?
Have you symlinked the /etc/apache2/sites-available/foo.com to /etc/apache2/sites-enabled/000-foo.com.
The default apache configuration only reads virtual hosts from the sites-enabled directory and not sites available.
I am guessing that if you go to /etc/apache2/sites-enabled and type ls -la you will only see a configuration for default site and not your new site. If this is the case then symlink your foo.com into the sites enabled directory as follows ln -s ../sites-available/foo.com 001-foo.com
I don't think Listen 80 should have been changed to Listen 127.0.0.1:80. All other changes look ok.
Uninstall apache2 service
Run update cmd
Reinstall apache2
Edit virtual host
This worked for me.
I'm trying to add subdomains to my home server.
svn.domain.com
trac.domain.com
Due to dynamic IP I use dyndns service, on top of that I have domain.com hosted somewhere else. I created CNAME for subdomains on remote host to point to my user.dyndns.org domain.
So now when I visit either of subdomains: trac or svn, I see "It works!" message.
This done, I created two virtual host files under /etc/apache2/sites-enabled
file1: svn.domain.com and file2: trac.domain.com
contents:
<VirtualHost *:80>
ServerName trac.domain.com
DocumentRoot = /var/www/trac/repos
<Directory /var/www/trac/repos>
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And
<VirtualHost *:80>
ServerName svn.domain.com
DocumentRoot = /var/svn/repos
<Directory /var/svn/repos>
Order allow,deny
allow from all
</Directory>
</VirtualHost>
But I get error: ERROR: Site trac.domain.com does not exist!
what am I doing wrong?
I had this problem when upgrading from Apache 2.2 to Apache 2.4. The (ridiculous) solution was to ensure all files end with .conf, or a2ensite would ERROR: Site example does not exist!.
Also, when linked manually in sites-enabled, they would not even load without the .conf extension.
I also came across the same problem when I upgraded from Apache 2.2 to 2.4; all my virtual hosts suddenly broke and while trying to search for why this was the case, I stumbled across this question.
It turns out the reason is because of a difference between my old apache2.conf and the new apache2.conf. My old Apache 2.2 conf file had the line
Include sites-enabled/
whereas my new Apache 2.4 conf file had the line
IncludeOptional sites-enabled/*.conf
Lo and behold, when I changed the line to
IncludeOptional sites-enabled/
everything went back to normal.
Try moving the files to /sites-available. Then run a2ensite svn.domain.com and a2ensite trac.domain.com and reload Apache.
if you type a2ensite. it will prompt. Which sites do you want to enable (ie., after you put a .conf file in the sites-available and link it from sites-enabled.
a2ensite expect the full name of the conf file with the .conf extension
a2ensite ONLY accepts .conf files, so copy all sites in sites-available so the have a .conf extension (renaming didn't work itconfused the linkssomehow), erase the original files from sites-available AND sites-enabled. use a2ensite on the new files (you don't need to add .conf) and it all works, with our without the *.conf in /etc/apache2/apach2.conf
There must be some "memory" of the original file even when it is renamed -the symbolic link renames also, butthe erases & enabling "new" .con files works and you can then use a2dissite and a2ensite as before
1) remove all default site inside sites-enable
a2dissite <site-configuration-file-name>
2) take a closed look at your config file: start with a minimum properties like:
<VirtualHost [Domain]:80>
ServerAdmin webmaster#localhost
ServerName [Domain]
DocumentRoot [webAppPath]
<Directory [webAppPath]>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/my_domain_name_error.log
CustomLog ${APACHE_LOG_DIR}/my_domain_name_access.log combined
</VirtualHost>
My solution for local server name is replacing:
sudo a2ensite serverName
with
sudo a2ensite serverName.conf
I have on a server machine a local domain called "localwiki.com" that points to /var/www/wiki and works fine.
The sites-available and sites-enable configuration:
<VirtualHost *:80>
DocumentRoot /var/www/wiki/
ServerName localwiki.com
ServerAlias *.localwiki.com
</VirtualHost>
I wanted to create a second local domain for /var/www/doxygen (which I can access using "serverIP"/doxygen).
Here is the localdoxygen.com config file created at /etc/apache2/sites-available/localdoxygen.com
<VirtualHost *:80>
DocumentRoot /var/www/doxygen/
ServerName localdoxygen.com
ServerAlias *localdoxygen.com
</VirtualHost>
I used "a2ensite" in order to create a symbolic link in sites-enable pointing to localdoxygen.com in sites-available:
sudo a2ensite localdoxygen.com
I also have reloaded the new configuration:
sudo /etc/init.d/apache2 reload
And restarted apache:
sudo service apache2 restart
But the domain (localdoxygen.com), still doesn't work.
Any suggestions on how to fix this?
To solve the problem I had to add an entry to /etc/bind in order to activate the DNS for the domain.
I think those conf files must end in .conf to be loaded: i.e. localdoxygen.com.conf
disable the default site - a2dissite default (!!!)
DNS correct
check in /etc/apache2/sites-enabled have your sites
reload apache2 /etc/init.d/apache2 reload
You need to define a NameVirtualHost in your apache2.conf to support multiple domains under one IP.
NameVirtualHost 123.456.789.123:80
or
NameVirtualHost *:80
see also Running several name-based web sites on a single IP address.
Below is my config file:
NameVirtualHost 12.34.56.78:80
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /srv/www/domain1.com/public_html1/
ErrorLog /srv/www/domain1.com/logs/error.log
CustomLog /srv/www/domain1.com/logs/access.log combined
</VirtualHost>
<VirtualHost 12.34.56.78:80>
ServerAdmin admin#domain2.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /srv/www/domain2.com/public_html1/
ErrorLog /srv/www/domain2.com/logs/error.log
CustomLog /srv/www/domain2.com/logs/access.log combined
</VirtualHost>
The thing is when I put www.domain1.com into browser, apache2 doesn't retrieve the web page resides in /srv/www/domain1.com/public_html1/, instead, it gets the page from the default document root defined in another file. However, if I put www.domain2.com, everything works fine. I don't see any difference between two VirtualHost config block, so I wonder what does make the difference. BTW, I haven't put any .htaccess file under their document root.
Try checking your Apache config by issuing:
/usr/sbin/apache2ctl -S
I guess your "default" virtual host uses "www.domain1.com" as its ServerName, thus it responds to the request to "www.domain1.com".
On my machine this happened due to "www.domain1.com" being my machine's hostname. If ServerName is not specified, Apache tries to guess - causing the abovementioned problem.
I solved this by specifying "ServerName default" in sites-available/default.
This might be of some help as well:
http://httpd.apache.org/docs/current/dns-caveats.html
If you are on Windows and probably using a ZendSever, than you MUST do next:
Open file "hosts" in directory "C:\Windows\System32\drivers\etc"
Add
127.0.0.1 www.domain1.com
under
127.0.0.1 localhost
127.0.0.1 domain1.com
It should look like this:
127.0.0.1 localhost
127.0.0.1 domain1.com
127.0.0.1 www.domain1.com
127.0.0.1 domain2.com
127.0.0.1 www.domain2.com
127.0.0.1 domain3.com
127.0.0.1 www.domain3.com
All domains need to be registered in this file.
Just wanted to say that this caught me out too, and changing the ServerName in the default apache site worked for me, as did simply disabling that site using
a2dissite default
Then reloading apache.