Apache is pre-installed webserver in the OS and needs to be enabled via the command line:

START/STOP APACHE

 #which version?
 sudo apachectl -v
 #start-stop-restart
 sudo apachectl start|stop|restart

There are many different Apache modules available to add functionality to the basic server.

CONFIGURE APACHE

 # open configuration file        
 sudo nano /etc/apache2/httpd.conf

Now that the file is open, find the line where LoadModule php5_module is commented out. Remove the # in the front of the line commenting it out. This will enable PHP ( i changed the path to use the new php version installed with homebrew /usr/local/Cellar...).

 #remove the "#" from this line: 
 LoadModule php5_module          /usr/local/Cellar/php55/5.5.5/libexec/apache2/libphp5.so

Change The name (or #number) of the user/group to run httpd as. It is usually good practice to create a dedicated user and group

#User your_mac_username ...
User [your_mac_username]
Group staff 

CREATE A VIRTUAL HOST

#open file for vhosts
sudo nano   /private/etc/apache2/extra/httpd-vhosts.conf 

#append to file :
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/docs/dummy-host.example.loc"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.loc
    ErrorLog "/private/var/log/apache2/dummy- host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>

#open host file
sudo nano /etc/hosts

#append your new local site
127.0.0.1       dummy-host.example.loc
127.0.0.1       www.dummy-host.example.loc

UPGRADE NATIVE OS PHP

Let’s see we can manually upgrade the native OS PHP installation to the newest version.
Homebrew offers a quick way to install common libraries and software without having to build from source. Read my article to install and configure Homebrew.

INSTALL PHP 5.5

#list all php packages
brew search php55
#select php55 and others package.. :
brew install php55 php55-memcache php55-memcached php55-mongo php55-mcrypt

#edit php.ini
sudo nano /usr/local/etc/php/5.5/php.ini

© 2018. All Rights Reserved.

Ghostium Theme by @oswaldoacauan

published with Ghost

Privacy Policy