Today I create my first project with Zend Framework2 and when using internal PHP cli-server in the root directory it works.
But when I try to configure virtual host in Apache2 I see only "500 Internal Server Error"
ZendFramework-2.4.2
PHP Version 5.5.9
Apache/2.4.7
/etc/apache2/sites-available/zend-default.conf
<VirtualHost *:80>
ServerName zend.local
DocumentRoot /var/www/html/zendframework/ZendSkeletonApplication/public
<Directory /var/www/html/zendframework/ZendSkeletonApplication/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 zend.local
127.0.0.1 localhost
if I remember correctly you have to enable mod_rewrite in your apache2.
Related
I have an installation of httpd on my server and a web application on it (/var/www/html/app). I want to when a user enter the IP of my server over HTTP (123.125.21.45:80) this redirects to my application on same port (123.125.21.45:80/app)
I have created and app.conf in /etc/httpd/conf.d/app.conf
<VirtualHost *:80>
DocumentRoot /www/html/app
ServerName 123.125.21.45
</VirtualHost>
And the result on the web browser is
http://123.125.21.45/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/
What am I doing wrong?
Please use below virtual host file and then try.
Note: make sure you are not using any redirection from .htaccess file.
<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerName 123.125.21.45
Redirect permanent / http://123.125.21.45/app/
<Directory /var/www/html/>
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
I'm attempting to configure simpleSAMLphp within a MAMP/Apache environment on Windows 10 and below is my httpd-vhosts.conf file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/simplesamlphp/www>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my /etc/hosts file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Virtual Hosts
127.0.0.1 simplesamlphp
Apache starts via MAMP totally fine without including this httpd-vhosts.conf file in my httpd.conf file, but as soon as its included, Apache will not start so the issue appears to be with httpd-vhosts.conf. No errors are shown in the apache_error.log file. My Apache version is 2.2 so I believe my Directory directives in my second VirtualHost are correct.
I've tried double quoting the DocumentRoot's, directory paths etc, and also tried backslashes over forward slashes. I spent most of yesterday trying to figure this out while scouring the web but nothing I found has made this work.
Any help is much appreciated!
Try this modified config
The path in Directory header same as DocumentRoot!
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/MAMP/htdocs
</VirtualHost>
<VirtualHost *:80>
ServerName simplesamlphp
DocumentRoot C:/MAMP/htdocs/pro-dashboard
Alias /simplesaml C:/MAMP/simplesamlphp/www
<Directory C:/MAMP/htdocs/pro-dashboard>
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
So oddly enough, taking out what I had in httpd-vhosts.conf and simply putting it in my httpd.conf file makes Apache start back up.
I try to set up virtual host for some local site with XAMPP.
I executed next steps:
In "C:/xampp/apache/conf/extra/httpd-vhosts.conf" I added:
<VirtualHost *:8081>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:8081>
DocumentRoot C:/xampp/htdocs/fw/public
ServerName fw.local.com
<Directory "C:/xampp/htdocs/fw/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Inside "C:/Windows/System32/drivers/etc/hosts" I added:
127.0.0.1 localhost
127.0.0.1 fw.local.com
Restarted Apache.
And...
If I follow to:
http://localhost:8081/
All is OK: I see my catalog with projects in folder "htdocs".
But! If I follow to:
http://fw.local.com/
I expect to see result of my "index.php" file inside "..htdocs/fw/public". But I get:
This site can’t be reached
fw.local.com refused to connect.
File "C:/xampp/apache/conf/httpd.conf" contains:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Where I was wrong?
You should change: <VirtualHost *:8081> to <VirtualHost *:80> on both counts, fw.local.com attempts to connect to port 80, not 8081.
Edit: You could also keep it the way you have it and connect to: http://fw.local.com:8081/
I am tried to create Multiple Virtual Hosts on my Windows 10, 64-bit, XAMPP 3.2.1
I did the following:
1- C:\Windows\System32\drivers\etc\hosts
I have added these line at the bottom of the hosts file:
127.0.0.1 smc
127.0.0.1 ocms
2- D:\xampp\apache\conf\httpd.conf
Virtual hosts is already is enabled see the following:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3- D:\xampp\apache\conf\extra\httpd-vhosts.conf
Here i have added the following code block on httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName smc
DocumentRoot "D:/vhosts/smc"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/smc/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ocms
DocumentRoot "D:/vhosts/ocms/"
SetEnv APPLICATION_ENV "development"
<Directory "D:/vhosts/ocms">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Finally i have put both my directories in my D:/vhosts/ folder:
D:/vhosts/ocms
D:/vhosts/smc
After i have restarted my apache server and test the url like:
http://ocms
Or
http://smc
It returns the following error:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
ocms
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
I have googled it too many times for last three to four days and also followed some other posts on stackoverflow i.e. how to create virtual host on XAMPP but with no luck. Please let me know what i am missing.
Thanks
Ok i have done it. i had to put all my directories under the htdocs folder like this.
structure should be:
D:\xampp\htdocs
D:\xampp\htdocs\test\smc
D:\xampp\htdocs\test\ocms
Thank you all for your precious time
Your initial settings works fine for me.
I think your problem was that the index was missing.
This line will force Apache to accept only index.php file as entry point:
DirectoryIndex index.php
However, if your entry point has a different name or extension you get the error:
You don't have permission to access the requested directory. There is either no index document or the directory is read-protecte
I'm stuck on this 403 problem. I set up virtual host for apache on ubuntu, and when I access the site, it returns 403.
/etc/apache2/site-available/os.solesschong.com
<VirtualHost *>
DocumentRoot /root/mysoft/sns
ServerName oa.solesschong.com
ErrorLog ${APACHE_LOG_DIR}/oa.solesschong.com-error.log
CustomLog ${APACHE_LOG_DIR}/oa.solesschong.com-access.log combined
<Directory /root/mysoft/sns>
Allow from all
</Directory>
</VirtualHost>
# a2enable oa.solesschong.com
file
root/mysoft/sns/index.php
DNS
oa.solesschong.com A-record: [IP of my server]
browser return
Forbidden
You don't have permission to access / on this server.
Apache/2.2.22 (Ubuntu) Server at oa.solesschong.com Port 80
Does the Apache process have permission access to read to /root/mysoft/sns/index.php?
Check your version of apache. If it is 2.4 then you need change alow configuration from
Allow from all
to
Require all granted