![]() ![]() MAMP is easy to install, but it creates a duplicate version of PHP and a duplicate version of Apache. I used to use MAMP for this, but lately have been using the built-in functionality that comes on a Mac instead. If you want to have colored PHP CLI output, you must enable it by installing php posix.I recently got a new Mac and needed to configure it as a local web server for the many Drupal sites I work on. If you regularly use PHP from the command line, you also want to link the php command to the MacPorts PHP version: $ sudo port select -set php php70 Search for fault_socket, fault_socket and pdo_fault_socket and assign the MariaDB socket to them: /opt/local/var/run/mariadb/mysqld.sock. LoadModule php7_module modules/mod_php70.soīefore we can use MySQL in our PHP code, we must set the default socket path in /opt/local/etc/php70/php.ini. so shared object for PHP is included: # Load the PHP module Make sure that Apache includes the PHP config, check your nf file for the following lines: # Include PHP configurationsĪlso verify that the. In Apache’s config file /opt/local/apache2/conf/nf, add index.php to the DirectoryIndex: $ sudo /opt/local/apache2/bin/apxs -a -e -n "php7" mod_php70.so For development purposes use: $ cd /opt/local/etc/php70įor production use: $ cd /opt/local/etc/php70Įnable the PHP module in Apache $ cd /opt/local/apache2/modules You might also need the following PHP extensions: $ sudo port install \ Last step is installing PHP: $ sudo port install php70-apache2handler ![]() If you want to use mysql on the command line, you can link mysql to MariaDB: $ sudo port select -set mysql mariadb PHP If you want to use 172.0.0.1 for your MySQL connections, you should comment out that line. Note: MacPorts MariaDB has skip-networking enabled by default in /opt/local/etc/mariadb/macports-default.cnf. You can also specify the socket path in your PHP config file: see below… ![]() If you work a lot with sockets for MySQL/MariaDB, you can create a symbolic link from the default socket path to MacPort’s path: $ sudo ln -s /opt/local/var/run/mariadb/mysqld.sock /tmp/mysql.sock Next we need to create a password for the root user, don’t forget to do this step! This procedure will interactively ask you some security details: $ /opt/local/lib/mariadb/bin/mysql_secure_installation Time to start MariaDB: $ sudo port load mariadb-server Once MariaDB is installed, we need to create the main databases: $ sudo -u _mysql /opt/local/lib/mariadb/bin/mysql_install_db Stopping services can be done using the unload statement.Īpache should be functioning right now, more configuration details can be found everywhere on the internet, I’m not gonna explain the whole config file here… MariaDB (MySQL)Īgain, we use MacPorts: $ sudo port install mariadb-server When everything is configured, you can start Apache using MacPorts services: $ sudo port load apache2 Replace it with the following directive: ĭon’t forget to verify your changes after every modification you do to nf! $ /opt/local/apache2/bin/apachectl -t By default you have a block like this in your Apache config: You must also allow traffic to go to your webserver otherwise you will get “Permission denied” errors. To do this change /opt/local/apache2/htdocs to your local sites folder e.g. Probably you want to set DocumentRoot to your local Sites folder. Whenever your installation is completed, you can edit Apache’s configuration file: /opt/local/apache2/conf/nf. Time to install Apache: $ sudo port install apache2 Web sharing can be found under ‘System preferences’, ‘Sharing’, … If you have web sharing enabled on your Mac, you should disable it before continuing. You could also install them using Homebrew, or use the packages that come with your Mac, but I prefer MacPorts… So if you don’t have MacPorts installed, follow the installation instruction on their website.īefore installing any ports, make sure you have the latest version of the ports tree: $ sudo port selfupdate Apache In this guide I will use it to install Apache, MariaDB and PHP. The tool is very handy when it comes to installing command line tools for Mac. ![]() The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the OS X operating system. MacPorts is a BSD ports like package management system for OS X. If you want to update your current PHP 5 installation to a PHP 7 installation, see this blogpost: Migrating/updating from PHP 5 to PHP 7 on OS X (MacPorts). Update: I updated the blogpost for PHP 7 instead of PHP 5. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |