Virtual Host with WAMP - wamp

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.

Related

Google Cloud Platform LAMP setup Laravel 5.4

Looking for help on server problem. I have followed the following steps to set up LAMP on the VM
https://cloud.google.com/community/tutorials/setting-up-lamp
I put my Laravel 5.4 website onto the VM, configure the .env for the following:
APP_URL=website_external_IP
But when I access the website by inserting the website_external_IP on my browser, it returns the following image.
Sorry for being noob of server problems but please let me know what else information should I provide for you to figure out the cause of it. Thank you!
1 EDIT:
In response to John Hanley's suggested site. I further made the following edits on the apache conf:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/laravel_project.conf
sudo vim /etc/apache2/sites-available/laravel_project.conf
and there vim the laravel_project.conf as followings
NameVirtualHost *:8080
Listen 8080
<VirtualHost *:8080>
ServerAdmin admin#example.com
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /home/user/projects/laravel_project/public
<Directory /home/user/projects/laravel_project/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then
sudo vim /etc/hosts
and add the following line:
127.0.0.1 laravel.dev
then disabled the original conf settings and enable for my site:
sudo a2dissite 000-default.conf
sudo a2ensite laravel_project.conf
Without having the full understanding of the new edits procedures, accessing the page with IP returns the following error:
You don't have permission to access / on this server.
Your Apache web server has directory browsing enabled. Also you do not have a default page present (or enabled) therefore you server is serving up the directory listing.
/etc/apache2/apache2.conf
Remove the word Indexes from this part of your configuration:
<Directory /var/www/>
Options Indexes FollowSymLinks
...
</Directory>

How to put Django within a subdirectory of a website?

I want to run WordPress at mysite.com/, because it's easier to edit sales copy and such. I want to run my Django site within mysite.com/members/
httpd.conf:
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com
WSGIDaemonProcess mysite python-path=/var/www/mysite.com/mysite:/var/www/mysite.com/
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite.com/mysite/mysite/wsgi.py
</VirtualHost>
What exactly do I need to do so that Django runs within the /members/ directory on my domain/website?
Use:
WSGIScriptAlias /members /var/www/mysite.com/mysite/mysite/wsgi.py
Do be aware that by doing that, since you have made the mistake of setting DocumentRoot to be a parent directory of your source code, people will be able to download the source code, including sensitive information in the settings module.
So, do not set DocumentRoot to be what you have. Have it refer to an en empty directory, of the default htdocs directory for the whole server.
To follow up on the previous answer and comments, here's an example of how I might do this if I had to:
<VirtualHost *:80>
# WordPress
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com
# Django
WSGIDaemonProcess mysite python-path=/var/django/django_project/virtualenv/django_project
WSGIProcessGroup mysite
WSGIScriptAlias /members /var/django/django_project/django_project/wsgi.py
Alias /members/static/ /var/django/django_project/static/
</VirtualHost>
Definitely understand the security concerns raised in comments, however.

Aid in setting up a Virtual Host with Wamp in Windows Vista

I need some help in setting up this thing.
I followed a tutorial about setting up a virtual host in WAMP which included the following steps:
Opened file httpd.conf in folder C:\wamp\bin\apache\apache2.2.6\conf and uncommented the last # of the following statement:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf"
to look like this:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Opened the file httpd-vhosts.conf in folder C:\wamp\bin\apache\apache2.2.6\conf\extra, deleted everything in there and replaced with these codes below:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.jagerseow.servegame.com (WHICH IS A DOMAIN A REGISTERED IN NO-IP)
ServerAlias jagerseow.servegame.com domain
DocumentRoot C:/wamp/www/MP4Public
ErrorLog "C:/wamp/www/MP4Public/logs/error.log"
CustomLog "C:/wamp/www/MP4Public/logs/access.log" common
</VirtualHost>"
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog "C:/wamp/www/logs/error.log"
CustomLog "C:/wamp/www/logs/access.log" common
</VirtualHost>
Used Notepad to open file hosts in folder C:/Windows/System32/drivers/etc on server computer; then, deleted and replaced the default codes with these codes:
127.0.0.1 localhost
127.0.0.1 domain
Restarted WAMP and waited until it turned green, which it did ...
Try to connect to my server page by typing domain in the browser and my web page showed up normally. However when anyone, including myself, tries to open it by typing the address (http://www.jagerseow.servegame.com), no page is loaded.
I'm running Windows Vista 32-bit. Anyone can tell me what I'm doing wrong?
Change your Virtual Hosts definition to this:-
NameVirtualHost *:80
## must be first so the the wamp menu page loads
## and stray hacks get sent here and ignored because access
## is only allowed from local ips (127.0.0.1 localhost ::1 )
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.jagerseow.servegame.com
ServerAlias jagerseow.servegame.com
DocumentRoot "C:/wamp/www/MP4Public"
# changed, dont want your logs available under your docroot directory (security)
ErrorLog "C:/wamp/www/logs/MP4Public_error.log"
CustomLog "C:/wamp/www/logs/MP4Public_access.log" common
<Directory "D:/wamp/www/MP4Public">
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>"
Now you need to change your hosts file to :-
127.0.0.1 localhost
127.0.0.1 jagerseow.servegame.com
After changing this do the following, or reboot.
Run a command window Run as Administrator and do
net stop "DNS Client"
net start "DNS Client"
This will force a refresh of the DNS Cache and make the new domain name available on your PC.
The hosts file is loaded by windows into its DNS cache. It pre-loads urls and is a bit like a very low function DNS. So this tell the dns cache and therefore your browser etc that jagerseow.servegame.com is found on ip address 127.0.0.1 which is this PC
If you actually did want the universe to be able to see this site, I assume you do as you used Allow from all, you will then have to port forward port 80 on your router to the ip address of the PC running wamp. Also that PC will need a STATIC ip address so it does not change when you reboot. Help for that can be found here PortForward.com

Trying to set up custom url (mysite.dev) using WAMP

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"...

Django urls.py catches all existing HTML projects' urls on WampServer

I had WampServer working perfectly with Aptana IDE using multiple folders for different html projects. Then I installed Django and added this to Apache's httpd.conf:
Alias /images/ "c:/wamp/www/daas/templates/images/"
<Directory "c:/wamp/www/daas/images>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / "c:/wamp/www/daas/apache/django.wsgi"
<Directory "c:/wamp/www/daas/apache">
Allow from all
</Directory>
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot c:/wamp/www/daas/
</VirtualHost>
and now the virtual hosts I had for html projects...
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot 'C:\wamp\www'
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName projectA.local
DocumentRoot 'C:\wamp\www\projectA'
</VirtualHost>
don't load correctly because Django's urls.py is catching all urls The current URL, projectA, didn't match any of these regular expressions, even the ones not inside the Django's projects.
How can I solve this? On Djano's side or on Apache's side? Here (How do i run Django and phpmyadmin on apache webserver on ubuntu) is a similar problem but the solution didn't worked for me. And luckily localhost/phpmyadmin works correctly but localhost/projectA doesn't.
It looks like WSGIScriptAlias / "c:/wamp/www/daas/apache/django.wsgi" in your httpd.conf catches all requests on apache.