Unable to start Zend2 skeleton app - php

I have a xampp serwer on windows XP:
Apache 2.4.3
PHP 5.4.7
and I try to start learning Zend2.
I downloaded skeleton app: https://github.com/zendframework/ZendSkeletonApplication
and run from cmd:
php composer.phar self-update
php composer.phar install
(not that I had to give a full link to php like C:\xxx\php.exe - I don't know why, I have php in my enviromental variables). It went ok - no errors.
I added this code to httpd-vhosts.conf :
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot /zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory /zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I also added this line to C:\WINDOWS\system32\drivers\etc\hosts
127.0.0.1 zf2-tutorial.localhost localhost
When I run
http://zf2-tutorial.localhost
in the browser I get "Permission denied"
When I try
http://localhost/zf2-tutorial/public/
I get very long php error
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in C:\xampp\htdocs\zf2-tutorial\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:302 ...........
I figure sth is wrong with serwer since I get "Permission denied".
What I am doing wrong? Thx in advance.
BIg Thanx Everyone. My final config:
<VirtualHost *:80>
ServerName zf2-tutorial.localhost
DocumentRoot C:/xampp/htdocs/zf2-tutorial/public
SetEnv APPLICATION_ENV "development"
<Directory C:/xampp/htdocs/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
127.0.0.1 zf2-tutorial.localhost
Works fine on: http://zf2-tutorial.localhost/

Your hosts file is incorrect. Instead of:
127.0.0.1 zf2-tutorial.localhost localhost
Remove the last "localhost", so you get:
127.0.0.1 zf2-tutorial.localhost
Edit:
Another thing I just noticed is your DocumentRoot: this should be the fully qualified path to your document root: i.e. C:/www/zf-tutorial/public. Note that you should use forward slashes for directory separators. Use the same path in your Directory configuration to make sure that access is allowed to that directory.

It seems you are using Windows, so your vhost configuration should contains Windows alike path to your project. Are you sure that you have valid path to php\bin in your %PATH%?
> echo %PATH%
I am using XAMPP on Windows 7.
Here is my vhost configuration:
<VirtualHost *:80>
##ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "C:/xampp/projects/zf2-tutorial/public"
ServerName zf2.tutorial
##ServerAlias www.dummy-host2.localhost
SetEnv APPLICATION_ENV "development"
<Directory C:/xampp/projects/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/zf2.tutorial-error.log"
CustomLog "logs/zf2.tutorial-access.log" combined
</VirtualHost>
This one is essential (probably also in your case):
<Directory C:/xampp/projects/zf2-tutorial/public>
# ...
Require all granted
</Directory>

Related

How can I run my Laravel project without cmd command "php artisan serve"?

<VirtualHost *:80>
ServerAdmin webmaster#hujjaj.dev
DocumentRoot "C:\xampp\htdocs\hujjaj_app_new\public"
ServerName hujjaj.dev
ErrorLog "logs/hujjaj.dev-error.log"
CustomLog "logs/hujjaj.dev-access.log" common
I am doing so in my virtual host file and update 127.0.0.1 hujjaj.dev then i restart XAMPP and after that I navigate to localhost/hujjaj.dev but showing 404|Not Found.
Please try the following
<VirtualHost 127.0.0.2:80>
DocumentRoot “D:\laravel-gkb\public”
DirectoryIndex index.php
ServerName laravel-gkb.test
<Directory “D:\laravel-gkb\public”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then add the save domain in your hosts file
127.0.0.2 hujjaj.dev
Refer this for more details : link
Yes, There is another way to run laravel project, with following command..
php -S 127.0.0.1:8001 server.php
This will run your application at 127.0.0.1:8001 mentioned address.
Note: laravel default entry point is server.php thats why we mentioned it. other wise it will be index.php

Why can't view the my project in zend framework 1.12

I am struck Here, create one project, project name is medicals.
I am Using xampp. i wrote in http.conf like.
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs/medicals/public"
ServerName medicals.com
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "C:/xampp/htdocs/medicals/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And,Using Windows path:C:\Windows\System32\drivers\etc point to.
127.0.0.1 medicals.com
i have an error im my browser to access the medicals.com.
Where is the actual issue. i did't understand.
Thhanks in advance.
Please Confirm your port is 80, In case you use another port in xampp u can change the line <VirtualHost *:80> to <VirtualHost *:8080>, the 8080 is a port number second commonly used, you change 8080 into your port,
your port number shown in xampp control pannel PFA
Copy following code :
<VirtualHost *:80>
ServerName medicals.com
DocumentRoot "C:/xampp/htdocs/medicals/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/medicals/public">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
To:
C:/xampp/apache/conf/extra/httpd-vhosts.conf
And also add following line :
127.0.0.1 medicals.com
to
C:/Windows/System32/drivers/etc
And also make sure your mod_rewrite is enabled and don't forget to restart your apache server after change.
This works for me in zf3. If it does not work in zf1 you may want to look at this.
https://framework.zend.com/manual/1.10/en/project-structure.rewrite.html

Setup VirtualHost for Zend Application on Wamp server

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.

How to access files outside the DocumentRoot in a VirtualHost in XAMPP?

I have a Virtual Host configured in Windows 7. The project is located in C:\project with the following structure:
project
\cache
\configs
\htdocs
\css
\images
\js
\.htaccess
\index.php
\includes
\setup.php
\en.php
\lib
\templates
\templates_c
In my httpd-vhosts.conf, I created a VirtualHost:
<VirtualHost *:80>
DocumentRoot "C:/project/htdocs"
ServerName project.dev
<Directory "C:/project/htdocs">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
And added 127.0.0.1 project.dev to the C:\Windows\System32\drivers\etc\hosts.
The problem is that I want the htdocs to be the directory from which httpd will serve files but I want to include, with PHP, files, for example, located in the includes directory.
How can I solve this problem? I already tried so many solutions from $_SERVER['DOCUMENT_ROOT'] to Apache Alias and .htaccess tweaking but none have worked so far. There must have be some easy solution. Maybe I'm not understanding quite correctly the concept of DocumentRoot. I just want to emulate the typical server folder public_html/www/htdocs while keeping important files out of the browser/user scope.
This is a VHost I took from my httpd-vhosts.conf. The only extra configuration I made was to get around the 403 I was hitting:
<VirtualHost *:80>
ServerName "Markdown.loc"
ServerAlias "www.Markdown.loc"
DocumentRoot "C:\INTERNAL\PHP\Markdown"
<Directory "C:\INTERNAL\PHP\Markdown">
Options +Indexes
AllowOverride All
</Directory>
</VirtualHost>
All my other VHosts look like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/somesite.loc"
ServerName somesite.loc
ServerAlias www.somesite.loc
</VirtualHost>
If you're simply looking to include something from a dir on the same level as your htdocs though, include("../includes/somefile.php") should work just fine.
If I've got your problem wrong, let me know, and I'll try to help you more.
Set your include path within your virtualhost or .htaccess:
php_value include_path ".;c:/project"

Problems in installing Laravel at localhost

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

Categories