Welcome Guest, Not a member yet? Register   Sign In
Starter questions
#1

(This post was last modified: 11-21-2024, 10:36 AM by 4usol.)

Hello,

I have now uploaded Codeigniter to the “httpdocs” folder on my web hosting for the first time.
In the browser I now see mydomain.de/public, the welcome page.

Now when I change the web hosting settings for the domain root to “httpdocs/public” I get this error

“Warning: require(): open_basedir restriction in effect. File(/var/www/vhosts/mydomain/subdomain/httpdocs/app/Config/Paths.php) is not within the allowed paths:"

What is the best way to solve this problem to get Codeigniter directly under the domain root without the "public" folder?


By the way, a second question. Is there a standard package that includes user registration for example?


Thanks!
Reply
#2

CodeIgniter 4 Shield Auth

Shield Documentation
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 11-22-2024, 02:33 AM by captain-sensible. Edit Reason: more )

it looks like your app folder is  basically accessible to public ; the only  part of  CI4 that should be accessible  to the public ,is the contents  of your public Ci4 folder. The rest should be at a level above  that. 

So if you have one site;the inside contents of public directory , should be in your hosting space; in another directory one level  above hosting, that directory will contain everything else and you state that in  the index.php file which will be at document route of your web hosting  :
Code:
// LOAD OUR PATHS CONFIG FILE
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
//if you packed Vendor, Writable, App into Joedoe.com directory 1 level up then path should be
//  ../Joedoe.com/app/Config/Paths.php
// ^^^ Change this line if you move your application folder
Now i use normal full domains such as  Joedoe.com  , but  each web is in a  sub-directory  inside main hosting space. So i would have a directory inside main web hosting called :
Joedoe.com.Then via cPanel  and  menu for hosting, where it says "manage domains " i add the domain "Joedoe.com . I go to cPanel and fiiddle with "add domains" and "sub domains" i edit  path to document route of  web in sub directory to point  to the  public directory inside the Joejoe.com directory, which itselrf is inside main hosting>There is no need to touch .htaccess or anything else.
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#4

(This post was last modified: 11-22-2024, 11:42 PM by 4usol.)

Great, i solved the domain problem. Now i see the welcomepage directly under the domainname. All files/foldes now in the "httpdocs" but the domain point to "public", is it correct?

1) So i edit the app>config>database file. Is there a way to test the database connection?

After that, i tried to setup the shield packages. I'm not firm with composer so i try to do it manually.

2) What will be the url to access the login page, i cannot find them? If i try to access "mydomain.tld/login" i get the message "No input file specified.".
Update: i edit the htaccess file in the public folder like in the docu. Now i recieved "Can't find a route for 'GET: login'." if it enter mydomain.tld/login
Also i don't understand the point in the documentation under "manual setup"-what i have to change in wich folder and files?

Sorry to have so simple basic "newbie"-questions :-)
Reply
#5

(This post was last modified: 11-23-2024, 02:31 AM by captain-sensible. Edit Reason: as once jimminy cricket said - wait theres more )

if you have a web with for example the sort of structure [Image: webstructure.png]

Then in my cPanel i set the "document root" as subdomainDirectoryName/public.

If you only have only one web , the inside contents of Ci4/public folder , without the directory will be inside your main web hosting , whic hwill be something like http . So there shouldn't be any directory called "public" in that case
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#6

(11-23-2024, 02:29 AM)captain-sensible Wrote: if you have a web with for example the sort of structure [Image: webstructure.png]
Very helpful image. My situation is the red circle, there i have all folders including the "public" folder and this i defined as the root folder for the domain, i think it should be right.

May you can help on the other questions, too?
Reply
#7

(11-21-2024, 10:35 AM)4usol Wrote: Hello,

I have now uploaded Codeigniter to the “httpdocs” folder on my web hosting for the first time.
In the browser I now see mydomain.de/public, the welcome page.

