cannot reach symfony app on my debian 404 Not Found - php

looking for solutions for a small challenge
i have my local network (router)
i have debian server on first machine where i have installed a symfony in /var/www/my-symf-app
i changed /etc/site-available
and
/etc/hosts
for my new web site
when i'm trying to reach in a web browser my-symf-app from my debian machine
--> and it works fine
but when I'm using targeting my server from another PC with my ip http://192.168.0.47/coach.dev
i have a situation
and i receive a 404 not found
but when I'm targeting my debian server just with http://192.168.0.47
it works fine, it shows me a index.htm Works find
i have commented code in config.php
for if server something throw error forbidden
could you pls explain me what I'm doing wrong and how can i fix it?
my /etc//sites-available/coach
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName coach.dev
ServerAlias www.coach.dev
DocumentRoot /var/www/coach/web
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/coach/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
my /etc/hosts
127.0.0.1 coach.dev

Add on the 2nd computer ip and domainname to hosts.
I mean add ip adress of the server and his domain to host on second computer it should work.

Related

Virtual Host Not Behaving Properly

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.

Apache virtual host without domain name

I have a VPS with apache2 installed and I would like to access some PHP projects without a domain name just with the IP address. For example:
http://162.243.93.216/projecta/index.php
http://162.243.93.216/projectb/index.php
I have other projects with domain like example.com, in my directory /var/www/
/html/
info.php
/projecta/
/projectb/
/example/
When I go to
http://162.243.93.216/info.php then /var/www/html/info.php is opened.
My file 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
" http://162.243.93.216/info.php then /var/www/html/info.php is opened "
I am assuming this already works (If not, uncomment the ServerAlias line shown in the conf below)
You now want to map
http://162.243.93.216/projecta/ to /var/www/projecta
http://162.243.93.216/projectb/ to /var/www/projectb
For this you need to use the Apache Alias directive.
Update your 000-default.conf file to:
<VirtualHost *:80>
# ServerAlias 162.243.93.216
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /projecta /var/www/projecta
Alias /projectb /var/www/projectb
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Create a new virtual host file, and setup like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerAlias 192.168.1.1
DocumentRoot /somewhere/public_html
<Directory /somewhere/public_html/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride Authconfig FileInfo
Require all granted
</Directory>
</VirtualHost>
add the serveralias and it will recognize the IP address as well ...
if you want to add more IP addresses (like local network second interface), you can add more serveralias lines ...
Step Six — Set Up Local Hosts File (Optional)
If you have been using example domains instead of actual domains to test this procedure, you can still test the functionality of your virtual hosts by temporarily modifying the hosts file on your "LOCAL COMPUTER". This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from "YOUR COMPUTER", though, and is simply useful for testing purposes.
Note: Make sure that you are operating on your local computer for these steps and not your VPS server. You will need access to the administrative credentials for that computer.
If you are on a Mac or Linux computer, edit your local hosts file with administrative privileges by typing:
sudo vi /etc/hosts
If you are on a Windows machine, you can find instructions on altering your hosts file here.
The details that you need to add are the public IP address of your VPS followed by the domain that you want to use to reach that VPS:
127.0.0.1 localhost
127.0.1.1 guest-desktop
server_ip_address example.com
server_ip_address example2.com
reference:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7?utm_source=Customerio&utm_medium=Email_Internal&utm_campaign=Email_CentOSDistroNginxWelcome&mkt_tok=eyJpIjoiTnpWbU5tUTJPV1F5TVRBMyIsInQiOiJhd0JCQVI0NDd0ZWprUDFaaDlhbENcL0lyTjdSbnhwMEpkTE1QcXJTcHl1ZXFhNURKVmVBZHFKMk92RW1kSFwvMHowOW0zcExhaUdyOU42U2lLbk1Cd2FRYzB4XC9lbkhlWnd1ekZOcW1sZVhRYlwvT0xrTUpmQ2dEK2dNVUw4alFrc00ifQ%3D%3D

Virtual Host: LAN access, WAMP, Windows 7, Apache 2.4.4, Php 5.4.16; returns dont-have-permission-to-access-on-this-server

