Switch to: V12V11V10V9V8V7V6V5

Valentina PHP: Install on macOS

This page discusses installing Valentina PHP on macOS 10.15 (Catalina).

Install VPHP

Open vphp_x64_11_mac.dmg disk image and run vphp.pkg. The package is installed to /Users/Shared/VPHP_x64_11 folder.

Copy VPHP/Examples Folder

To use the examples for VPHP and easily use phpinfo() you need to copy the VPHP/Examples folder to the /Library/WebServer/Documents folder.

Starting Web Server

Web serving is built into macOS with Apache app, it is installed ready to be fired up.

This needs to be done in the Terminal which is found in the OS filing system at /Applications/Utilities/Terminal

To start Apache web sharing

sudo apachectl start
  <<< type password when asked  

TESTING:

To test that this works, type in your browser the string shown in the settings. For example:

http://localhost

If you see a web page then it's all right.

Now you can try to see the page, which shows the PHP info on your Mac:

http://localhost/Examples/get_php_info.php

If you get nothing, then you need to read the next section to enable PHP. Otherwise, you can skip it and go to the next section.

Enable PHP on your macOS

First, make sure that PHP is enabled on your macOS, it comes with a default installation of PHP, but it is not enabled for development and use. You can find many guides that explain how to enable it on Google; for example this one [https://wpbeaches.com/install-apache-mysql-php-on-macos-11-big-sur-and-earlier-macos/].

macOS has System Integrity Protection (SIP), which prohibits writing to important system directories, even for the root user. Enabling PHP requires editing Apache configuration file which is located in such a directory.

To overcome this issue it is necessary to disable SIP, at least during the configuration of Apache, PHP, Valentina PHP Extension.

You can check the status of sip in the Terminal.app:

csrutil status
System Integrity Protection status: enabled.

To disable SIP, do the following:

  1. Restart your computer in Recovery mode.
  2. Launch Terminal from the Utilities menu.
  3. Run the command csrutil disable.
  4. Restart your computer.

Now modify the Apache configuration:

  1. Open Terminal and navigate to the apache2 directory by typing cd /etc/apache2
  2. Using your text editor of choice, open httpd.conf; in this case, we'll use nano. We should use sudo because the root is the owner of httpd.conf: sudo nano httpd.conf
  3. Press Control-W and search for php; uncomment the line that loads the PHP module by deleting the # at the front, leaving this: LoadModule php7_module
  4. Save the changes by pressing Control-X, then press Y, then press Enter.
  5. Now restart the server:
sudo apachectl restart

Of course, you can use any other way to get the same; for example, you can use TextMate to edit this file without the terminal.

TESTING

In the browser go to

http://localhost/Examples/get_php_info.php 

You should be able to see a page with PHP information, note the version.

The major version of the PHP engine must match the PHP version of the supplied VPHP extension (e.g. for PHP 7.3 we should use php_73_valentina_fat_x64.so)

Create php.ini

By default, /etc/php.ini does not exist on your Mac. You should create it by copying the php.default.ini file. The easiest way to do this is from the Terminal.app:

cd /etc
sudo cp php.ini.default php.ini

Edit php.ini

To point PHP where to find the VPHP module do the following:

  • Open this new php.ini file, find a section
; Dynamic Extensions ;
  • add one or a few lines here
extension=/Users/Shared/VPHP_x64_11/php_73_valentina_fat_x64.so.so
extension=/Users/Shared/VPHP_x64_11/php_73_pdo_valentina_fat_x64.so
extension=/Users/Shared/VPHP_x64_11/php_73_pdo_vsqlite_fat_x64.so

An absolute path is used in the definition. PHP extensions are saved in /usr/lib/php/extensions/no-debug-non-zts-xxxxxxxx directory, but this folder is read-only, so easier to specify an absolute path.

  • Save and close php.ini file.

NOTE: For your computer you should check the exact name of this folder and use it.

Restart Apache

To enable PHP to see all these changes you should restart Apache from the Terminal

  sudo apachectl restart

TESTING:

Reload in the browser the page with phpinfo. Now try to find Valentina word on this page. You should find a section about the Valentina module:

Congratulations! Now you can use VPHP on your Mac to develop your websites.