So I have www.example.com and m.example.com. Now when I go to m.example.com I see the same content as www.example.com. I have an index.php inside the m.example.com, so I'd expect that to show instead.
Here's my m.website.com.conf
<VirtualHost *:80>
ServerName m.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/m/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And a part of my apache2.conf
<VirtualHost *:80>
ServerAdmin web#webite.com
DocumentRoot /var/www/m
ServerName m.example.com
ErrorLog /var/log/apache2/mlog.log
</VirtualHost>
So now I'd expect it to work off of /var/www/m, and inside that I have a separate file that isn't rendering, because the main domain takes it over. Any help would be great.
For adding virtual hosts to your Apache use this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-debian-7
It's my first time seeing someone that puts virtualhost information on 2 files, both at the apache2.conf and at the sites-available folder. In my setup, I have an "include" statement in my apache2.conf file which includes the files in the sites-enabled directory and not other information at all - this is the default for Debian Linux, I didn't touched it at all. I put all my virtualhost configurations in the sites-available directory. That's where you should put them also.
Related
Actually, I downloaded PHP7.2.7 safe thread from PHP's website(php.net) and I don't know if it is possible I can configure PHP to setup a virtualhost like we can do using XAMPP
You can try below configuration:
1) Entry in hosts file as below
127.0.0.1 example.com
2) Set virtual host in httpd-vhosts.conf as below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example/public_html"
ServerAlias quickstart.com
<Directory "/var/www/example/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
PHP has a built-in web server, but is has limited capability. It does not provide all the configuration options a complete web server does. It does not do VirtualHost.
If you need VirtualHost, you will have to include it as a module inside Apache (or other web server). The module will be global. If your pages in a VirtualHost do not need PHP, PHP remains dormant and does nothing.
PHP isn't a web server, you need to create a VirtualHost in Apache. If you're using Linux, open up httpd.conf or /etc/apache2/sites-enabled/000-default.conf
and enter the following lines.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to restart your web server/apache in order to these changes to work.
Currently, I have XAMPP setup to where typing 127.0.0.1 in the browser redirects me to the home page found within htdocs.
I would like to be able to type "devtest" and have that be an alias for 127.0.0.1.
What I have tried so far is modifying: C:\xampp\apache\conf\extra\httpd.vhosts.conf where I added an entry that looks like:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot C:\xampp\htdocs\Workspace\MyProject
ServerName devtest
ErrorLog C:\xampp\htdocs\Workspace\MyProject\MyProject-error_log
CustomLog C:\xampp\htdocs\Workspace\MyProject\MyProject-access_log common
</VirtualHost>
Is there another step I'm missing?
Open the hosts file in Notepad:
C:\Windows\System32\drivers\etc\hosts
Add the line:
127.0.0.1 devtest
Navigate to: http://devtest
Use this, and make sure you enable using vhosts config file in apache.
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\Workspace\MyProject"
ServerName devtest.local
<Directory "C:\xampp\htdocs\Workspace\MyProject">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I am a complete novice when it comes to WAMP, apache etc.
I'm trying to get a site to run locally but so far not having any luck. I've got as far as installing WAMP and it seems to be going online fine, i.e. the green "W" icon is green. Features like phpmyadmin seems to be working. When I click "localhost" it opens the browsers and navigates to localhost as you'd expect, however, all I see is the directory listing.
So, I have virutal hosts set up as follows:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/bts/BiteTheSun"
ServerName bts
ServerAlias bts
<Directory "c:/wamp/www/bts/BiteTheSun">
Require all granted
</Directory>
</VirtualHost>
and in my hosts file I have:
127.0.0.1 localhost
127.0.0.1 bts
::1 bts
::1 localhost
I've added some images just to be clear as to the issue - the top image shows what I think I should be seeing and the bottom shows what I actually see:
localhost screenshot issue
I've tried everything I can think of to no avail. It might also help to mention that in the log file [apache_error.log] I seem to get errors relating to permissions:
"AH01630: client denied by server configuration: C:/Apache24, referer: http://localhost/"
However, I've gone through the permissions set in the config files using examples from several sources and nothing seems amiss.
Has anyone any idea what is going on here? I have searched online high and low on this and on one else seems to have exactly this issue which makes me think it is me doing something very silly - I just need someone to point out how exactly! :)
Richard
Is there an index file in your www folder?
Typically, you want to place your individual projects within the www folder and point your virtual hosts to the www/your-project/ folder which should contain an index.php file (unless you have a custom set up where you are going to point your virtual host directly to a specific file).
Your Virtual Host definitions are incomplete.
Each VH should have its own <Directory>...</Directory> definitions so you can apply the access and other config information to that directory.
The parts you are missing are AllowOverride and Options.
The other thing to remember is that when you create a Virtual Host environment the host defined in the httpd.conf file is basically ignored and the VH's take presidence. This is why you need to redefine the localhost in the VH file.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/bts/BiteTheSun"
ServerName bts
<Directory "c:/wamp/www/bts/BiteTheSun">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
Your AH01630: client denied by server configuration: C:/Apache24 error is likely because the default httpd-vhost.conf file comes with 2 example definitions as supplied by Apache. These should be completely deleted from the file. So if you left these in the httpd-vhost.conf file. Delete them completely from the file.
Example of the defs to remove. Note they use the c:/Apache24 directory which does not, and should not exist in a WAMPServer environmant!
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
I'm using WAMPSERVER to run a wordpress site that has to be acessible by the users in my network, like a environment for testing together.
Localhost works fine, but at first i couldn't access the aplication from other computers in the network. I created a rule to open the port 80, created an Alias in the Apache configuration, and it worked but the theme and any images inside subfolders wouldn't load and the console was returning lots of 404 responses.
I want to map the subfolders and its files that are under the 'base dir' of the site. I tried tons of options in the Apache conf. file but i couldn't make it.
Attached a printscreen of the responses, the apache conf file and the windows hosts file
Httpd.conf :
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#animamidia
DocumentRoot "C:\wamp\www\website"
ServerName www.animamidia
ErrorLog "logs/animamidia-error.log"
CustomLog "logs/animamidia-access.log" common
<Directory "C:\wamp\www\website\*">
Options FollowSymLinks Includes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Windows hosts file:
127.0.0.1 www.animamidia
The site with it's theme broken because the requisition returned a 404
Well i found the problem.
Even though i couldn't enter the wordpress-admin i decided to check the 'wp-config.php' file just in case something is wrong or missing.
And what i did find is that the 'Home-URL' and the 'WP-URL' were set at 'localhost/website' which means that all the requisitions would point at this location as a base directory.
All i had to do was to use the 'define' comand and set the site's URL to the machine's IP and now the environment is all set up for the guys over here to develop and test their stuff.
I am trying to setup WordPress multi site on my ubuntu 10.04 laptop with apache2.
For normal WordPress installs in create an entry in the /etc/hosts file and create virtual hosts entry in /etc/apace2/sites-available directory and then soft link it to sites-enabled directory.
For sub domains, I added the server alias directive. But that is not doing anything. Do I have a syntax error. Please advice.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias mysite.com *.mysite.com
DocumentRoot /home/myhome/Sites/public_html/mysite.com
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
#we want specific log file for this server
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>
You must restart or reload Apache after making changes to your Apache configuration file. What does it tell you when you run:
sudo /etc/init.d/apache2 restart
Does it show you any error messages? That will tell you if you have a syntax error. For your reference, here is an example of using ServerAlias that I have on my own server. Note the difference between mine and yours. Maybe you should remove the initial mysite.com part and just leave *.mysite.com?
Let me know if that helps.
<VirtualHost *:80>
ServerAdmin jesse#domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/vhosts/domain.com/httpdocs
ServerName domain.com
ErrorLog /var/log/domain.com-error_log
CustomLog /var/log/domain.com-access_log common
</VirtualHost>