Subject
- #Codeigniter 4
- #PHP Extension Installation
- #Apache2
- #CI4 Initial Screen
- #Development Server Environment Setup
Created: 2024-03-27
Created: 2024-03-27 19:47
Codeigniter 4.
I had the opportunity to work on a new project at my company. Since the existing web pages were built using Codeigniter 3 after I joined the company, I decided to use Codeigniter 4 out of curiosity and anticipation.
The first thing to do is set up a development server. This document was created to record the struggles (?) I encountered while setting up Codeigniter 4 on the development server.
The operating system of the development server was tested on Ubuntu 20.04.2 version
Since Apache2 and PHP version 7 were already installed, I downloaded the Codeigniter 4 (hereinafter referred to as CI4) framework files.
I accessed the URL above, clicked on CI4 Download, and downloaded the framework files. Apparently, PHP version 7.3 or higher is required.
After extracting the archive, you can see the files shown in the image above. The CI version I used for testing was 4.1.3.
Now, let's upload the downloaded project files to Apache2.
For testing purposes, I renamed the project to 'ci4' and uploaded it. To check if it's working properly, I accessed localhost (or the address)/public/index.php.
I was greeted with an error screen right away.
This is where the real struggle began. In my case, it was an error indicating that folder permissions and PHP extensions were not set up correctly. First, I changed the permissions of the '/writable' folder within the project files.
sudo chmod -R 777 writable
Second, I needed to install the required PHP extensions. The essential extensions are curl, intl, mbstring, and xml – four in total. They might already be installed on servers that are already in operation, but since I was setting up a new server, I had to install them one by one.
sudo apt-get install php-curl
sudo apt-get install php-intl
sudo apt-get install php-mbstring
sudo apt-get install php-xml
I executed each of these commands to install the necessary extensions.
Finally, I needed to uncomment the curl and intl extensions in the php.ini file.
sudo nano /etc/php/7.4/apache2/php.ini
The location of the php.ini file can vary depending on the server environment. I executed the command above to access the php.ini file in edit mode.
;extension=bz2
extension=curl
;extension=ffi
;extension=ftp
;extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
extension=intl
;extension=imap
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
As I scrolled down the php.ini file, I found the sections shown above. I removed the semicolon (;) from the beginning of the curl and intl lines, pressed Ctrl + X to save, and exited.
After making all the changes, I restarted Apache.
sudo service apache2 restart
When I accessed the URL again, I saw the initial CI4 screen displayed correctly.
Looking back, it might seem like a trivial matter, but setting up the development server for the first time took a considerable amount of time due to Google searches and troubleshooting.
Since I've mainly worked on server management (SM) for operational servers, I haven't had many opportunities to set up development servers myself. However, doing it this time was a challenging but rewarding experience that offered a valuable learning opportunity.
Comments0