Before I start.. Good day to all! :)
I have problem with my WAMP virtual host.. the other computer on our LAN keeps receiving error forbidden-you-dont-have-permission-to-access-on-this-server..
Below is the current settings I have:
/httpd.conf
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
Options FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
/phpmyadmin.conf
Alias /phpmyadmin "c:/wamp/apps/phpmyadmin4.0.4/"
# to give access to phpmyadmin from outside
# replace the lines
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
#
# by
#
# Order Allow,Deny
# Allow from all
#
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Order Deny,Allow
Allow from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
/httpd.vhosts.conf
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName www.ecommerce.local
ServerAlias ecommerce.local
DocumentRoot C:/wamp/www/ecommerce
ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
CustomLog "C:/wamp/www/ecommerce/logs/access.log" common
<Directory />
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot C:/wamp/www/
</VirtualHost>
Also...
tried to ping from other computer response is success
tried to turn off firewall for both computer
tried to add everyone in www's folder properties
I have tried other solutions I found but still to no avail.. I can access "http://ecommerce.local" but the other computer on our LAN recieves forbidden-you-dont-have-permission-to-access-on-this-server error..
does it have something to do with our network settings? the other computer is also in the same settings... my ip: 192.168.1.198 and the other computer is 192.168.1.192
Access to Apache has nothing to do with windows access rights on a Windows system. Its all to do with what you tell Apache to allow in.
Also you are using a mixture of Apache 2.2 and Apache 2.4 syntax in most of your access declarations.
Apache 2.2
Allow .....
Apache 2.4
Require .....
Require local - means 127.0.0.1 and localhost and ::1
Require ip - specifies a single ip (192.168.0.10) or a range of ip's (192.168.0)
Apache does not seem to complain yet, but its probably best to stick to the Apache 2.4 syntax.
This first change you made is very dangerous and should be changed to this unless you really wanted to give unlimited access to the servers C:\ drive to anyone that hacks your Apache server.
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
Options FollowSymLinks Includes
AllowOverride All
Require all denied
</Directory>
Again here use Apache 2.4 syntax and be specific about who you want to allow in.
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
Require ip 192.168.0
</Directory>
Now to your Virtual Host definitions
You dont need this Listen 127.0.0.1:80
Put the localhost definition first so it becomes the default domain, so if a random or misspelt domain name is used this will load. If that comes from an internet ip then they will get an error as only ip's from within you network are allowed access. This isreally for later when you decide to open up your site to a wider audience.
Also dont specify 127.0.0.1 on the line, you want it to be listen any incoming ip not just this machine.
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
## May not want to let people access the wamp page so leave this off if not.
Require ip 192.168.0
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.ecommerce.local
ServerAlias ecommerce.local
DocumentRoot "C:/wamp/www/ecommerce"
## not a good idea to have logs visible under the DocumentRoot folder
## should really go in C:\wamp\logs
## But I assume you want developers to have easy access during development
## ErrorLog "C:/wamp/logs/ecommerce_error.log"
## CustomLog "C:/wamp/logs/ecommerce_access.log" common
ErrorLog "C:/wamp/www/ecommerce/logs/error.log"
CustomLog "C:/wamp/www/ecommerce/logs/access.log" common
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
Require ip 192.168.0
</Directory>
</VirtualHost>
Now you may want to allow your local developers access to phpMyAdmin. If so you will need to change your C:\wamp\alias\phpmyadmin.conf file as well.
<Directory "c:/wamp/apps/phpmyadmin4.0.4/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Require local
Require ip 192.168.0
</Directory>
Or you could be more specific here and only allow certain ip's to use phpMyAdmin by using something like this
Require ip 192.168.0.10 192.168.0.11 192.168.0.12
Just as a side note. I personally like to move my VistualHosts sites completely out of the C:\wamp\ folder structure. So I would have placed my ecommerce folder somewhere like C:\websites\ecommerce\www\. This keeps any confusion about access rights to a complete minimum and also if I need to upgrade WAMP, my website code is never in any danger when I make a silly typo.
ADDITIONAL INFO:
Now to be able to access your new site as ecommerce.local or www.ecommerce.local you will have to make a chnage to your HOSTS file.
C:\windows\system32\drivers\etc\hosts
On the PC running WAMP add this line:
127.0.0.1 ecommerce.local
On the other PC's do this
192.168.0.10 ecommerce.local
Where 192.168.0.10 is the ip address of the PC running WAMP
Then reboot the PC's or do these 2 commands from a command window started as Administrator
net stop "DNS Client"
net start "DNS Client"
I have already solved my own issue... I have not shared my folder for anyone to view... so what I did is:
Right Click the project folder
On folder options go to sharing tab
Click on advance sharing
advance sharing option will open then tick share this folder
click permissions
permissions option will open then choose whom you would like to share your folder
I chose everyone then below tick full control (*for trial purposes only; recommended tick only Read)
then click ok for all the opened options

Configure multiple Kohana applications on one server

Currently I am using wamp on a windows machine and have kohana up and running for one site. I would like to deploy another site which is completely separate and uses a different copy of kohana. To do so I added file structure and deployed kohana as follows
+wamp
++www
+++site1
++++kohana
+++site2
++++kohana
Currently my apache httpd.conf listener is as follows
Listen 0.0.0.0:80
And my hosts file in the windows directory is set up as
127.0.0.1 localhost
127.0.0.1 site1.localhost
127.0.0.1 site2.localhost
Currently when I go to localhost it will go to site1.localhost. Or if i go to site1.localhost it will go to site 1. If I go to site2.localhost the application will redirect to site1.localhost
I am very new to LAMP so this may be a very basic issue, for that I apologize.
Creating a virtual host is the answer
<VirtualHost site1.localhost>
ServerAdmin webmaster#site1
ServerName site1
DocumentRoot "C:/wamp/www/site1"
<Directory "C:/wamp/www/site1">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site1-error.log"
CustomLog "logs/site1-access.log" common
</VirtualHost>
<VirtualHost site2.localhost>
ServerAdmin webmaster#site2
ServerName site2
DocumentRoot "C:/wamp/www/site2"
<Directory "C:/wamp/www/site2">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/site2-error.log"
CustomLog "logs/site2-access.log" common
</VirtualHost>

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.

Categories