http://digitalshore.io/local-web-development-environment-apache-macos-sierra-10-12 This is the guide that i used to set up an apache server.
I did everything that was necessary but i wasn't able to run this command
$ sudo cp httpd-userdir.conf httpd-userdir.conf.bak
Answer from terminal was "Access denied"
So, I decided not to make back-up files. When i completed the proccess, i entered this in the browser
http://localhost/~username
, where username was my actual username.
And got this response
Forbidden
You don't have permission to access /~username on this server.
I ran apachectl configtest
. And got this:
Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist AH00557: httpd: apr_sockaddr_info_get() failed for MacBook-Pro-Tim.local AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message Syntax OK
What should I do?
Try http://localhost/directory/ where directory is an folder in your sites folder. For some reason before Seirra this worked for me and http://localhost/~username/directory didn't (most likely the way I had it configured, don't quite remember how I did it, try them both just in case).
If both doesn't work, try the following in terminal.
sudo nano /etc/apache2/users/username.conf;
Add this in the file. Side Note: username below and anywhere else in this answer should be your machines username.
<Directory "/Users/username/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
Save the changes. Then sudo chmod 644 username.conf
Next: sudo nano /etc/apache2/httpd.conf
Uncomment the following lines (i.e. remove the # in front of each line if it has one)
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule include_module libexec/apache2/mod_include.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/extra/httpd-userdir.conf
Then sudo nano /etc/apache2/extra/httpd-userdir.conf
and uncomment the line Include /private/etc/apache2/users/*.conf
Save and restart apache. sudo apachectl restart
http://localhost/~username/ should then be accessible. I just went through these steps and it worked for me.
Ref: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With