googlelapp

Get started with CodeIgniter

The CodeIgniter framework is not installed by default in Bitnami installations. However, it can be easily enabled using Composer. In this guide, you will learn how to install and configure a CodeIgniter 4 project.

Installation and Testing

NOTE: This section assumes that the application project directory will be located at /opt/bitnami/projects/APPNAME. Remember to replace the APPNAME placeholder with the application name, such as myapp.

  • First, create a project directory where to store your application. Run the following commands:

      $ sudo mkdir -p /opt/bitnami/projects/APPNAME
      $ sudo chown $USER /opt/bitnami/projects/APPNAME
    
  • Create the CodeIgniter project. Run the following command:

      $ composer create-project codeigniter4/appstarter /opt/bitnami/projects/APPNAME
    
  • Grant write permissions for the web server to the writable directory. Run the following command:

      $ sudo chown daemon:daemon /opt/bitnami/projects/APPNAME/writable
    
  • Create the Apache configuration for your application. Follow these steps:

    • Create the /opt/bitnami/apache/conf/vhosts/APPNAME-vhost.conf file containing the application’s HTTP virtual host configuration with the configuration block shown below:

        <VirtualHost 127.0.0.1:80 _default_:80>
          ServerAlias *
          DocumentRoot /opt/bitnami/projects/APPNAME/public
          <Directory "/opt/bitnami/projects/APPNAME/public">
            Options -Indexes +FollowSymLinks -MultiViews
            AllowOverride All
            Require all granted
          </Directory>
        </VirtualHost>
      
    • Create the /opt/bitnami/apache/conf/vhosts/APPNAME-https-vhost.conf file containing the application HTTPS virtual host configuration with the configuration block shown below:

        <VirtualHost 127.0.0.1:443 _default_:443>
          ServerAlias *
          DocumentRoot /opt/bitnami/projects/APPNAME/public
          SSLEngine on
          SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"
          SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"
          <Directory "/opt/bitnami/projects/APPNAME/public">
            Options -Indexes +FollowSymLinks -MultiViews
            AllowOverride All
            Require all granted
          </Directory>
        </VirtualHost>
      
  • Finally, restart the Apache server:

      $ sudo /opt/bitnami/ctlscript.sh restart apache
    

You can now verify that the example application is working by visiting its URL using your browser at http://SERVER-IP/. Here is an example of what you might see:

CodeIgniter 4 welcome page

Configuration

Before using the example application, if your application will use a database, edit the database settings at the .env file.

NOTE: If the /opt/bitnami/projects/APPNAME/.env file does not exist, create it.

database.default.hostname = localhost
database.default.port = 3306
database.default.database = database_name
database.default.username = user
database.default.password = pass
database.default.DBDriver = MySQLi
# database.default.DBPrefix =

MySQL support is already available by default. If you plan to use PostgreSQL, enable the pdo_pgsql extension in the /opt/bitnami/php/etc/php.ini file.

extension=pdo_pgsql

More Information

Learn more about developing applications with CodeIgniter at https://codeigniter.com/user_guide/index.html.

Last modification February 9, 2023