CodeIgniter Forums
set the "document root" to the public folder inside your project - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: set the "document root" to the public folder inside your project (/showthread.php?tid=68469)

Pages: 1 2


set the "document root" to the public folder inside your project - Edel - 07-13-2017

HI, first sorry my english, it's not the best. I am new in CI 4, although I have experience en CI 3. MY problem is quite comented in other post.
I copied the CI 4 code in my web server , the same directory when I have a project with CI 3. The name of the folder that contains the CI 4 code es CI4, so http://localhost/CI4 should be the way to access to the welcome message. But the CI return
"If you see this message, you have not configured your web server properly.
You need to set your "document root" to the code public folder inside your project. This could be your default setting, or that of a virtual host, depending on how you set up your local development environment.".
I set
Code:
public $baseURL = 'http://localhost/CI4/public';

in application/config/app.php.
In other post I read set it to
Code:
'http://localhost/CI4

only but the problems persits in both case.
What the problem? What can I do?
Thanks


RE: set the "document root" to the public folder inside your project - ciadmin - 07-13-2017

Setting your document root refers to web server configuration, eg setting the DocumentRoot inside Apache or your virtual host setting. If Apache's document root is "/projectroot/public", then your $baseURL will be "http://localhost" or the virtual host domain that you have setup.

If you need "public" inside your baseURL or as part of the location field inside your browser, then you haven't setup the server properly.

See https://bcit-ci.github.io/CodeIgniter4/concepts/structure.html#public


RE: set the "document root" to the public folder inside your project - kilishan - 07-13-2017

If you don't want to muck around with your web server settings, you can use the built-in PHP server but dropping to the command line and running:

Code:
> php serve.php

This will start up the local server which you can access at http://localhost:8080, and will handle basic URL rewriting so that things behave as you would expect them to under Apache or nginx.


RE: set the "document root" to the public folder inside your project - Edel - 07-13-2017

Thanks for yours answers.
ciadmin: I created a virtual host. so I can access  my application through http://code
I changed the name of the folder to code instead of CI4.
But returns the error message ( see image)

I downloaded twice the code from official website of Codeigniter 4 an the error is the same.
what can I do?
thanks again.


RE: set the "document root" to the public folder inside your project - InsiteFX - 07-14-2017

I use phpStorm and I also have to add a mapping in phpStorm to my public_html folder after that everything works fine.


RE: set the "document root" to the public folder inside your project - Edel - 07-14-2017

If in system/CodeIgniter.php , I delete line 38
Code:
use Config\Services;

the problem disappears( returns the welcome message), but I dont' know why and its consequences.


RE: set the "document root" to the public folder inside your project - kilishan - 07-14-2017

Edel what type of server setup are you using locally and what OS are you running on? There's another report at GitHub about this happening on a WAMP setup. I know we're not seeing that on Mac or Linux, though.


RE: set the "document root" to the public folder inside your project - Edel - 07-14-2017

kilishan I am using wamp server version 3.0.6, which use php 7.0.10 and apache 2.4.23.  My OS is Windows 7 64 bits.


RE: set the "document root" to the public folder inside your project - InsiteFX - 07-15-2017

@killshen, If I remember right I read someplace that people were running the 32-bit version of wamp because they were having problems with the 64-bit version.


RE: set the "document root" to the public folder inside your project - John_Betong - 07-15-2017

(07-14-2017, 09:41 AM)Edel Wrote: If in system/CodeIgniter.php , I delete line 38
Code:
use Config\Services;

the problem disappears( returns the welcome message), but I dont' know why and its consequences.

I run Linux and have successfully installed CodeIgniter several times.

I found the installation instructions slightly confusing because Ubuntu Apache2 does not have a /public/ folder. Instead it has a /public_html/ folder where index.php should be copied and modified. The modifications are to set the paths to the Application and System folders.

The index.php can be tested by echo __FILE__; die; at the top of the index.php file. This should display the full path when http://localhost/ is called from the browser command line.

I copy the Application folder above the Root (where the index.php file resides) and the System folder into an even higher, common, CI2 folder (could even be on another drive). This makes it easily available to other CodeIgniter installations on the same drive. The System folder contents should never be altered.

The identical structure can be uploaded to the server and does not require any changes apart from the .htaccess file for pretty URLs, file type optimisatiion, caching, etc.