Bitnami PHP

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.

PHP is a popular open source scripting language that is commonly used in Web application development.

How to change the date or timezone?

The default timezone is "America/Los_Angeles" but you can change it in the php.ini file, as shown below:

[Date]
date.timezone = "America/Los_Angeles"

You can see all available timezones at http://php.net/manual/en/timezones.php.

How to create a custom PHP application?

Many users run a Bitnami stack as a development environment for their own PHP projects (as opposed to running third-party applications such as Joomla! or WordPress). To deploy your PHP application in this environment, you have two options:

  • To make a single PHP application accessible at the root URL of the Web server (for example, http://localhost), simply copy the PHP files into the installdir/apache2/htdocs folder. For an example, take a look at the phpinfo example.

  • To have several applications running, create the same structure used by Bitnami when installing Bitnami PHP applications. Recent versions of Bitnami stacks ship a demo application with this structure to help you get started. To use this, follow the steps below:

    • Copy the installdir/docs/demo folder into the installdir/apps directory.

      $ sudo cp -r installdir/docs/demo installdir/apps
      
    • Add the following line to the end of the installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf file:

      Include "installdir/apps/demo/conf/httpd-prefix.conf"
      
    • Restart the Apache server using the command-line tool.

      $ sudo installdir/ctlscript.sh restart apache
      

    You should now be able to access the demo application at http://localhost/demo. You should see a "Hello world" message in your browser.

  • If your stack does not include a demo application, or if you prefer to create a custom PHP application from scratch, follow the steps below. These steps assume that your application will live in the installdir/apps/myapp/ directory:

    • Run the following commands to create the directories:

      $ sudo mkdir installdir/apps/myapp
      $ sudo mkdir installdir/apps/myapp/htdocs/
      $ sudo mkdir installdir/apps/myapp/conf
      
    • Create and edit the installdir/apps/myapp/conf/httpd-prefix.conf file and add the line below to it:

      Alias /myapp/ "installdir/apps/myapp/htdocs/"
      Alias /myapp "installdir/apps/myapp/htdocs/"
      Include "installdir/apps/myapp/conf/httpd-app.conf"
      
    • Create and edit the installdir/apps/myapp/conf/httpd-app.conf file and add the content below to it. This is the main configuration file for your application, so modify it further depending on your application's requirements.

      <Directory installdir/apps/myapp/htdocs/>
          Options +FollowSymLinks
          AllowOverride None
          <IfVersion < 2.3 >
          Order allow,deny
          Allow from all
          </IfVersion>
          <IfVersion >= 2.3>
          Require all granted
          </IfVersion>
      </Directory>
      
      NOTE: If your application uses .htaccess files, you should change the AllowOverride None option to AllowOverride All. Find out how to move the .htaccess file content to the main server configuration file.
    • Once you have created the files and directories above, add the following line to the end of the main Apache configuration file at installdir/apache2/conf/bitnami/bitnami-apps-prefix.conf, as shown below:

      Include "installdir/apps/myapp/conf/httpd-prefix.conf"
      
    • Restart the Apache server:

      $ sudo installdir/ctlscript.sh restart apache
      

      You should now be able to access the application at http://localhost/myapp.

How can I deploy my PHP application?

The main directory to deploy your PHP application is installdir/apache2/htdocs. You can copy your PHP application files to that directory and access the application via your browser at http://localhost/.

How to install the APCu module?

NOTE: The APCu module is only compatible with PHP 7.x.

APCu is the APC User Cache module. Install it manually following the steps below:

  • Install the following packages:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget 
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source package from the web page, uncompress it and compile the module.

     $ wget https://pecl.php.net/get/apcu-X.Y.Z.tgz
     $ tar xzf apcu-X.Y.Z.tgz
     $ cd apcu-X.Y.Z
     $ phpize
     $ ./configure --with-php-config=installdir/php/bin/php-config
     $ make
     $ sudo make install
    
  • Enable the module by adding the following line in the php.ini file:

     ...
     extension = apcu.so
     ...
    

How to install the eAccelerator module?

eAccelerator is a free open-source PHP accelerator and optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution.

Follow the steps below to install this module:

  • Install the following packages:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

      $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the eAccelerator web page, copy to the server, uncompress it and compile the module:

     $ unzip eaccelerator-*.zip
     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd eaccelerator-0.9.6.1
     $ installdir/php/bin/phpize
     $ ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
     $ make
     $ sudo make install
    
  • Enable the module in the php.ini file:

     ...
     extension=eaccelerator.so
     ...
    
  • Check it and verify that the output looks similar:

     $ php -version
    
     Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
         with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
    

Now, configure this module in the php.ini file. For more information, refer to http://eaccelerator.net/wiki/InstallFromSource.

How to install the FreeTDS and MSSQL modules?

FreeTDS is a set of libraries for Unix and Linux that allow your programs to natively talk to Microsoft SQL Server and Sybase databases.

NOTE: Since LAMP stack v5.4.25, this module is already included so it is only necessary to enable the module in the php.ini file.

Follow these steps:

  • Load the build environment and add -liconv to the LDFLAGS:

     $ .  installdir/scripts/build-setenv.sh
     $ export LDFLAGS="$LDFLAGS -liconv"
    
  • Install FreeTDS:

     $ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
     $ tar zxf freetds-patched.tgz
     $ cd freetds-0.95.21/
     $ ./configure --enable-msdblib --prefix=/usr/local/freetds
     $ make
     $ sudo make install
     $ cd ..
    
  • Compile and install the MSSQL module for PHP. Note that you should download the module that matches the PHP version in use. Check the current PHP version with the php -v command.

     $ wget http://us.php.net/distributions/php-5.4.45.tar.bz2
     $ tar jxf php-5.4.45.tar.bz2
     $ cd php-5.4.45/ext/mssql/
     $ phpize
     $ ./configure --with-mssql=/usr/local/freetds
     $ make
     $ sudo make install
    
  • Confirm that the mssql.so library has been copied to the installdir/php/lib/php/extensions/ directory.

  • Edit the installdir/php/etc/php.ini file and add the line below to it:

     extension=mssql.so
    
  • Restart the server:

     $ sudo installdir/ctlscript.sh restart apache
    

How to install the mod_geoip2 module?

The mod_geoip2 module embeds GeoIP database lookups into the Apache web server. It is only capable of looking up the IP address of a client that connects to the web server, as opposed to looking up arbitrary addresses.

If this module is not in your stack, you can install it manually following the steps below.

  • Install the following packages if necessary:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Install the development files for libgeoip:

    • Debian:

       $ sudo apt-get install libgeoip-dev
      
    • CentOS:

       $ sudo yum install GeoIP
      
  • Download the latest source code from the web page, uncompress it and compile the module.

     $ wget http://www.maxmind.com/download/geoip/api/mod_geoip2/mod_geoip2-latest.tar.gz
    
  • Uncompress it and build the libraries

     $ tar -xzvf mod_geoip2-latest.tar.gz
     $ cd mod_geoip2_*
     $ sudo apxs -i -a -lGeoIP -c mod_geoip.c
    

    The module should now be available at installdir/apache2/modules/mod_geoip.so. It is also automatically included in your Apache configuration.

  • Enable GeoIP in the Apache configuration by adding the line GeoIPEnable On in the installdir/apache2/conf/httpd.conf file. Find other specific configuration settings at http://dev.maxmind.com/geoip/mod_geoip2#Configuration-2.

  • Restart the Apache server:

     $ sudo installdir/ctlscript.sh restart apache
    

How to enable the Imagick extension?

The Imagick module is installed in Bitnami stacks, but is not enabled by default. To enable it, follow these steps:

  • Uncomment or add the following line to the installdir/php/etc/php.ini file:

     ...
     extension=imagick.so
     ...
    
  • Restart the Apache server and/or the PHP-FPM service (if available):

     $ sudo installdir/ctlscript.sh restart apache
     $ sudo installdir/ctlscript.sh restart php-fpm
    

How to install the IonCube extension?

Follow these steps:

  • Download the pre-compiled version and copy the .so file to the PHP extensions directory. It is very important to install the right version of Ioncube taking into account the PHP version included in your solution. For example, if you want to install Ioncube on WordPress and it uses PHP 7.0.27, you need to install the version 7.0 of Ioncube.

    NOTE: Y and Z are placeholders. Remember to replace them with the corresponding Ioncube version number.
    $ wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_xY-Z.tar.gz
    $ tar xvzf ioncube_loaders_lin_xY-Z.tar.gz
    $ sudo cp ioncube/ioncube_loader_lin_Y.Z.so installdir/php/lib/php/extensions/
    
  • Add the following line to the php.ini file:

    zend_extension = installdir/php/lib/php/extensions/ioncube_loader_lin_Y.Z.so
    
  • Restart PHP-FPM and Apache.

How to install the memcache module?

The memcache module provides a handy procedural and object-oriented interface to memcached, the highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

If this module is not in your stack, you can install it manually following these steps:

  • Install the following packages:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget 
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module.

     $ wget http://pecl.php.net/get/memcache-2.2.7.tgz
     $ tar -zxf memcache-2.2.7.tgz
     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd memcache-2.2.7
     $ installdir/php/bin/phpize
     $ ./configure --enable-memcache --with-zlib-dir=installdir/common
     $ make
     $ sudo make install
    
  • Enable the module in the php.ini file:

     ...
     extension=memcache.so
     ...
    

How to install the memcached module using the libmemcached library?

Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. This extension uses the libmemcached library to provide an API for communicating with memcached servers.

If this module is not in your stack, you can install it manually following these steps. The steps differ for PHP5 and PHP7, so choose the appropriate section below depending on the PHP version bundled with your stack. To obtain the PHP version, use the command php -v at your console prompt.

Installation

PHP7
  • Install development tools:
    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget git
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the library. Replace the placeholder version X.Y with the most current version.

     $ wget https://launchpad.net/libmemcached/1.0/1.X.Y/+download/libmemcached-1.X.Y.tar.gz
     $ tar -zxf libmemcached-1.X.Y.tar.gz
     $ cd libmemcached-1.X.Y
     $ ./configure --prefix=installdir/common
     $ make
     $ sudo make install
    
  • Download and compile the PHP7 version of the PHP memcached module:

     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd ~/
     $ git clone https://github.com/php-memcached-dev/php-memcached.git
     $ cd php-memcached
     $ git checkout php7
     $ installdir/php/bin/phpize
     $ ./configure --enable-memcached --with-zlib-dir=installdir/common --with-libmemcached-dir=installdir/common --with-php-config=installdir/php/bin/php-config --disable-memcached-sasl
     $ make
     $ sudo make install
    
  • Enable the module in the php.ini file:

     $ echo 'extension=memcached.so' | sudo tee -a installdir/php/etc/php.ini
    
  • Start the memcached server by running these commands:

     $ mv installdir/memcached/scripts/ctl.sh.disabled installdir/memcached/scripts/ctl.sh
    
     $ sudo installdir/ctlscript.sh start memcached
    

    If you get an error, check that your stack includes the memcached server:

     $ sudo installdir/ctlscript.sh status memcached
    

    Usually, if you don't see the status, it is because you are using a stack that doesn't bundle the memcached server. To install and start it, run:

     $ sudo apt-get install memcached
     $ sudo /etc/init.d/memcached start
     $ sudo installdir/ctlscript.sh restart apache
    
PHP5
  • Install development tools:
    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module. Replace the placeholder version X.Y or X.Y.Z with the most current version.

     $ wget https://launchpad.net/libmemcached/1.0/1.X.Y/+download/libmemcached-1.X.Y.tar.gz
     $ tar -zxf libmemcached-1.X.Y.tar.gz
     $ cd libmemcached-1.X.Y
     $ ./configure --prefix=installdir/common
     $ make
     $ sudo make install
     $ cd ~/
     $ wget http://pecl.php.net/get/memcached-X.Y.Z.tgz
     $ tar -zxf memcached-X.Y.Z.tgz
     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd memcached-X.Y.Z
     $ installdir/php/bin/phpize
     $ ./configure --enable-memcached --with-zlib-dir=installdir/common --with-libmemcached-dir=installdir/common --with-php-config=installdir/php/bin/php-config
     $ make
     $ sudo make install
    
  • Enable the module in the php.ini file:

     $ echo 'extension=memcached.so' | sudo tee -a installdir/php/etc/php.ini
    
  • Start the memcached server by running these commands:

     $ mv installdir/memcached/scripts/ctl.sh.disabled installdir/memcached/scripts/ctl.sh
    
     $ sudo installdir/ctlscript.sh start memcached
    

    If you get an error, check that your stack includes the memcached server:

     $ sudo installdir/ctlscript.sh status memcached
    

    Usually, if you don't see the status, it is because you are using a stack that doesn't bundle the memcached server. To install and start it, run:

     $ sudo apt-get install memcached
     $ sudo /etc/init.d/memcached start
     $ sudo installdir/ctlscript.sh restart apache
    

Testing

Check that the PHP memcached extension is installed:

    $ php -m | grep memcached

Once installed, check if the PHP memcached extension is working properly. To do this, create a PHP script file in your htdocs/ directory with the code below and access it using your Web browser:

    <?php
    $mc = new Memcached();
    $mc->addServer("127.0.0.1", 11211);

    $result = $mc->get("test_key");

    if($result) {
        echo $result;
    } else {
        echo "No data in cache. Please refresh page.";
        $mc->set("test_key", "test data pulled from cache!") or die ("Failed to save data in memcached server");
    }
    ?>

How to install the Mongo module?

The Mongo PHP module is a MongoDB driver.

If this module is not in your stack, you can install it manually following these steps:

  • Compile and install the module:

     $ sudo pecl install mongo
     ...
     Build process completed successfully
     Installing 'installdir/php/lib/php/extensions/<wbr>mongo.so'
     install ok: channel://pecl.php.net/mongo-<wbr>1.4.5</wbr><wbr>
     configuration option "php_ini" is not set to php.ini location
     You should add "extension=mongo.so" to php.ini</wbr></wbr>
    
  • Enable the module in the php.ini file:

     ...
     extension=mongo.so
     ...
    
  • Restart Apache:

     $ installdir/ctlscript.sh restart 
    

How to install the OAuth module?

OAuth is an authorization protocol built on top of HTTP which allows applications to securely access data without having to store usernames and passwords.

Follow these steps:

  • Install the following packages:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget 
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module.

     $ wget http://pecl.php.net/get/oauth-1.2.2.tgz
     $ tar -zxf oauth*
     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd oauth-*
     $ installdir/php/bin/phpize
     $ ./configure
     $ make
     $ sudo make install
    
  • Enable the module by adding the following line in the php.ini file:

     ...
     extension = 'installdir/php/lib/php/extensions/oauth.so'
     ... 
    
  • Check if the extension is loaded with the following command:

     $ php -i | grep -i oauth
    

How to install the OCI8 module?

Since LAMP/MAMP/WAMP stacks v5.4.34, 5.5.18 and 5.6.2, Bitnami stacks ship the oci8 module already compiled for each platform. This module requires users to download and install the InstantClient libraries from Oracle.

Follow these steps:

Linux and Mac OS X

  • Extract the package contents in your home folder.

  • Add the following environment variable to the end of your installdir/scripts/setenv.sh file:

    For Linux:

     LD_LIBRARY_PATH=/home/bitnami/instantclient_11_2:$LD_LIBRARY_PATH
     export LD_LIBRARY_PATH
    

    For Mac OS X:

     DYLD_LIBRARY_PATH=/Users/bitnami/instantclient_11_2:$LD_LIBRARY_PATH
     export DYLD_LIBRARY_PATH
    
  • Restart the servers:

     $ sudo installdir/ctlscript.sh restart
    
  • Check again if the module is active:

     $ installdir/php/bin/php -m
    

Windows

  • Extract the package contents in your home folder.

  • Copy the required DLL files from the package folder to *installdir/php/.

  • Check again if the module is active:

     $ installdir/php/bin/php -m
    

How to enable the OpenSSL extension?

Linux and Mac OS X

The OpenSSL module for PHP is already enabled and no additional configuration is required.

Windows

Edit the php.ini file located in your installation directory in the php directory and uncomment the following line:

extension=php_openssl.dll

Additionally, you may want to add the environment variable OPENSSL_CONF so PHP can easily find the installdir/apache2/conf/openssl.cnf file.

More information can be found in the official PHP documentation.

How to install the PDO_IBM module?

Linux and Mac OS X

Bitnami LAMP/MAMP Stacks include the PDO_IBM module but it is necessary to activate it. To do this, follow the steps below:

Follow these steps:

  • Enable the PDO_IBM module in the installdir/php/etc/php.ini file by adding the following line:

     extension=pdo_ibm.so
    
  • Check if the module is enabled with the following command:

     $ installdir/php/bin/php -m
    
  • In case you see a PHP warning, download the Data Server Driver Package for your platform from the IBM website.

  • Extract the package contents to your home folder and install it by running the following commands:

     $ cd /home/bitnami/dsdriver
     $ bash installDSDriver 
    
  • Add the following environment variable at the end of your installdir/scripts/setenv.sh* file:

     LD_LIBRARY_PATH=/home/bitnami/dsdriver/lib:$LD_LIBRARY_PATH
     export LD_LIBRARY_PATH
    
  • Restart the server:

     $ sudo installdir/ctlscript.sh restart apache
    
  • Check again if the module is active. If it is, no warning will be displayed.

     $ installdir/php/bin/php -m | grep ibm
    

Windows

The Bitnami WAMP Stack no longer includes the PDO_IBM module and it is necessary to download it separately and copy it to the PHP extensions directory. Remember to download the VC11 thread-safe version.

Once the module is copied to the PHP extensions directory, follow the steps below:

  • Enable the PDO_IBM module in the installdir/php/etc/php.ini file by adding the following line:

     extension=php_pdo_ibm.dll
    
  • Check if the module is enabled with the following command:

     $ installdir/php/bin/php -m
    
  • In case you see a PHP warning, download the Data Server Driver Package for your platform from the IBM website and install it.

  • Restart the server using the graphical manager.

  • Check again if the module is active. If it is, no warning will be displayed.

     $ installdir/php/bin/php -m | findstr ibm
    

How to install the pdo_pgsql module?

Install the pdo_pgsql module by following these steps:

  • Download the module source code and extract it:

     $ pecl download pdo_pgsql
     $ tar xzf PDO_PGSQL-1.0.2.tgz
    
  • Compile the code:

     $ cd PDO_PGSQL-1.0.2
     $ phpize
     $ ./configure --with-pdo-pgsql=/path/to/your/PostgreSQL/installation
     $ make && sudo make install
    
  • Confirm that the pdo_pgsql.so extension is available at installdir/php/lib/php/extensions.

  • Enable the module by adding the following line to the installdir/php/etc/php.ini file inside the "Dynamic Extensions" section:

     extension=pdo_pgsql.so
    

How to install the Redis extension?

The phpredis extension provides an API for communicating with the Redis key-value store. Follow these steps to install it:

  • Install the following package:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install -y autoconf
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools" 
      
  • Download the latest source code from the web page, uncompress it and compile the module:

     $ wget https://pecl.php.net/get/redis-VERSION.tgz
     $ tar -xvf redis-VERSION.tgz
     $ cd redis-VERSION
     $ phpize
     $ ./configure
     $ make
     $ sudo make install
    

    Replace VERSION placeholder with the correct value for the latest Redis version.

  • Enable the module in the installdir/php/etc/php.ini file by adding this line to the end:

     extension=redis.so
    
  • Check that the module was correctly installed with the following command:

     $ php -m | grep redis
    

More information can be found in the official documentation at https://github.com/phpredis/phpredis.

How to install the Solr module?

The Apache Solr PHP extension is an extremely fast, light-weight, feature-rich library that allows PHP applications to communicate easily and efficiently with Apache Solr server instances using an object-oriented API.

If this module is not in your stack, install it manually following these steps:

  • Install the following packages:

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget 
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module:

     $ wget http://pecl.php.net/get/solr-1.0.2.tgz
     $ tar -zxf solr-1.0.2.tgz
     $ export PHP_AUTOCONF=/usr/bin/autoconf
     $ export PHP_PREFIX=installdir/php
     $ cd solr-1.0.2
     $ installdir/php/bin/phpize
     $ ./configure --enable-solr --with-curl=installdir/common --with-libxml-dir=installdir/common
     $ make
     $ sudo make install
    
  • Enable the module in the php.ini file:

     ...
     extension=solr.so
     ...
    
  • Restart the server:

     $ sudo installdir/ctlscript.sh restart apache
    

How to install the SSH2 module for PHP?

Install and enable the SSH2 module for PHP by following these steps:

  • Install the libssl-dev package:
    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install libssl-dev
      
    • CentOS: the libssl-dev package is installed by default. You can check it by executing yum info openssl.

  • Download and compile libssh2 and ssh2:

     $ cd /tmp
     $ wget http://www.libssh2.org/download/libssh2-1.4.3.tar.gz
     $ tar vxzf libssh2-1.4.3.tar.gz
     $ cd libssh2-1.4.3
     $ ./configure
     $ make
     $ make install
     $ cd /tmp
     $ wget http://pecl.php.net/get/ssh2-0.12.tgz
     $ tar vxzf ssh2-0.12.tgz
     $ cd ssh2-0.12
     $ phpize
     $ ./configure --with-ssh2
     $ make
     $ make install
    
  • Copy the ssh2.so file into the shared extensions folder at installdir/php/lib/php/extensions/ and modify the installdir/php/etc/php.ini file to add the following line:

     ...
     extension=ssh2.so
     ...
    
  • Restart the server and you will now have the ability to run SSH2 commands.

Thanks to @Chris_James for posting this guide!

How to install the Tidy module?

Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree.

If this module is not in your stack, you can install it manually following these steps:

  • Install the following packages (they are already in the machine in recent versions):

    • Debian:

       $ sudo apt-get update
       $ sudo apt-get install build-essential libtool autoconf unzip wget 
      
    • CentOS:

       $ sudo yum groups mark install "Development Tools"
      
  • Download the latest source code from the web page, uncompress it and compile the module:

     $ wget http://tidy.cvs.sourceforge.net/viewvc/tidy/tidy/?view=tar
    
  • Uncompress it and build the libraries:

     $ cd /home/bitnami
     $ tar -xzvf tidy-tidy.tar.gz
     $ cd tidy/build/gmake
     $ make
    
  • Download the PHP source code version that you are currently using and uncompress it. Then, build the shared module for tidy:

     $ tar -xzvf php-VERSION.tar.gz
     $ cd php/ext/tidy
     $ ./phpize
     $ ./configure --with-tidy=/home/bitnami/tidy
     $ make
     $ sudo make install
    

How to enable the XCache extension?

The XCache module is installed in Bitnami stacks, but is not enabled by default. To enable it, follow these steps:

  • Add the following lines to the installdir/php/etc/php.ini file:

     ...
     [xcache-common]
     extension=xcache.so
     ...
    
  • Restart the Apache server to include the new configuration:

     $ sudo installdir/ctlscript.sh restart apache
    

How to install the XCache administration page?

Once XCache is installed, add the XCache administration page to obtain information on cache operations. This is not included by default, so follow the steps below:

  • Download the complete tarball containing the XCache Administration Page for the XCache version included in the Bitnami stack. Find XCache versions at http://xcache.lighttpd.net. To check your current XCache version, use the command php -v.

  • Extract the tarball content and use the htdocs folder to enable the XCache administration page.

  • Generate and save your authentication password. The XCache administration page is protected with HTTP authentication. Edit your php.ini file and add these lines to include your user and password.

     xcache.admin.user = "user"
     xcache.admin.pass = "6a4dc9133d5f3b6d9fff778aff361961"
    

    The password must be specified in MD5 format. Here is a simple PHP script that returns the encrypted MD5 version of a plaintext password:

     <?php
     echo md5("password");
     ?>
    
  • Create a new xcache directory and add the Apache configuration files to it. Find out how to create a custom application.

  • Access your XCache administration page through your browser.

How to install the Zend Guard Loader extension?

Zend Guard is a free runtime application that enables PHP to run scripts encoded by Zend Guard. It can be freely used by anyone looking to run encoded applications. Follow these steps:

  • Download the binary version of the extension from the Zend Guard site.

  • Run the following commands:

     $ tar -xzvf  ZendGuardLoader-*-PHP-5.4-linux-glibc23-x86_64.tar.gz
     $ sudo cp ZendGuard*/php-5.4.x/ZendGuardLoader.so installdir/php/lib/php/extensions/
    
  • Add the following entry to the end of the php.ini file:

     zend_extension = installdir/php/lib/php/extensions/ZendGuardLoader.so
    
  • Check that the module was correctly installed with the following command:

     $ php -m | grep Zend
    

How to enable the ZipArchive extension?

ZipArchive is a class of the zip PHP module. This module is enabled by default. Check it with the following command:

$ sudo installdir/php/bin/php -m | grep zip
zip

Here is a script named sample.php that lists the content of a zip file named sample.zip:

<?php
$za = new ZipArchive();
$za->open('sample.zip');
for( $i = 0; $i < $za->numFiles; $i++ ){
    $stat = $za->statIndex( $i );
    print_r( basename( $stat['name'] ) . PHP_EOL );
}
?>

To use this script, create a sample.zip file and run this script at the server console, as below:

$ installdir/php/bin/php sample.php

How to install New Relic for PHP?

To install New Relic for PHP, refer to this page.

How to modify the allowed limit for uploaded files?

Modify the following options in the installdir/php/etc/php.ini file to increase the allowed size for uploads:

; Maximum size of POST data that PHP will accept.
post_max_size = 16M

; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

Restart PHP-FPM and Apache for the changes to take effect.

$ sudo installdir/ctlscript.sh restart apache
$ sudo installdir/ctlscript.sh restart php-fpm    

How to modify the allowed limit for uploaded files?

Modify the following options in the installdir/php/etc/php.ini file to increase the allowed size for uploads:

; Maximum size of POST data that PHP will accept.
post_max_size = 16M

; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

Restart PHP-FPM and NGINX for the changes to take effect.

$ sudo installdir/ctlscript.sh restart nginx
$ sudo installdir/ctlscript.sh restart php-fpm

How to install PHP modules?

To install a PHP module, the typical process is to install the module (either via the package manager or through a manual build/install process) and then activate it in the above configuration file. Find instructions for installing specific PHP modules.

NOTE: Bitnami stacks already include a number of PHP modules, which are installed but not active. Before installing a new module, check that it is not already included. If it exists, simply enable it in the PHP configuration file.

After modifying the PHP configuration file, restart both Apache and PHP-FPM for the changes to take effect:

$ sudo installdir/ctlscript.sh restart apache
$ sudo installdir/ctlscript.sh restart php-fpm

How to modify PHP settings?

The PHP configuration file allows you to configure the modules enabled, the email settings or the size of the upload files. It is located at installdir/php/etc/php.ini.

For example, to modify the default upload limit for PHP, update the PHP configuration file following these instructions.

After modifying the PHP configuration file, restart both Apache and PHP-FPM for the changes to take effect:

$ sudo installdir/ctlscript.sh restart apache
$ sudo installdir/ctlscript.sh restart php-fpm

How to modify PHP settings?

The PHP configuration file allows you to configure the modules enabled, the email settings or the size of the upload files. It is located at installdir/php/etc/php.ini.

For example, to modify the default upload limit for PHP, update the PHP configuration file following these instructions.

After modifying the PHP configuration file, restart both NGINX and PHP-FPM for the changes to take effect:

$ sudo installdir/ctlscript.sh restart nginx
$ sudo installdir/ctlscript.sh restart php-fpm

How to modify the execution time?

This parameter sets the timeout for Apache to run a script. Modify it in the php.ini file.

max_execution_time = 120     ; Maximum execution time of each script, in seconds 

How to check the installed PHP modules?

The easiest way to check which PHP modules are installed is to create a test script using the phpinfo() function. Open your favorite text editor and type:

<?php phpinfo(); ?>

Save the file as phptest.php in installdir/apache2/htdocs/. Make sure Apache is up and running, open a browser and type http://localhost/phptest.php. You should then see a screen showing detailed information about the PHP version you are using and installed modules.

You can also run the following command:

$ installdir/php/bin/php -m

How to send email via an external SMTP account?

To make sure your emails are delivered properly, configure your PHP script or PHP application to use an external SMTP account. The following example shows how to do this using a Gmail account.

  • Install the Mail and Net_SMTP PEAR modules:

     $ sudo installdir/php/bin/pear install pear/Net_SMTP pear/Mail-1.2.0
    

    Note that if these packages are already installed in your system you see the messages below when executing that command:

     Ignoring installed package pear/Net_SMTP
     Ignoring installed package pear/Mail
     Nothing to install
    
  • Use the script below to send an email. Place it in your pear directory and execute it with the PHP CLI:

     <?php
     require_once "Mail.php";
    
     $from = "myaccount@gmail.com";
     $to = 'test@mytest.com';
    
     $host = "ssl://smtp.gmail.com";
     $port = "465";
     $username = 'myaccount@gmail.com';
     $password = 'mypassword';
    
     $subject = "test";
     $body = "test";
    
     $headers = array ('From' => $from, 'To' => $to,'Subject' => $subject);
     $smtp = Mail::factory('smtp',
       array ('host' => $host,
         'port' => $port,
         'auth' => true,
         'username' => $username,
         'password' => $password));
    
     $mail = $smtp->send($to, $headers, $body);
    
     if (PEAR::isError($mail)) {
       echo($mail->getMessage());
     } else {
       echo("Message successfully sent!\n");
     }
     ?>
    

How to send email using sendmail?

To use sendmail instead of an external SMTP server, first check that sendmail is installed by executing the command below:

$ sudo /usr/sbin/sendmail -q

If sendmail is not installed, install it with the command below:

  • Debian:

      $ sudo apt-get install sendmail
    
  • CentOS:

      $ sudo yum install sendmail
    

Configure PHP to use sendmail by uncommenting this line in the PHP configuration file at installdir/php/etc/php.ini:

sendmail_path = "env -i /usr/sbin/sendmail -t -i"

Where is the PHP configuration file?

The PHP configuration file allows you to configure the modules enabled, the email settings or the size of the upload files. It is located at installdir/php/etc/php.ini (Linux and Mac OS X) or installdir/php/php.ini (Windows).

NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.

How to configure NetBeans with Bitnami LAMP, MAMP or WAMP stacks?

NOTE: Before starting, install the Bitnami LAMP, MAMP or WAMP Stack with the NetBeans IDE and its PHP module.
  • Create your first project in NetBeans using "File -> New Project".

  • Select the PHP category and start a new PHP application project.

  • Save the source files in the /Applications/mampstack-VERSION/apache2/htdocs directory (Mac OS X), C:\Bitnami\wampstack-VERSION\apache2\htdocs (Windows) or /home/USER/lampstack-VERSION/apache2/htdocs (Linux).

    Netbeans project

  • Select how to run your project. Select "Local Web Site" so it is only necessary to set the URL. This URL will be different depending on your platform. Use http://localhost:8080 for Linux and Mac OS X, and http://localhost for Windows.

    Netbeans project

    It is also possible to run PHP scripts from the command line. Set the path to the PHP binary file to /Applications/mampstack-VERSION/php/bin/php (Mac OS X), /home/USER/lampstack-VERSION/php/bin/php (Linux) or C:\Bitnami\wampstack-VERSION\php\php\php.exe (Windows).

    Netbeans project

  • Once you start a new project, also start debugging your application from the NetBeans interface. If you want to configure an existing project with the Bitnami LAMP, MAMP or WAMP Stack, you can also modify the project settings.

nativeInstaller

Bitnami Documentation