0

I am following this tutorial to setup my Mac as the web server: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-osx-10-11-el-capitan/

But unfortunately I got stuck, if I access the http://localhost/~username/info.php it works normally, but when I access only: http://localhost/info.php it says forbidden, any idea how to fix this?

Edit:

I want to access both the System root and User root
Big Thanks

jaysingkar
  • 4,315
  • 1
  • 18
  • 26
da_root
  • 364
  • 2
  • 11

1 Answers1

0

I think to achieve this, you would need to activate and use virtual host.
Try this:
1) Open httpd.conf file:

sudo nano /etc/apache2/httpd.conf

2) Look for followig line and uncomment it:

# Virtual hosts

Include /private/etc/apache2/extra/httpd-vhosts.conf

3) This will allow usage of the httpd-vhosts.conf file, open this file to add in the vhost.

sudo nano /etc/apache2/extra/httpd-vhosts.conf

4) Add following code in the start of the file.

<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
jaysingkar
  • 4,315
  • 1
  • 18
  • 26
  • Check if your configuration is correct by running this command `httpd -S` – jaysingkar Jul 25 '16 at 05:57
  • I think, my setting is not correct, it show something like this: Warning: DocumentRoot [/Library/WebServer/Documents/Sites/] does not exist AH00112: Warning: DocumentRoot [/Users/username/Sites/] does not exist Sorry for this silly questions, how to fixed this? Big Thanks – da_root Jul 25 '16 at 06:00
  • check if both directories exists. and in `[/Users/username/Sites/]` I think you would need to use your username instead of `username`. Also could you update your question with contents of `/etc/apache2/extra/httpd-vhosts.conf` file – jaysingkar Jul 25 '16 at 06:06
  • Sorry, I forgot to change the username with real name. I changed it but still access forbidden (screenshot link- https://postimg.org/image/ylhj1iirb/). following is my vhost: # match a ServerName or ServerAlias in any block. # ServerName localhost DocumentRoot /Library/WebServer/Documents/ DocumentRoot "/Users/soetjitro/Sites/" ServerName localhost – da_root Jul 25 '16 at 06:36