to start it
sudo apachectl start
to stop it
sudo apachectl stop
to restart it
sudo apachectl restart
To find the Apache version
httpd -v
http://localhost
troubleshooting Apache to see if there is anything wrong in its config file by running
apachectl configtest
http://localhost/
The files are shared in the filing system at – /Library/WebServer/Documents/
Add a .conf
cd /etc/apache2/users/
sudo nano suvozit.conf
Add the content
<Directory "/Users/suvozit/Sites/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
Set permission
sudo chmod 644 suvozit.conf
Allow some modules:
sudo nano /etc/apache2/httpd.conf
Make sure these 3 modules are uncommented (the first 2 should be on a clean install):
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
and
Include /private/etc/apache2/extra/httpd-userdir.conf
Then open another Apache config file and uncomment another file:
sudo nano /etc/apache2/extra/httpd-userdir.conf
And uncomment:
Include /private/etc/apache2/users/*.conf
Restart Apache for the new file to be read:
sudo apachectl restart
Then this user level document root will be viewable at: http://localhost/~suvozit/
sudo nano /etc/apache2/httpd.conf
Uncomment
LoadModule php5_module libexec/apache2/libphp5.so
Restart Apache
sudo apachectl restart
sudo nano /etc/apache2/httpd.conf
Allow any .htaccess files used to override the default settings
Change AllowOverride None to AllowOverride All
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
Uncomment
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Restart Apache
sudo apachectl restart
mkdir /Users/suvozit/Sites/welcome
sudo nano /Users/suvozit/Sites/welcome/index.php
Paste it
<?php phpinfo(); ?>
URL
http://localhost/~suvozit/welcome
To run a website with no permission issues it is best to set the web root and its contents to be writeable by all, since it’s a local development it should’nt be a security issue.
sudo chmod -R a+w ~/Sites/welcome
If you are concerned about security then instead of making it world writeable you can set the owner to be Apache _www
sudo chown -R _www ~/Sites/welcome