{"id":1993,"date":"2015-12-30T11:01:16","date_gmt":"2015-12-30T10:01:16","guid":{"rendered":"http:\/\/denbeke.be\/blog\/?p=1993"},"modified":"2015-12-30T11:05:18","modified_gmt":"2015-12-30T10:05:18","slug":"migratingupdating-from-php-5-to-php-7-on-os-x-macports","status":"publish","type":"post","link":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/","title":{"rendered":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts)"},"content":{"rendered":"<p><a href=\"http:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/attachment\/php-7-logo\/\" rel=\"attachment wp-att-1996\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-1996 size-medium\" src=\"http:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo-300x151.png\" alt=\"PHP 7 logo\" width=\"300\" height=\"151\" srcset=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo-300x151.png 300w, https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo.png 727w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>PHP 7 was released earlier this month,\u00a0time for me to upgrade my development environment to keep up to date with this new version. I had already installed PHP 5.6 using MacPorts, so this guide is about upgrading a PHP 5 installation to a PHP 7. If you need help for actually installing PHP\/Apache\/MySQL, read this blogpost:\u00a0<a href=\"http:\/\/denbeke.be\/blog\/webdevelopment\/installing-mamp-mac-os-x-apache-mariadb-php-using-macports\/\">Installing MAMP (Mac OS X Apache MariaDB PHP) using MacPorts<\/a>.<\/p>\n<h3 id=\"install-php-7\">Install PHP 7<\/h3>\n<p>Install PHP 7, and the extensions you need:<\/p>\n<pre><code>$ sudo port install php70\r\n$ sudo port install php70-cgi php70-gd php70-curl php70-intl php70-iconv php70-gettext php70-mbstring php70-imap php70-mcrypt php70-xmlrpc php70-mysql php70-openssl php70-sockets php70-zip php70-tidy php70-opcache php70-xsl php70-sqlite<\/code><\/pre>\n<p>Install the Apache handler for PHP 7:<\/p>\n<pre><code>$ sudo port install php70-apache2handler<\/code><\/pre>\n<h3 id=\"activating-php-7\">Activating PHP 7<\/h3>\n<p>Once installed you must activate the handler:<\/p>\n<pre><code>$ cd \/opt\/local\/apache2\/modules\r\n$ sudo \/opt\/local\/apache2\/bin\/apxs -a -e -n php7 mod_php70.so<\/code><\/pre>\n<p>This may lead to two PHP modules being loaded in the Apache configuration file. If <code>phpinfo()<\/code> still uses PHP 5.6 (or any other PHP version), you need to uncomment the PHP 5 module in <code>\/opt\/local\/apache2\/conf\/httpd.conf<\/code>.<\/p>\n<pre><code>#LoadModule php5_module        modules\/mod_php56.so\r\nLoadModule php7_module        modules\/mod_php70.so<\/code><\/pre>\n<p>At the bottom of the same file, you need to add this line for PHP 7 (and possibly delete the same line for PHP 5):<\/p>\n<pre><code>Include conf\/extra\/mod_php70.conf<\/code><\/pre>\n<p>Now we have configured PHP 7 and Apache, we need to restart Apache:<\/p>\n<pre><code>$ sudo port unload apache2; \\\r\n  sudo port load apache2<\/code><\/pre>\n<p>or<\/p>\n<pre><code>$ sudo \/opt\/local\/etc\/LaunchDaemons\/org.macports.apache2\/apache2.wrapper restart<\/code><\/pre>\n<p>Select PHP 7 as the current PHP version:<\/p>\n<pre><code>$ sudo port select php php70<\/code><\/pre>\n<p>You can verify this by executing <code>$ sudo port select --list php<\/code>:<\/p>\n<pre><code>Available versions for php:\r\n    none\r\n    php55\r\n    php56\r\n    php70 (active)<\/code><\/pre>\n<h3 id=\"verifying-the-php-version\">Verifying the PHP version<\/h3>\n<p>Verify the executable using PHP cli:<\/p>\n<pre><code>$ php -v\r\nPHP 7.0.1 (cli) (built: Dec 29 2015 19:22:02) ( NTS )\r\nCopyright (c) 1997-2015 The PHP Group\r\nZend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies<\/code><\/pre>\n<p>Now create a test PHP file on your webserver and verify in the browser if Apache uses the correct PHP version:<\/p>\n<pre><code>&lt;?php phpinfo(); ?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP 7 was released earlier this month,\u00a0time for me to upgrade my development environment to keep up to date with this new version. I had already installed PHP 5.6 using MacPorts, so this guide is about upgrading a PHP 5 installation to a PHP 7. If you need help for actually installing PHP\/Apache\/MySQL, read this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[227],"tags":[213,251,149,215],"class_list":["post-1993","post","type-post","status-publish","format-standard","hentry","category-servers","tag-apache","tag-macports","tag-os-x","tag-php","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke\" \/>\n<meta property=\"og:description\" content=\"PHP 7 was released earlier this month,\u00a0time for me to upgrade my development environment to keep up to date with this new version. I had already installed PHP 5.6 using MacPorts, so this guide is about upgrading a PHP 5 installation to a PHP 7. If you need help for actually installing PHP\/Apache\/MySQL, read this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-30T10:01:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-12-30T10:05:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"727\" \/>\n\t<meta property=\"og:image:height\" content=\"366\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mathias Beke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mathias Beke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/\"},\"author\":{\"name\":\"Mathias Beke\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#\\\/schema\\\/person\\\/386878f712fe3fe22227216f087772dc\"},\"headline\":\"Migrating\\\/updating from PHP 5 to PHP 7 on OS X (MacPorts)\",\"datePublished\":\"2015-12-30T10:01:16+00:00\",\"dateModified\":\"2015-12-30T10:05:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/\"},\"wordCount\":210,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/denbeke.be\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/PHP-7-logo-300x151.png\",\"keywords\":[\"apache\",\"macports\",\"os x\",\"php\"],\"articleSection\":[\"Servers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/\",\"name\":\"Migrating\\\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/denbeke.be\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/PHP-7-logo-300x151.png\",\"datePublished\":\"2015-12-30T10:01:16+00:00\",\"dateModified\":\"2015-12-30T10:05:18+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#\\\/schema\\\/person\\\/386878f712fe3fe22227216f087772dc\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#primaryimage\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/PHP-7-logo.png\",\"contentUrl\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/PHP-7-logo.png\",\"width\":727,\"height\":366},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/servers\\\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Migrating\\\/updating from PHP 5 to PHP 7 on OS X (MacPorts)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#\\\/schema\\\/person\\\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/","og_locale":"en_US","og_type":"article","og_title":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke","og_description":"PHP 7 was released earlier this month,\u00a0time for me to upgrade my development environment to keep up to date with this new version. I had already installed PHP 5.6 using MacPorts, so this guide is about upgrading a PHP 5 installation to a PHP 7. If you need help for actually installing PHP\/Apache\/MySQL, read this [&hellip;]","og_url":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/","og_site_name":"DenBeke","article_published_time":"2015-12-30T10:01:16+00:00","article_modified_time":"2015-12-30T10:05:18+00:00","og_image":[{"width":727,"height":366,"url":"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo.png","type":"image\/png"}],"author":"Mathias Beke","twitter_card":"summary_large_image","twitter_creator":"@MthsBk","twitter_site":"@MthsBk","twitter_misc":{"Written by":"Mathias Beke","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#article","isPartOf":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/"},"author":{"name":"Mathias Beke","@id":"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc"},"headline":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts)","datePublished":"2015-12-30T10:01:16+00:00","dateModified":"2015-12-30T10:05:18+00:00","mainEntityOfPage":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/"},"wordCount":210,"commentCount":3,"image":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#primaryimage"},"thumbnailUrl":"http:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo-300x151.png","keywords":["apache","macports","os x","php"],"articleSection":["Servers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/","url":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/","name":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts) &#8211; DenBeke","isPartOf":{"@id":"https:\/\/denbeke.be\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#primaryimage"},"image":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#primaryimage"},"thumbnailUrl":"http:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo-300x151.png","datePublished":"2015-12-30T10:01:16+00:00","dateModified":"2015-12-30T10:05:18+00:00","author":{"@id":"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc"},"breadcrumb":{"@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#primaryimage","url":"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo.png","contentUrl":"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2015\/12\/PHP-7-logo.png","width":727,"height":366},{"@type":"BreadcrumbList","@id":"https:\/\/denbeke.be\/blog\/servers\/migratingupdating-from-php-5-to-php-7-on-os-x-macports\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/denbeke.be\/blog\/"},{"@type":"ListItem","position":2,"name":"Migrating\/updating from PHP 5 to PHP 7 on OS X (MacPorts)"}]},{"@type":"WebSite","@id":"https:\/\/denbeke.be\/blog\/#website","url":"https:\/\/denbeke.be\/blog\/","name":"DenBeke","description":"Mathias Beke","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/denbeke.be\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc","name":"Mathias Beke","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8889cf00cef9570a8f82e7510ed97205ccb7a1a0d2c7e0968a07e1885386f198?s=96&d=mm&r=g","caption":"Mathias Beke"}}]}},"_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/1993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=1993"}],"version-history":[{"count":3,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/1993\/revisions"}],"predecessor-version":[{"id":1997,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/1993\/revisions\/1997"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=1993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/categories?post=1993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/tags?post=1993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}