Welcome Guest, Not a member yet? Register   Sign In
Deploying Codeigniter 4 Website on LAN server
#1

I developed Codeigniter 4 website on my laptop running Mint Linux with LAMP.
I have another PC in the home network dedicated as an ubuntu 20.04 LTS server with LAMP installed.
On deploying the Codeigniter 4 website onto the Ubuntu server 20.04 LTS, and calling the ip address of it, i only get "index.php" displayed on the browser
How do i need to configure the Ubuntu server other than using virtual host configurations?
In the Mint Linux laptop, i can configure "httpd.conf" to point to the website, but in the 20.04 server, i only have "apache2.conf", and am not sure if and how to configure
Kindly help
Reply
#2

The most likely reason is that you are missing the .htaccess file.
Reply
#3

(07-29-2021, 05:56 AM)Chroma Wrote: The most likely reason is that you are missing the .htaccess file.
i have added .htaccess

and now i got this message

systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php'; $app = require realpath($bootstrap) ?: $bootstrap; /* *--------------------------------------------------------------- * LAUNCH THE APPLICATION *--------------------------------------------------------------- * Now that everything is setup, it's time to actually fire * up the engines and make this app do its thang. */ $app->run();
Reply
#4

That looks like the end part of the index.php file.

Have you made any changes to the index.php file that would break the PHP? such as a punctuation character?

On my system running 4.1.3, that is part of line 27, so it seems that up until line 27 all was fine, then it had a problem.

Can you check that and if it all looks good, show the full index.php file here.
Reply
#5

from what i understand apache2.conf for ubuntu is the "equivalent" for httpd.conf which i have on Arch and you have on Mint

Also on your ubuntu see if you have this file: /etc/apache2/sites-enabled/000-default.conf


One weird thing with Ubuntu is you have to run : sudo a2ensite <VirtualHostFilename>

Did you have to do that on Mint ?

There are a few tutorials out there for Ubuntu but you should be able to compare apache2.conf settings against httpd.conf settings
since in essence they are the same thing


So you should see something like [in apache2.conf:

Code:
<IfModule dir_module>
    DirectoryIndex index.html index.php
# i added index.php to above
</IfModule>


here i added index.php after index.html
Reply
#6

Have you confirmed if you have properly installed the PHP module in your Apache? This is because instead of parsing the index.php as a PHP file, your server instead parses it as a normal text file resulting in just rendering the contents.

Make sure you have the following similar lines in your apache2.conf
Code:
# Taken from my dev httpd.conf
PHPIniDir "C:/php80"
AddHandler application/x-httpd-php .php
LoadModule php_module "C:/php80/php8apache2_4.dll"
Reply
#7

(This post was last modified: 07-31-2021, 02:09 AM by captain-sensible. Edit Reason: addition )

hes got Linux on both boxes and that looks like your on Windows Paul . but your right I'm on Arch and in httpd.conf

the lines i added were:

Code:
LoadModule rewrite_module modules/mod_rewrite.so
#i uncommnented line above

LoadModule php_module modules/libphp.so
AddHandler php-script .php



Another thing to check is : libapache2-mod-php

you can check that with :
Code:
apt-cache policy libapache2-mod-php
if thats missing and you install it , it has to be enabled:
Code:
sudo a2enmod php



it might be worth you having a look at : https://linuxhint.com/install_apache_web_server_ubuntu/
Reply
#8

(07-30-2021, 02:29 AM)Chroma Wrote: That looks like the end part of the index.php file.

Have you made any changes to the index.php file that would break the PHP? such as a punctuation character?

On my system running 4.1.3, that is part of line 27, so it seems that up until line 27 all was fine, then it had a problem.

Can you check that and if it all looks good, show the full index.php file here.

Hello,

I have checked.

I did make some change but it was on line 20 on "FCPATH......"

and it did work on the development machine, but not on the ubuntu server

here is the index.php
PHP Code:
<?php

// Path to the front controller (this file)
define('FCPATH'__DIR__ DIRECTORY_SEPARATOR);

/*
 *---------------------------------------------------------------
 * BOOTSTRAP THE APPLICATION
 *---------------------------------------------------------------
 * This process sets up the path constants, loads and registers
 * our autoloader, along with Composer's, loads our constants
 * and fires up an environment-specific bootstrapping.
 */

// Ensure the current directory is pointing to the front controller's directory
chdir(__DIR__);

// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
$pathsConfig FCPATH '/codetent/app/Config/Paths.php';
// ^^^ Change this if you move your application folder
require realpath($pathsConfig) ?: $pathsConfig;

$paths = new Config\Paths();

// Location of the framework bootstrap file.
$bootstrap rtrim($paths->systemDirectory'\\/ ') . DIRECTORY_SEPARATOR 'bootstrap.php';
$app      = require realpath($bootstrap) ?: $bootstrap;

/*
 *---------------------------------------------------------------
 * LAUNCH THE APPLICATION
 *---------------------------------------------------------------
 * Now that everything is setup, it's time to actually fire
 * up the engines and make this app do its thang.
 */
$app->run(); 
Reply
#9

(07-31-2021, 02:07 AM)captain-sensible Wrote: hes got Linux on both boxes and that looks like  your on Windows Paul . but your right  I'm on Arch and in httpd.conf

the lines i added were:

Code:
LoadModule rewrite_module modules/mod_rewrite.so
#i uncommnented line above

LoadModule php_module modules/libphp.so
AddHandler php-script .php


Looking into this.



Another  thing to check is : libapache2-mod-php

you can check that with :
Code:
apt-cache policy libapache2-mod-php
if thats missing and you install it , it has to be enabled:
Code:
sudo a2enmod php



it might be worth you having a look at : https://linuxhint.com/install_apache_web_server_ubuntu/
Reply
#10

(07-30-2021, 11:24 AM)paulbalandan Wrote: Have you confirmed if you have properly installed the PHP module in your Apache? This is because instead of parsing the index.php as a PHP file, your server instead parses it as a normal text file resulting in just rendering the contents.

Make sure you have the following similar lines in your apache2.conf
Code:
# Taken from my dev httpd.conf
PHPIniDir "C:/php80"
AddHandler application/x-httpd-php .php
LoadModule php_module "C:/php80/php8apache2_4.dll"

@ paulbalandan will check on apache2.conf
Reply




Theme © iAndrew 2016 - Forum software by © MyBB