Apache Server Configure on Mac

Apache Server

  • Start up Apache on Mac
    • sudo apachectl (-k) start
    • //sudo apachectl (-k) restart
    • sudo apachectl (-k) stop
  • Check the apache version
    • sudo apachectl -v
    • or apachectl -v
  • (Mac) Apache: You don’t have permission to access / on this server
    1
    2
    3
    4
    5
    <Directory "/Users/andy/Sites/">
    AllowOverride All
    Options Indexes MultiViews FollowSymLinks
    Require all granted
    </Directory>

Configure PHP Server

  1. Search httpd.conf

    1
    2
    3
    cd /etc/apache2
    //sudo cp httpd.conf httpd.conf.bak
    sudo vim httpd.conf
  2. Configure httpd.conf

    1
    2
    3
    4
    // Change the DocumentRoot "/Library/WebServer/Documents"
    DocumentRoot "/Users/andy/Sites"
    // Change the <Directory "/Library/WebServer/Documents">
    <Directory "/Users/andy/Sites">
  3. Find php

    1
    2
    #LoadModule php5_module libexec/apache2/libphp5.so
    drop "#"
  4. cd /etc/

    1
    sudo cp php.ini.default php.ini
  5. Create index.php in /Users/andy/Sites”, and type in

    1
    <?php phpinfo(); ?>    // <?php  without blank space
  6. sudo apachectl restart

  7. Scan localhost in website
    1
    http://loaclhost/index.php