Welcome Guest, Not a member yet? Register   Sign In
Secure Installation of CI4 on shared hosting
#1

Hey guys,

first of all I would like to point out that I am quite new to Codeigniter in general.

I want to upload the codeigniter 4 framework onto my shared hosting website, in order to build an webapplication based on it.
So far so good, I uploaded everything and it worked out quite well (saw the message, could generate new views, etc.).

My problem is the following:

the directory on my server is: public_html
If I upload the frameworks directory as it is onto that directory, people can access my files like the env file.

I struggle with "hiding" the directories and files right in order to be secure.
I checked the manual for ci4 but it didn't quite help me.

I understand that my public_html needs to be mapped to the "public" folder provided in CI4. But where shall I save the other folders? A directory above?

Sorry if my question seems silly to you, but I can't get that sorted out at the moment.

I am very thankful for any help!

Kind regards,
Paul
Reply
#2

Hi, this part haven't made it into the manual as of yet. So I will just post it here.

Shared Hosting with cPanel

cPanel is a Linux-based web hosting control panel that provides a powerful set of automation tools in an easy and
straightforward interface, allowing a simplified process for hosting websites.

The contents of CodeIgniter's public folder should be placed in your domain's Document Root, in cPanel's case it's
called public_html for your Main Domain. Here is an example of a directory structure that are created by cPanel:


Code:
/bin
/cache
/cpanelbranding
/etc
/logs
/mail
/perl
/php
/public_ftp
/public_html
/ssl
/tmp
/var


All other Default Directories should be placed in your Home Directory /home/username/ referred to as / above. But this will just turn into a mess as it's difficult to see what folder/files belong to cPanel and/or CodeIgniter.

Therefor it's recommended to create another folder named after your domain name in your home directory,
and place all other folders and files (refer to ... below) in it. This makes the final structure look like this:


Code:
/example.com
        /app
        /system
        /writable
        /tests
        ...
/public_html
        robots.txt
        index.php
        favicon.ico
        .htaccess


Since we changed the directory structure we have to tell CodeIgniter about it. Open /public_html/index.php
in a text editor and change the following line to match your domain name directory that we previously created.

PHP Code:
$pathsPath FCPATH '../example.com/app/Config/Paths.php'
Reply
#3

Hey,

thank you so much for your quick answer!

You really helped me out with that one and solved my question / problem.

Have a nice evening and kind regards,

Paul Smile
Reply
#4

Thank you! This was useful to me too
Reply




Theme © iAndrew 2016 - Forum software by © MyBB