PHP - HVboom/HowTo-DigitalOcean GitHub Wiki

Description

PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. Its syntax draws upon C, Java, and Perl, and is easy to learn. The main goal of the language is to allow web developers to write dynamically generated webpages quickly, but you can do much more with PHP.

:speech_balloon: copied from package description

Setup PHP

  • Follow the instruction to setup PHP:

    sudo pkg install mod_php70 php70-mysqli php70-openssl
    sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
    # ensure, that the _ini_ file is readable by the apache process
    sudo chmod o+r /usr/local/etc/php.ini
    
  • Currently none of the available extension modules pkg search php70 will be installed

  • Activating Apache to serve PHP files, by creating a dedicated configuration file. (No direct manipulation of the Apache configuration)

  • Test the installation by executing

    # restart Apache
    sudo service apache24 restart
    # create the test file with content "<?php phpinfo(); ?>" & ensure it is readable
    sudo touch /usr/local/www/apache24/data/admin/info.php
    sudo bash -c 'echo "<?php phpinfo(); ?>" >> /usr/local/www/apache24/data/admin/info.php'
    sudo chmod o+r /usr/local/www/apache24/data/admin/info.php
    

Install Composer to manage PHP package dependencies

# install necessary PHP modules
sudo pkg install php70-phar php70-hash php70-json php70-filter php70-iconv php70-zlib php70-openssl

# download and verify a setup script
sudo php -r "readfile('https://getcomposer.org/installer');" > /tmp/composer-setup.php
sudo php -r "chdir('/tmp'); if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

# install _/usr/local/bin/composer_ script
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer