I have a problem since I update macOS X to high sierra version I have some problem running apache service . When I try to access to this url http://social.demo in local I have Forbidden Page
social.demo is a project made with Laravel
When run this command :
apachectl configtest
It return me this error :
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Alexiss-iMac.local. Set the 'ServerName' directive globally to suppress this message
Syntax OK
So I check in /ect/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 api.demo
127.0.0.1 tv.demo
127.0.0.1 bo.demo
127.0.0.1 social.demo
127.0.0.1 website.demo
127.0.0.1 revive.demo
127.0.0.1 bo.demo
~
It seems ok
I try to uncomment this in this file "/private/etc/apache2/extra/httpd-userdir.conf" and restart apache service
#Include /private/etc/apache2/users/*.conf
Even I try http://localhost I have a forbidden page
I don't where I have to look for ...
Edit : here my httpd-vhost.conf
<VirtualHost *:80>
DocumentRoot "/Users/alexisjqn//Documents/Ctor/public/"
ServerName http://social.demo/
SetEnv APPLICATION_ENV "development"
<Directory "/Users/alexisjqn//Documents/Ctor/public/">
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
My Work around was thew following:
Please check "/private/etc/apache2/extra/httpd-userdir.conf" file. Change
#Include /private/etc/apache2/users/*.conf
to
Include /private/etc/apache2/users/*.conf
And edit your "/etc/apache2/httpd.conf"
change
Options FollowSymLinks Multiviews
to
Options FollowSymLinks Multiviews Indexes
finally your doc root will be look like the following,
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
Restart apache
sudo apachectl restart
Related
OS: Mac OS
Mamp 6.6 version
The virtual host is not working, when I open the host I get an error:
Not Found
The requested URL was not found on this server.
looked at a lot of articles on topic of installing virtual hosts and it seems that I did everything right
My hosts file:
enter image description here
The virtual hosts file is included in configuration file /Applications/MAMP/conf/apache/httpd.conf:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
My httpd-vhost-conf:
NameVirtualHost *:80
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php"
<Directory "/Users/danilbondarev/Projects/php">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName localhost
DirectoryIndex index.html index.htm index.php
DocumentRoot "/Users/danilbondarev/Projects/php/hybrid-main"
<Directory "/Users/danilbondarev/Projects/php/hybrid-main">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
Mamp->Preferences->Server->Document Root:
enter image description here
Error screen:
enter image description here
I want to note: I always restart apache and MAMP when I make any changes to the config files. I also tried to give directories permissions for Apache and it didn't help, although obviously this wasn't the problem
Tried these solutions:
Virtual hosts not working on MAMP
MAMP setting virtual host does not working
I installed apache with brew and changed port 8080 to 80. when I accessed localhost this shown me a page "it works!" and that page is located in /usr/local/var/www directory with file name index.html but when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf file.
<VirtualHost *:80>
DocumentRoot "/Users/ranaamir/projects/sample/yii2/backend/web"
ServerName yii2.example.be
ServerAlias yii2.example.be
<directory "/Users/ranaamir/projects/sample/yii2/backend/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</directory>
ErrorLog "/usr/local/var/log/httpd/vjfBackenderror.log"
CustomLog "/usr/local/var/log/httpd/vjfBackendaccess.log" common
</VirtualHost>
and restart the service with sudo apachectl -k restart command and this host also added in /etc/hosts.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 yii2.example.be
Then I access localhost or yii2.example.be both are showing a page where only one line mentioned Index of /.
if I remove code of block <VirtualHost *:80> from httpd-vhosts.conf then again localhost host showing correct index.html.
why my project not running on the virtual-host url instead of index of /?
Any help would be so appreciated!!
I have resolved this issue, I made little change in httpd.conf file where we have to mentioned which type of file they will be process first so I just added index.php in the code block of dir_module.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
I hope this will save your time and minimize your stress. :)
I'm trying to setup my Apache on OSX, but I'm not able to make my local url 'awr.local' point to the correct path. I mean whether I type http://localhost or http://awr.local, it always shows me the index.html page in my 'localhost' vhost path.
I've restarted my httpd service countless times, with or without sudo.
Any help would be greatly appreciated, thanks :'|
I've been following a tutorial (https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions), here are the steps about Apache :
Disabling the bundled Apache and installing the one from homebrew :
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew install httpd
Then, some httpd.conf modifications :
# changed Listen 8080 to :
Listen 80
[...]
# changed DocumentRoot "/usr/local/var/www" to :
DocumentRoot "/Users/wallace/dev/default"
[...]
# changed <Directory "/usr/local/var/www"> to :
<Directory "/Users/wallace/dev/default">
[...]
# changed AllowOverride None to :
AllowOverride All
# uncommented :
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
[...]
# changed
# User _www
# Group _www
# to :
User wallace
Group staff
[...]
# added the missing line :
ServerName localhost
Until this point everything seemed to be working fine, I've installed PHP and MariaDB without any problem.
Then came the virtual hosts part :
Some other httpd.conf modifications :
# uncommenting these lines
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
[...]
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
Editing the file /usr/local/etc/httpd/extra/httpd-vhosts.conf :
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/default"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/awr"
ServerName awr.local
</VirtualHost>
The /etc/hosts file :
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 awr.local
::1 awr.local
The output of 'httpd -S' :
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (/usr/local/etc/httpd/extra/httpd-vhosts.conf:25)
port 80 namevhost localhost (/usr/local/etc/httpd/extra/httpd-vhosts.conf:25)
port 80 namevhost awr.local (/usr/local/etc/httpd/extra/httpd-vhosts.conf:30)
ServerRoot: "/usr/local/opt/httpd"
Main DocumentRoot: "/Users/wallace/dev/default"
Main ErrorLog: "/usr/local/var/log/httpd/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="wallace" id=501 not_used
Group: name="staff" id=20 not_used
Well, today when I was preparing to try the answer of Juan, I had something new : instead of serving me the localhost, the awr.local url showed me a 403 forbidden. After a new research & doc reading, I managed to make it work like this :
My /usr/local/etc/httpd/extra/httpd-vhosts.conf file :
The Require all granted is the most important part.
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/default"
ServerName localhost
<Directory "/Users/wallace/dev/default">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/wallace/dev/awr"
ServerName awr.local
<Directory "/Users/wallace/dev/awr">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I had to restart Apache with sudo for it to work :
sudo brew services stop httpd && sudo brew services start httpd
I had the same problem and couldn't get it to work no matter what I tried. Stopping, starting or restarting httpd did not work. Even though httpd -S always reported the correct settings, all browsers loaded the default docroot, regardless of the virtualhost settings. Then I noticed something strange. After stopping httpd with brew services stop httpd I reloaded localhost in the browser and it still loaded without a problem. This gave me the idea to sudo killall httpd then start it again with brew services start httpd. After this, all was fine.
Considering how much time I spent on this, I will be dropping my own fix too.
First of all I noticed that all server names using the 127.0.0.1 IP always points to the default directory. I edited my custom domain to use 127.0.1.1 in /etc/hosts.
In /usr/local/etc/httpd/extra/httpd-vhosts.conf, edited it according to Alfred's answer as I was initially getting a 403 too.
Files looks something like this;
/etc/hosts:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.1.1 customdomain.local # note: 127.0.1.1
127.0.1.2 customdomain2.local # note: 127.0.1.2 (will increment for each new domain)
255.255.255.255 broadcasthost
::1 localhost
::1 customdomain.local
::1 customdomain2.local # this part is equally important though I am not sure why
/usr/local/etc/httpd/extra/httpd-vhosts.conf:
<VirtualHost customdomain.local:80>
ServerAdmin webmaster#customdomain.local
DocumentRoot "/Users/user/Projects/customdomain/public"
ServerName customdomain.local
<Directory "/Users/user/Projects/customdomain/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Confirm that your Listen value in /usr/local/etc/httpd/httpd.confis 80.
This might not be the best solution but should solve the issue.
This is how I have it setup (I've made changes to match your configuration).
Besides awr.local must be in your /etc/hosts file pointing to 127.0.0.1 or any other network interface you want to use.
<VirtualHost awr.local:80>
DocumentRoot "/Users/wallace/dev/awr"
ServerName awr.local
<Directory "/Users/wallace/dev/awr">
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
I know, this problem has been faced several times, but after reading many posts, it still does not work. the funny part: yesterday it worked. so, who can help me find the error? step by step:
I am using Apache/2.2.29 on Mac OS 10.8.5
/etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 scripts
127.0.0.1 page
/private/etc/apache2/httpd.conf
[...]
ServerRoot "/usr"
User _www
Group _www
DocumentRoot "/Users/me/server"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
[...]
<Directory "/Users/me/server">
MultiViews
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
[...]
Include /private/etc/apache2/extra/httpd-vhosts.conf
[...]
/private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/Users/me/server/scripts"
ServerName scripts
ErrorLog "/Users/me/server/scripts/errlog"
CustomLog "/Users/me/server/scripts/customlog" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/me/server/page"
ServerName scripts
ErrorLog "/Users/me/server/page/log/errlog"
CustomLog "/Users/me/server/page/log/customlog" common
</VirtualHost>
Given Rights: (Full rights for testing)
/Users/me/server
drwxrwxrwx 5 _www _www
/Users/me/server/page
drwxrwxrwx 4 _www _www
Restart apache
sudo apachectl restart
I tried to restart the browser as well
Log Files
All log files are empty
Result
http://localhost
http://page
neither of them works, I keep on getting the forbidden message.
You need to change ServerName from scripts to page in second section in httpd-vhosts.conf.
i am trying to add another local domain to my mac osx:
No matter what i do when visiting say 'domainnumber2.dev' it always displays the first host in my list.
If i swop them around in my httpd-vhosts file then i get the domainnumber2.dev site.
How can i run multiple localhost site on my mac.
I have a simple set up as below:
<VirtualHost *:80>
ServerName mydomain.dev
ServerAlias mydomain.dev
DocumentRoot "/Users/UserName/Sites/mydomain/"
</VirtualHost>
<VirtualHost *:80>
ServerName mydomainTwo.dev
ServerAlias mydomainTwo.dev
DocumentRoot "/Users/UserName/Sites/mydomainTwo/"
</VirtualHost>
I have also had the more details set up adding the below for both
<Directory "/Users/UserName/Sites/mydomain/">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my hosts file i have:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 mydomain.dev
127.0.0.1 mydomainTwo.dev
which ever VirtualHost is first is the site that is served up
I stumbled across this same problem...
In your httpd-vhosts.conf file (/private/etc/apache2/extra/httpd-vhosts.conf after showing hidden files) add the following for each domain...
<VirtualHost *:80>
ServerName mysubdomain.dev
CustomLog "/root/to/site/logs/mysubdomain.dev-access_log" combined
ErrorLog "/root/to/site/logs/mysubdomain.dev-error_log"
DocumentRoot "/root/to/site/mysubdomain.co.uk"
<Directory "/root/to/site/mysubdomain.co.uk">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Then restart apache. Everything else you have seems to be the same as my setup.
Make sure you have the correct permissions to be able to write the log files etc too.