Evening everyone,
Firstly, I apologize if this is the best location to ask this question so feel free to redirect me or this post :)
I have WAMP installed on C: but any projects will exist on a separate drive. I can create an alias to point to the correct directory just fine - no problem there. The problem lies in the fact that I want/need to have a custom URL assigned to each project (so instead of localhost/mysite it would be something similar to mysite.dev).
I found this article, but it's a bit old so I'm not sure if the information is still accurate. Here's what I have so far:
Edited hosts file to add domain - 127.0.0.1 mysite.dev
Edited WAMP's httpd.conf file to uncomment - Include conf/extra/httpd-vhosts.conf
Edited WAMP's httpd-vhost.conf file to add virtual host:
<VirtualHost 127.0.0.1>
DocumentRoot "d:/projects/mysite/"
ServerName mysite.dev
ServerAlias mysite.dev
<VirtualHost>
In the end this produces no errors, just a big fat 403 Forbidden Access "You don't have permission to access / on this server."
No idea where to go from here, this isn't exactly my area of expertise :P any and all help/tips are greatly appreciated! Thanks!
Try setting a port to listen for
<VirtualHost *:80>
DocumentRoot d:/projects/mysite/
ServerName mysite.dev
</VirtualHost>
After another hour or two I can actually answer my own question.
Someone on another forum mentioned that you need to keep a mention of plain ol' localhost in the httpd-vhost.conf file, so here's what I ended up with in there:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/wamp/www/"
</VirtualHost>
<VirtualHost *:80>
ServerName platypus.dev
DocumentRoot "d:/projects/test/"
<Directory "d:/projects/test/">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Exit WAMP, restart - good to go. Hope this helps someone else :)
Depending on which WAMP stack you're using, different, but very silimar configs in every stack. WAMP = (apache, mysql, php FOR Windows ... Win Ap My Php). There are different WAMP stacks, AMPPS, XAMPP, Bitnami.. You probably meaned WAMPserver (most people call it simply WAMP, but can mean also others, which has slightly different configs..)
If you're using WAMPserver, I think it's the easiest to config a "custom URL", that means virtual host. You just need to uncomment the vhosts config file in httpd.conf in apache's folder, and you already have a template of how to set virtual host in this file, there are 2 dummy hosts as examples. But, don't forget the Windows' "hosts" file, you need to set 127.0.0.1 [url_you_want] in your hosts file, and that [url_you_want] is the same in your apache vhosts config file as "ServerName"...
Related
I have a program called ‘project’ that I run from wamp, and everything goes correctly, the problem is that I'm getting the following warning every time I launch wamp:
It's a bad idea to add localhost in the url of launching projects. It is best to define VirtualHost in
wamp/bin/apache/apache2.4.37/conf/extra/httpd-vhosts.conf
file and not add localhost in the url.
I know there are similar questions with solutions, I have been reading several forums with solutions to solve the problem but I can not get the warning to disappear. In httpd-vhosts.conf I have the following:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Can you help me solve it? I get the same warning even if I replace 'localhost' in serverName and ServerAlias with: C:/wamp64/www/project/
My wamp version is 3.1.7 - 64bit:
Within c:\wamp64\wampmanager.conf under [options] you should see urlAddLocalhost = "on", try switching its value to off and restart WAMP.
I'm sorry that I couldn't find any documentation that explains it. I know it because I was looking for something that could link my projects directly from http://localhost and tracked this option from the WAMP scripts. When I enabled it the warning started to show.
PS.: I'm afraid this method I described works only for WAMPSERVER >v3.1
I'm trying to deploy my local Django site on my Ubuntu 12.04 server. I followed a tutorial, and everything seems to work fine, except Apache won't allow me to store my Django project under /root. More specifically, I get a 403 Forbidden when trying to access my site.
I suspect I need to configure my virtual host in a different manner. Any ideas?
Here is /etc/apache2/sites-available/mysite
<VirtualHost *:80>
ServerAdmin me#mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
WSGIScriptAlias / /root/me/index.wsgi
Alias /static/ /root/me/static/
<Location "/static/">
Options -Indexes
</Location>
ErrorLog /var/log/mysite/error.log
</VirtualHost>
Thanks for the comments. I'll mark this as the correct answer for future reference.
I ended up moving the whole Django project to /home/anotheruser, and defined DocumentRoot as per Aamir Adnans suggestion. After service apache2 restart it started working.
I'm using Wamp 2.2, edited conf/extra/httpd-vhosts.conf edited this file to add VirtualHosts , but when I un-commented line in httpd.conf to include httpd-vhosts.conf file, after restarting Wamp doesn't starts. If I revert changes is works fine.
Any ideas why is this happening?
This is code I'm using in httpd-vhost.conf:
<VirtualHost *>
ServerAdmin admin#localhost.com
DocumentRoot "C:/wamp/www" # change this line with your htdocs folder
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# WooCommerce Multisite
<VirtualHost dev.lo>
ServerAdmin admin#localhost.com
DocumentRoot "C:/wamp/www/dev"
ServerName dev.lo
ServerAlias dev.lo
<Directory "C:/wamp/www/dev">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Thanks
George
Edit
As Andreas Hagen suggested, I run Apache via httpd.exe.
First error was wrong parameter for DocumentRoot, as appears comment like was taken as second parameter, when DocumentRoot accepts only one.
Then I got warning: [warn] NameVirtualHost *:80 has no VirtualHosts. Did a quick search and found very helpful question - https://serverfault.com/questions/1405/apache-2-startup-warning-namevirtualhost-80-has-no-virtualhosts
Probably some bad config in vhosts file. Try to start apache from commandline so you get the error output. That will help you identify your problem.
Open your hosts file (\WINDOWS\system32\drivers\etc\hosts).
Add this line to the bottom:
127.0.0.1 test
This will tell your computer that any url that contains test will be routed to 127.0.0.1 (localhost).
Now open httpd.conf and add this to the very bottom of the file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/myfirstsite/"
ServerName testsite
</VirtualHost>
Now restart apache and navigate to: http://test/ (you may have to restart your browser for the changes to take effect.)
Hope this works.
Go to C:/drive and choose wamp folder
and go to C:\wamp\bin\apache\Apache2.4.4\conf and choose httpd.conf file.
Edit with notepad and go to 58 line number
change Listen 80 and replace Listen 8181 Save file and restart your Apache server
Now check url such like this localhost:8181
I have used this hop you will be success.
I've got a bit of a problem with forcing django based site and a "regular" sites i.e. wikis to work on the same machine, and to top it I'm kinda new to this stuff...
I've been trying to setup this using the VirtualHost but it seems that this does not work very well. In other words I can either run the django site (alredy in form of host.com/djangosite) and other sites in the same time (i.e host.com/othersite1). Only one works at a time it looks like the apache runs first VirtualHost it finds.
the structure in the server looks like this
/var/www/djangosite
/var/www/othersite1
/var/www/othersite2 ... etc
Now the sites-enabled, I experimented a bit and finally ended up in one file with two VirtualHosts for now:
<VirtualHost *:80>
ServerAdmin ss#dd.gg
DocumentRoot /var/www/djangosite
ServerName host.com/djangosite
Alias /m/ "/var/www/djangosite/forum/skins/"
<Directory "/var/www/djangosite/forum/skins">
Order allow,deny
Allow from all
</Directory>
Alias /upfiles/ "/var/www/djangosite/forum/upfiles/"
<Directory "/var/www/djangosite/forum/upfiles">
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /djangosite /var/www/djangosite/djangosite.wsgi
CustomLog /var/log/djangosite.access.log common
ErrorLog /var/log/djangosite.error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/othersite1
ServerName host.com/othersite1
</VirtualHost>
On their own both VirtualHosts do ok, i.e. when I put this in a file in sites-enabled the djangosite works fine, the second is not found, (something with document root being rooted at wrong dir in filesystem structure). If I put the second Vhost on top it works the djangosite doesn't.
Ok. so now a real question is there a recipe for running djangosite and "regular" site on one linux/apache configuration with one NIC and one hostname.
thanks for at least reading :)
You don't need two seperate VirtualHosts. Just put them both in the same one, with the ServerName as just "host.com". Then you can use aliases - the WSGIScriptAlias for the Django site, and a normal Alias for the wiki.
One note: please do not put your Django code in the DocumentRoot. This is dangerous - it makes it potentially possible for people to see your code, including your passwords etc in settings.py. Move it somewhere else, and leave out the DocumentRoot directive.
I have a system CentOS with Django and MySQL.
/home/user1/
-/vhost/*.conf
-/webapps/
abc.com
xyz.com
/home/user2/
-/vhost/*.conf
-/webapps/
123.com
789.com
Thanks for help!
UPDATE 1:
In httpd.conf:
User user1
Group apache
And httpd cannot access /home/user2/webapps.
You'll want to read up on Apache Vhost Configuration.
Tell us what you tried, what is working, what is not working, or what you don't understand.
Most common configuration
If your system has 1 IP address for all sites, you're going to want something like this:
#This is your 'default' host,
#people accessing the site via IP-address will see this site.
<VirtualHost *:80>
ServerName abc.com
ServerAlias xyz.com
DocumentRoot /home/user1/webapps/
</VirtualHost>
#This is the 123 and 789 vhost
<VirtualHost *:80>
ServerName 123.com
ServerAlias 789.com
DocumentRoot /home/user2/webapps/
</VirtualHost>
You can add all directives as explained by the <VirtualHost> Directive
EDIT: Updated question
There is a module called
perchild for apache that allows
to run different threads under
different users, configurable by
vhost. The module is not considered
functional, and not under current
development. Unless you know what
you're doing or are willing to take
the risk, you probably shouldn't use
it.
Another solution might be mpm-itk,
which appears to be more reliable.
Read this serverfault question
for more information, or visit their
homepage.
If you don't want to use either of both modules, you could always create a new user and group, run both vhosts under that user, and make both homedirs readable to the user by setting their group to the new group.