Now when I change the web hosting settings for the domain root to “httpdocs/public” I get this error

“Warning: require(): open_basedir restriction in effect. File(/var/www/vhosts/mydomain/subdomain/httpdocs/app/Config/Paths.php) is not within the allowed paths:"

What is the best way to solve this problem to get Codeigniter directly under the domain root without the "public" folder?


By the way, a second question. Is there a standard package that includes user registration for example?


Thanks!
For Your First Question:
The error you’re seeing, “open_basedir restriction in effect”, typically happens because your hosting provider has restricted access to certain directories outside of the allowed paths. Here’s how you can solve it:
  1. Adjust the Server Settings:
    If you have access to your hosting control panel (like cPanel or Plesk), check the PHP settings for
    Code:
    open_basedir
    and add your application paths to the allowed list. If you don’t have access, you may need to contact your hosting provider to request this change.
  2. Move Public Folder Files:
    Another way to solve this is to move the contents of the
    Code:
    public
    folder to the root directory (
    Code:
    httpdocs
    ). Be careful when doing this, and remember to:
    • Update
      Code:
      index.php
      to point to the correct paths for
      Code:
      Paths.php
      .
      php
      Copy code
      Code:
      $pathsPath = '../app/Config/Paths.php';
    • Ensure your
      Code:
      .htaccess
      file is updated and configured properly for the new structure.
  3. Alternative Configuration:
    Some hosting providers allow you to set a subdirectory (like
    Code:
    httpdocs/public
    ) as the domain root. This can work, but the open_basedir issue would still need to be addressed.
For Your Second Question:
Yes, there are starter packages and libraries for CodeIgniter that include features like user registration. You can check out:
  • CodeIgniter Shield: A comprehensive authentication and authorization library for CodeIgniter 4.
  • Community Add-ons: You’ll find plenty of third-party libraries or example repositories on GitHub with user authentication setups.
Why Cloudways Could Be a Great Fit
If you're experiencing configuration headaches with your current host, a managed hosting provider like Cloudways might save you time and effort. They offer dedicated environments optimized for PHP frameworks like CodeIgniter, and you won't have to deal with open_basedir restrictions since the platform is designed for flexibility.
  • One-Click Deployment: Install CodeIgniter and other PHP apps easily without dealing with complicated server configurations.
  • Performance-First Hosting: Built on top-tier providers like AWS and Google Cloud.
  • Security Built-In: Features like firewalls, Cloudflare CDN integration, and automatic backups keep your site safe.
Cloudways BFCM 2024 Deal
If you're considering trying a new host, now’s a great time:
  • 40% off for 4 months with the code BFCM2024.
  • 40 free migrations to help you switch without hassle.
  • Offer valid from November 7th to December 5th, 2024.
Alternatives to Explore
If you’re still exploring hosting options, you could also consider:
  • Hostinger: Affordable and beginner-friendly.
  • SiteGround: Great for managed hosting and support.
  • Namecheap: Budget-friendly with decent performance.
Let me know if you need more specific help with the configuration!
Reply
#8

(This post was last modified: 11-26-2024, 03:37 AM by captain-sensible. Edit Reason: the usual reasons )

with number 2) above by @UmairHussain  then as he says, you want "the contents of the directory public"  only (without the  directory  itself) . So from a command line  if your on linux , you will change directory to inside of public eg

Code:
[andrew@darkstar public]$ cd ~
[andrew@darkstar ~]$ cd /srv/http/CI4-CMS/public
[andrew@darkstar public]$ zip -r  namezipfile.zip    .

Note the trailing  "."  end of last line. If you then upload , namezipfile.zip to the document root of your main hosting and extract, you will  have  the contents of public including the .htaccess file. What happends if your not careful is that you get  the  contents of public, with the directory called "public" to root of hosting which you dont want.

if you have any trouble with the .htaccess  then you can rename to  htaccess , so you can easily see it, and just rename the file back to .htaccess using cPanel
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB