This article will actually demonstrate on how to access a web-based application. That web-based application is actually using Code Igniter 4 as its framework. The service itself is available by running a command in the command line. Furthermore, it exist in a virtual server of a VirtualBox application. So, after running the virtual server, access the command line, just install and create the web-based application using Code Igniter 4. Following after, just run it. But before it is possible for accesss from host machine, there are several additional step.
Step for Accessing Web-based Application using Code Igniter 4
So, in order to achieve the purpose, just perform the following steps to achieve it :
Just access the VirtualBox application. Start the virtual server where the web-based application will start as the service. The image of the VirtualBox application exist as follow :
After successfully start the virtual server, just access it. Either directly access or just remotely access. For an example, accessing using SSH protocol. Read the article with the title of ‘How to Remote CentOS Virtual Server running in a VirtualBox with a NAT Network using SSH’ in this link to get reference on accessing virtual server remotely.
Access the command line interface of the virtual server. Do not forget to go to the root folder of the web-based application which is using Code Igniter 4 framework. In order to create and install web-based application using Code Igniter 4 framework, just read it in another article. The article has a title of ‘How to Create and Install Code Igniter 4 Web Application in Virtual Server running using Linux CentOS 8’ in this link. After that, access the root folder of the web-based application where it exist as follows :
[root@10 codeigniter]# cd app/ [root@10 app]# ls -al total 1424 drwxrwx--- 1 root vboxsf 4096 Mar 24 10:28 . drwxrwx--- 1 root vboxsf 0 Mar 23 23:53 .. drwxrwx--- 1 root vboxsf 4096 Jan 31 21:56 app drwxrwx--- 1 root vboxsf 0 Mar 24 04:00 bootstrap -rwxrwx--- 1 root vboxsf 1309428 Mar 24 03:58 bootstrap.zip -rwxrwx--- 1 root vboxsf 3760 Jan 31 21:56 builds -rwxrwx--- 1 root vboxsf 858 Jan 31 21:56 composer.json -rwxrwx--- 1 root vboxsf 91159 Mar 23 23:53 composer.lock -rwxrwx--- 1 root vboxsf 4181 Mar 24 10:28 .env -rwxrwx--- 1 root vboxsf 1860 Jan 31 21:56 .gitignore -rwxrwx--- 1 root vboxsf 1159 Jan 31 21:56 LICENSE -rwxrwx--- 1 root vboxsf 2091 Jan 31 21:56 phpunit.xml.dist drwxrwx--- 1 root vboxsf 4096 Mar 24 11:01 public -rwxrwx--- 1 root vboxsf 2724 Jan 31 21:56 README.md -rwxrwx--- 1 root vboxsf 2236 Jan 31 21:56 spark drwxrwx--- 1 root vboxsf 0 Jan 31 21:56 tests drwxrwx--- 1 root vboxsf 4096 Mar 23 23:54 vendor drwxrwx--- 1 root vboxsf 0 Jan 31 21:56 writable [root@10 app]#
There is a file with the name of ‘spark’. It is a file for running the Code Igniter web-based framework application.
Run the command for activating the service. Just type the following command :
[root@10 app]# php spark serve --host 0.0.0.0 CodeIgniter v4.1.1 Command Line Tool - Server Time: 2021-03-28 02:41:45 UTC-05:00 CodeIgniter development server started on http://0.0.0.0:8080 Press Control-C to stop. [Sun Mar 28 03:41:47 2021] PHP 7.4.16 Development Server (http://0.0.0.0:8080) started
The process is not done yet, there is another step for adding port forwarding rule. Just read the article with the title of ‘How to Add Port Forwarding Rule to access Code Igniter 4 Service of Guest Machine running in VirtualBox Manager from Host Machine’ in this link. It is for adding port forwarding rule so that accessing web-based application is possible from host machine. It is possible using specific port defined as in the port forwarding rule. In the article mentioned before, it is using port 9080 for accessing it.
- Do not forget to add firewall rules in the virtual server. Just add port 8080 so that it is available for further access. Type the following command in the command line of the virtual server :
[root@10 app]# firewall-cmd --add-port=8080/tcp --permanent Success [root@10 app]# firewall-cmd --list-port 22/tcp 80/tcp 3306/tcp 3001/tcp 8000/tcp 8080/tcp [root@10 app]#
After defining the port forwarding rule, just access it from the web browser using the address of ‘localhost:9080’. Accessing using port ‘9080’ is because it is using port ‘9080’ for accessing the web-based application using Code Igniter 4 framework in port 8080 available in the virtual server.The following is the appearance of it :