First time cake user and I'm having real apache problems. For some reason the .htaccess is trying to find
File does not exist: /Library/WebServer/Documents/Users
but there is no such directory as Users. I have tried setting up the following also:
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80 >
DocumentRoot "/Users/username/Sites/mysite/app/webroot"
ServerName mysite.dev
ServerAlias www.mysite.dev mysite.dev *.mysite.dev
<Directory "/Users/username/Sites/mysite/app/webroot">
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 mysite.dev
/etc/apache2/users/username.conf
<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
That also hasn't worked, but with a different error Failed opening required 'cake/libs/cache/file.php'
Although I'd rather not use virtual hosts, and just run it off localhost
Seems like the solution that worked for me was to edit /etc/apache2/users/username.conf and add this at the top:
DocumentRoot "/Users/username/Sites"
And the default cakePHP download now runs ok.
Looks like Apache is trying to find your webroot in a different location--the default location, if memory serves. If you want to use virtual hosts (which would be my recommendation, for whatever it's worth), ensure that the NameVirtualHost directive is uncommented. By default, it's commented out:
NameVirtualHost *:80
If you'd prefer not to use virtual hosts for whatever reason, ensure that the NameVirtualHost is commented out (your <VirtualHost> blocks will be ignored) and change the DocumentRoot value to the proper directory:
DocumentRoot "/Users/username/Sites/mysite/app/webroot"
That should tell Apache to look in the right place.
Related
This problem has been bugging me for days and I really need an answer.
I have a previous WAMP server in which I have configured properly so I can set up virtual hosts for applications that I build. It served me well for months.
Recently, there's this software, in which I think is a Malware, that run in my pc. The software was removed and I scanned the pc and there were no viruses.
I re-installed WAMP server and configured it again. It went well but the virtual hosts are not behaving properly.
These are what I have declared:
In httpd-vhost:
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/Thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/Thesis">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
In my hosts file:
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
The thing is, I am able to access the pixtcha.dev properly and there were no problems, while the copers.com is inaccessible, when I type it, it redirects me to some website from the web. I just don't understand why this happens. I even tried flushing the dns if there were corrupted local files but I just can't figure it out.
Also, I have tried using the server names from my previous virtual host and they are all inaccessible too. They are giving me:
http://copers.edu.ph is not available
So I resorted to using new server names, but I don't understand why can't I use the previous server names from my previous WAMP configuration. :(
What do you think are the problems? And how to solve them?
Please help. Thanks in advance.
Ok a couple of things that might help here.
As Apache 2.4 is IPV4 and IPV6 aware you need to change your HOSTS file like this so if the browser decides to use IPV6 it knows where to find your domains. I wish I knew what controls the broswers decision, but I dont.
127.0.0.1 localhost
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
::1 localhost
::1 pixtcha.dev
::1 copers.com
Dont forget to restart the dnscache or reboot after changing this file.
From a command windows, started using the 'Run as Administrator' option, do these 2 commands to restart the dnscache.
net stop dnscache
net start dnscache
Also when you create Virtual Hosts the default host, as defined in httpd.conf, is ignored, so you need to add a VHOST definition for localhost.
Also you are using old Apache 2.2 syntax in your VHOST definitions, incorrectly as well as it happens, and this should be changed to Apache 2.4 syntax
Also it is better to stick to lower case for directory names, Windows does not care but if you ever move code to a Unix live server it may cause confusion.
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/thesis">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
Check and make sure that your scripts (PHP?) in your copers.com root (index.php?) are not redirecting to these outside URLs, or to URLs further inside your local site that would redirect outside as well.
Also in Chrome, you can open the Network tab of Developer Tools to see what actual web requests are being made, and in what order.
I need to set my url for my site to appear as mydomain.com/ and have apache recognize that as the webroot.
Currently my url looks like:
###.###.##.##/laravel/public
and I want it to become:
mydomain.com/
This is the first site I've worked on from scratch, so I'm not completely sure what information I should include here.
Current apache httpd.conf:
NameVirtualHost *:80
NOTE: NameVirtualHost cannot be used without a port specifier
(e.g. :80) if mod_ssl is being used, due to the nature of the
SSL protocol.
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for requests without a known
server name.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/html/foo_bar/public
ServerName foo.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
<Directory /var/www/html/foo/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
First you'll need to edit your httpd.conf (usually located somewhere like /etc/apache2/conf).
Look for a line like <Directory "/var/www">. This is telling apache the root directory from which you want to work. /var/www in your case will be whatever directory laravel/public is living in on your websever currently.
If you change that line to <Directory "/var/www/laravel/public"> (assuming /var/www is where your laravel app is), save the file and restart apache, then you should be serving mydomain.com from inside laravel/public.
I'm working locally on my Macbook Pro using XAMPP and I'm trying to setup virtualhosts so that I can work on multiple projects more easily.
Everything appears to be working fine except I can't connect to MySQL through PHPMyAdmin and on the XAMPP control panel it says MySQL isn't running. However, I can access MySQL through an application I have in my htdocs folder. When I access phpmyadmin through localhost/phpmyadmin the CSS is loaded and PHPMyAdmin appears to be located, but MySQL can't connect so I'm not quite sure where the issue lies (considering I can connect through my application)
Upon going to localhost/phpmyadmin I get the following error
#2002 - No such file or directory
The server is not responding (or the local server's socket is not correctly configured).
The thing is, I can access the database just fine through the application. I can log in, save and do any other sort of interactions with the database.
Here's what I have in my httpd-vhosts.conf file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/test1"
ServerName localhost
<Directory /Applications/XAMPP/xamppfiles/htdocs/test1>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName pma
DocumentRoot "/Applications/XAMPP/xamppfiles/phpmyadmin"
<Directory /Applications/XAMPP/xamppfiles/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
</VirtualHost>
Now for a summary
I set up virtualhosts for apache on my Macbook
The virtualhost setup appears to be working fine for the application I have in my htodcs folder, and it can connect to the database. I can log in, save data and all that stuff.
When I browse to localhost/phpmyadmin I get a MySQL connection error. If I browse to pma/phpmyadmin (the virtualhost I tried to create) Chrome and Firefox just search google for it instead of recognizing the alias (is that the correct term?)
I ran into the same thing with a WAMP server. I solved it by putting back the original "out of the box" server settings:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache2/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>
And then for each project used code such as:
<VirtualHost *:80>
ServerAdmin admin#localhost
DocumentRoot "C:/wamp/projectname"
ServerName localhost
ServerAlias projectname.here
<Directory "C:/wamp/projectname">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all # <-- used for Apache 2.2
#Require all granted #<-- used for Apache 2.4+
</Directory>
</VirtualHost>
For different projects, just duplicate the last set of code for each project, renaming the DocumentRoot, ServerAlias and Directory path. You will notice the "ServerAlias" line; this is what made Apache serve up the project when entering the alias in the web browser. I found the explanation here which ironically was in the httpd-vhosts.conf file.
Also, please note that my research recommends for higher versions of Apache to use Require all granted in place of Allow from all as commented in the code above.
All of this code is in the httpd-vhosts.conf file, which on my Windows 7 installation is at c:\wamp\bin\apache\Apache2.2.21\conf\extra directory. Since you are using a Macbook and have already identified the location, I just put this in for other's reference.
I'm following this tutorial to learn how to start a project using ZendFramework
http://framework.zend.com/manual/1.12/en/learning.quickstart.create-project.html
When I get to setup a virtual host I get stuck. If I do exactly as the tutorial says, it shows me an error (in all my project, zend or not), says the file wasn't found.
Then I found this tutorial on StackOverflow very handy
Can't run zend framework MVC application on WAMP
Following what the guy on the bottom of the page says takes me to the same error when I try to access my app as zendProject.local/
This is what I got
on hosts (Windows/System32/drivers/etc/hosts) file
127.0.0.1 blog.local
on httpd-vhosts.conf file
<VirtualHost 127.0.0.1>
ServerName blog.local
DocumentRoot /blog/public
SetEnv APPLICATION_ENV "development"
<Directory /blog/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Can you tell me what I am doing wrong? The browser still says Not Found The requested URL /public was not found on this server when I go to http://blog.local/
I'm running WAMP on Windows. And this is the absolute path to the 'blog' project C:\wamp\www\blog
#Edit RiggsFolly
this is what I got now in the httpd-vhosts.conf file
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
AllowOverride All
# make sure this is only allowed to be accessed by the local machine
# then if/when you open one of your other sites up to the internet and somebody uses your IP
# they will get directed here as its the first VH def and then receive a 403 not allowed to access
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName blog.local
DocumentRoot "C:/websites/blog/public"
Options Indexes FollowSymLinks
SetEnv APPLICATION_ENV "development"
<Directory "C:/websites/blog/public">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
And I created a new directory at C:/ called 'websites' as you suggested
You need to be a little more specific with your folder locations. I guess this tutorial was written for Unix and you are using windows.
For Apache 2.2.x use this syntax:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName blog.local
DocumentRoot "C:/wamp/www/blog/public"
Options Indexes FollowSymLinks
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/blog/public">
DirectoryIndex index.php
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
You would be better avoiding the Allow from all and using Allow from localhost 127.0.0.1 ::1 until you actually want to allow the universe to see your sites.
For Apache 2.4.x use this syntax:
<VirtualHost *:80>
ServerName blog.local
DocumentRoot "C:/wamp/www/blog/public"
Options Indexes FollowSymLinks
SetEnv APPLICATION_ENV "development"
<Directory "C:/wamp/www/blog/public">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
Note NameVirtualHost *:80 no longer required for Apache 2.4.x
Again you would be better avoiding the Require all granted and using Require local until you actually want to allow the universe to see your sites.
EDITED After comment from Questioner:
Right, that's the Apache default. If you enter a url it cannot find a Virtual Host definition for it will default to the first Virtual Host definition you gave it, the blog in your case.
Ok, so now you need to create a Virtual Host for each of your other projects, and MOST IMPORTANTLY the first one needs to be localhost and only be allowed to be accessed from the local PC for a bit of extra security.
Now personally I would take this opportunity to move my actual sites to a totally separate folder structure outside the \wamp\ folder structure so there is no confusion with rights given to the \wamp\www folder and my other sites.
So for example, create a folder c:\websites\www and in that folder create a folder for each of your projects eg
c:\websites\www\blog
c:\websites\www\project2
Then point your virtual hosts to the relevant folder containing the site code ( this can be on another disk if you like ). This allows you to specify the Apache security ( who is allowed in to this site) specifically for each of your VHOSTS. So when you want a client or friend to be able to play with one site, you just change the security on that one site while you let them play.
Like this:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
AllowOverride All
# make sure this is only allowed to be accessed by the local machine
# then if/when you open one of your other sites up to the internet and somebody uses your IP
# they will get directed here as its the first VH def and then receive a 403 not allowed to access
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName blog.local
DocumentRoot "C:/websites/www/blog/public"
Options Indexes FollowSymLinks
SetEnv APPLICATION_ENV "development"
<Directory "C:/websites/www/blog/public">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName project2.dev
DocumentRoot "C:/websites/www/project2"
Options Indexes FollowSymLinks
<Directory "C:/websites/www/project2">
DirectoryIndex index.php
AllowOverride All
Require local
# this site also available to other PC's on my internal network
Require ip 192.168.0
</Directory>
</VirtualHost>
Remember, for each new Virtual Host site you create you also need to add that ServerName (project2.dev) to the hosts file.
hosts file:
127.0.0.1 blog.local
127.0.0.1 project2.dev
I hope this helps.
I am trying to install PHP-Laravel in Windows 8 and I am using Xamp server(localhost). I am following Installing Laravel guide.
According to this guide I am making virtual host using following code :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
//Where "C:/xampp/htdocs/TssApp/public" is path of Laravel public folder
and I have also added following line in in etc/hosts
127.0.0.2 TssApp
After doing necessary steps mentioned in this tutorial when I type "http://TssApp" , it always redirect to "http://tssapp/xampp/" instead of Laravel Home page. I don't know if I am missing any thing.
Note: I can access laravel home page at "http://localhost/tssapp/public/" but want
to use "http://TssApp" link to access my application.
Please help me regarding this issue.
Thanks .
Do you have NameVirtualHost * in your virtual-hosts configuration?
You'll need to restart Apache after any changes to either /etc/hosts or your virtual-hosts configuration files
Try adding the code to C:\xampp\apache\conf\extra\httpd-vhosts.conf instead of adding it to your own conf file. As far as I know xampp will ignore it unless its in the vhosts file.
You could try this.
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\TssApp\public"
ServerName tssapp
<Directory "C:\xampp\htdocs\TssApp\public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Although you should put your files in the xampp directory and not the htdocs directory, so your files should be C:\xampp\TssApp\public, This would stop people from visiting htdocs which is a public folder and getting access to your application.
According to the documentation (that you point to), you should write
<VirtualHost 127.0.0.2>
and not
<VirtualHost *:80>
Could you try that and restart your computer/server?
Add in:
Allow from all
after
AllowOverride all
The end result should be:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Allow from all
</Directory>
</VirtualHost>
Also make sure you are editing the file "httpd-vhosts.conf" found in:
C:\xampp\apache\conf\extra