I have clean installed Mac OSX Yosemite but I cant configure the Apache 2.4 like I have always done on older OSX versions.
Here is what I want to do : set the "localhost" directory to "/Users/username/Public/".
But, everything I tried won't work, I always get a "Forbiden, can't access to /" or I get the default "It works!" page...
How to simply reroot my localhost ?
Thx
EDIT (thanks to Krister Andersson for the answer)
For Mac OSX 10.10 Yosemite
I also post the changes I had to do to keep things running.
In "/etc/apache2/users/", I created a file named by my username like this "myUsername.conf".
You can get your username by typing "id" in terminal. You should find your username at start in "uid=501(myUsername)".
In this new "myUsername.conf" file, just copy past this:
<Directory "/Users/myUsername/Sites/">
AllowOverride All
Options Indexes MultiViews
Options +FollowSymLinks
Require all granted
</Directory>
Dont forgive to change the myUsername value.
Then, in the "/etc/apache2/httpd.conf" file, uncomment all these two lines:
167 #LoadModule userdir_module libexec/apache2/mod_userdir.so
169 #LoadModule php5_module libexec/apache2/libphp5.so
Line 236, change the directory of "DocumentRoot" to whatever you want.
Line 250, set "Options" to "Options "Options Indexes FollowSymLinks Multiviews".
Line 258, set "AllowOverride None" to "AllowOverride All".
Line 263, set "Require all denied" to "Require all granted"
In Terminal, restart apache by typing "sudo apachectl restart".
It work's for me on Mac OS X 10.10 Yosemite clean install.
I've just installed Yosemite and I managed to change the DocumentRoot without any problems. First I modified the following lines in /private/etc/apache2/httpd.conf:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
AllowOverride None
</Directory>
to:
DocumentRoot "<CUSTOM_PATH>"
<Directory "<CUSTOM_PATH>">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
</Directory>
The above will set a custom DocumentRoot, enable directory listing and allow configurations to be overridden by .htaccess files.
Then I restarted apache by executing sudo apachectl restart.
Another approach would be to set up a virtual host. First make sure so that the following line is uncommented in your /private/etc/apache2/httpd.conf file:
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Then you can add the following in the httpd-vhosts.conf file:
<VirtualHost *:80>
ServerAdmin webmaster#example.local
DocumentRoot "/Library/WebServer/Documents"
ServerName example.local
ErrorLog "/private/var/log/apache2/example.local-error_log"
CustomLog "/private/var/log/apache2/example.local-access_log" common
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
The above will setup a document root for a new virtual host named example.local and enable directory listing and allow configurations to be overridden by .htaccess files. Of course your also will need to restart apache for the changes to take effect:
sudo apachectl restart
On El Capitan you should restart apache with "-k" flag:
sudo apachectl -k 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 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
I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.
This is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /laravelproject /var/www/laravelproject/public
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error
Not Found
The requested URL /laravelproject/login was not found on this server.
Apache/2.4.10 (Ubuntu) Server at '' Port 80
Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.
How can i set up a virtualhost or an alias to run it with all the routes working?
You could also try enabling apache mod-rewrite if not enabled yet.
sudo a2enmod rewrite
sudo systemctl restart apache2
You'll need to make sure the /var/www/laravelproject/public directory is set to AllowOverride All (which I believe you have taken care of by setting /var/www to All). Then make sure the .htaccess file in your public directory is correctly set up: https://github.com/laravel/laravel/blob/master/public/.htaccess
this is because Apache is looking for /public/login/index.html which is not a file. Laravel's .htaccess redirects these requests appropriately, but it has to be in your public folder and Apache has to AllowOverride
edit:
<Directory /var/www/laravelproject/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
In my attempt to get my Drupal alias links to work I have narrowed it down to the fact that the mod_rewrite module is not installed. I uncommented the LoadModule rewrite_module libexec/apache2/mod_rewrite.so as well as LoadModule php5_module libexec/apache2/libphp5.so. I have also changed AllowOverride None to AllowOverride All in every instance it appears in the httpd.conf file. I then restarted apache and I still cannot run this command: sudo a2enmod rewrite. Everytime I run it I get command not found error. What am I doing wrong, my username.conf also has the code listed below.
<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Any help would very appreciated.
Tyler
Go to the terminal and type sudo apachectl stop and then sudo apachectl start and see what happens.
I want to change XAMPP's htdocs directory. I followed the instructions to create a virtual host from this question:
Make XAMPP/Apache serve file outside of htdocs
this works fine on Windows 7, however when I try it on OSX, going to mysite.local just loads the xampp splash screen (mysite.local/xampp/index.html). I have restarted the web server. My virtual host declared in httpd-vhosts.conf is:
<VirtualHost *:80>
DocumentRoot Users/username/Documents/sitename.com
ServerName sitename.localhost
<Directory Users/username/Documents/sitename.com>
Order allow,deny
Allow from all
</Directory>
Open the following file in a text editor.
/Applications/XAMPP/xamppfiles/etc/httpd.conf
Search for "DocumentRoot", if the line below has a # in front of it than it's commented remove it and change the path between the quote
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
Now search for the line below and change the path between the quotes to your needs.
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
NOTICE: Paths similar to ~/ won't work use the absolute path.
I would like to expand this answer for 2022.
You will have to change 3 files if you want to keep web root in another directory. Let's say that you have installed XAMPP regularly, but your httpd directory is on another volume. Let's say in work/xampp/
Open /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf and change it to the following
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
We have added
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
and the block
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Open file /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf and change it to the following
<VirtualHost *:80>
DocumentRoot "/Volumes/work/xampp"
</VirtualHost>
<VirtualHost yoursite.mac:80>
ServerName yoursite.mac
ServerAlias www.yoursite.mac
ServerAdmin webmaster#yoursite.mac
DocumentRoot "/Volumes/work/xampp/yoursite.mac/webroot"
ErrorLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-error_log"
CustomLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-access_log" common
<Directory "/Volumes/work/xampp">
Require all granted
</Directory>
</VirtualHost>
Open /etc/hosts as a sudo and add your new site to it
127.0.0.1 yoursite.mac
If you forward to a directory in your user root, then:
DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">
Other than the answers mentioned above, I also had to change the line in XAMPP/xampfiles/etc/httpd.conf where it mentions username. the default was set to daemon and I changed it to my username; so there was no permission problem.
solved by editing httpd.conf
I have got this working. As per http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac, in OSX it is necessary to make two changes to httpd.conf, first, uncomment
#Include /Applications/xampp/etc/extra/httpd-vhosts.conf
and second, change the user from nobody to the username you use to log into OSX. You may also need to delete your browser's cache.