Welcome Guest, Not a member yet? Register   Sign In
Ci4 Install without vhosts
#1

Hi,

I have been experiencing a number of problems with Ci4 on my local machine, so to eliiminate errors that may caused by my local environment I decided to install Ci4 on my hosted server.

However, I cannot configure a virtual host in apache on the server.

Is there an alternative?

Of course I can access the site via http://mydomain/public/   and set app/$baseURL = 'http://mydomain/public/';   But, accoring to the documentation this defeats the objective.
Reply
#2

Shared hosting providers can use one of several different setups. What you do depends on what the provider's setup allows. It comes down to whether they allow you to upload to the same level as where they have put the folder that mydomain.com is served from.

Let's say mydomain.com is served out of a folder at /some/path/to/public_html/ and that last folder (public_html) is where they say you should, "put your website files here."  The public_html folder might have some other name, but for this explanation we will use public_html as a placeholder for whatever the provider used. Typically, but not always, that folder won't have anything in it you really need and can be deleted. But unless it is empty do not do that just yet. Instead, change the name to public_html_bak. Then install (or upload) CodeIgniter at /some/path/to/.  Then change the name of the folder public that CodeIgnier created to public_html.

In \Config\App

PHP Code:
$baseURL 'https://mydomain.com'

(You really, really, really need to install security certificates and use SSL, e.g. https, if you're on a live server.)

If the provider does not allow you to install in the same folder where they put public_html you will have to use "Option B". Let me know if you need Option B along with what, if any other folders they provide at the /some/path/to/ level.
Reply
#3

Thank you dave friend,

I spent over an hour with the hosting companies support yesterday trying to find a solution (they are very helpful) and renaming public_html to public was one of the sugestion I made.

The outcome of our conversation was:
Virtual host is not allowed (probably something to do with shared server)
public_html cannot be renamed
configuring redirect in .htaccess exposes public foledr and causes other CI config issues
moving current .htaccess and index.php to public_html causes other CI config issues

any plan B would really be appreciated.
Reply
#4

(This post was last modified: 06-14-2020, 06:44 AM by dave friend.)

(06-14-2020, 04:47 AM)68thorby68 Wrote: I have been experiencing a number of problems with Ci4 on my local machine,

I'm curious. What kind of problems?

Have you considered using a virtual machine (VM) instead of exposing a work in progress to the whole wide world? You can set up the VM to exactly match the OS and app stack your eventual hosting provider uses. There are several free VMs available such as VirtualBox and VMware Workstation Player.

It is another layer of complexity to deal with but once you figure it out it's pretty slick.

(06-14-2020, 06:31 AM)68thorby68 Wrote: Thank you dave friend,

I spent over an hour with the hosting companies support yesterday trying to find a solution (they are very helpful) and renaming public_html to public was one of the sugestion I made.

The outcome of our conversation was:
Virtual host is not allowed (probably something to do with shared server)
public_html cannot be renamed
configuring redirect in .htaccess exposes public foledr and causes other CI config issues
moving current .htaccess and index.php to public_html causes other CI config issues

any plan B would really be appreciated.

Virtual host is not allowed because that is how they create your space on the shared server. A VHost cannot "host" another VHost.

I suspect that when the provider said "public_html cannot be renamed" they meant, "the website files must be in a folder named public_html".
Please read my solution again. You change the name of CI's "public" to "public_html". To do that you must first rename the original "public_html" to something else.

How can you put files on the shared server? FTP? Or must you use Control Panel?

Can you put files and/or folders at the same level as "public_html"?
Reply
#5

If it's a Cpanel based host provider, you can find instructions here:
https://forum.codeigniter.com/thread-759...#pid373901

And it will be same for other panels too, as long as you can access one level above public_html.
Reply
#6

(This post was last modified: 06-14-2020, 07:30 AM by 68thorby68.)

Thanks, that is certainly an option I will look at.

But for the time being I have done as suggested, and in case anyone else needs this I'll put it in long hand.

I manually installed CI4 in the server root (i.e. using FTP copied all unzipped files to server root).
Renamed server foler \public_html to \public_html_bak
Renamed the newly created \public to \public_html
in \app\config\App.php edited $baseURL = 'https://mydomain/';

I then uploaded (FTP) the controllers, models and views from my local machine to the appropriate server folder (\app\Controllers\, \app\models\, \app\views\).

As I use bootstrap 4 and a local copy of fontawesome I found that on my local machine the best place to house these is in a subfolder of public, assets. So I uploaded (FTP) the assets folder to \public_html\assets\

I configured my database \app\config\Databases.php

and tested.

in browser https://mydomain.co.uk displays the welcome page (as expected)
in browser https://mydomain.co.uk/user/login displays the expected login page (derived from \app\controllers\user\login,php, \app\models\user\login.php and \app\views\user\login.php) formatted and styled with the expected css and fontawesome derived from \public_html\assets\...

As of yet, I have not executed any fancy routing, redirects or invoked any session mgmnt but am hopeful I wont run into any issues with this install.

Thank you so much for your help and assiatance.

Could I also suggest that you suggeted set up this is added to the documentation?

"Where the option of setting up a virtual host is not an option (i.e. some shared hosting), Shared hosting providers can use one of several different setups. What you do depends on what the provider's setup allows. It comes down to whether they allow you to upload to the same level as where they have put the folder that mydomain.com is served from.

Let's say mydomain.com is served out of a folder at /some/path/to/public_html/ and that last folder (public_html) is where they say you should, "put your website files here." The public_html folder might have some other name, but for this explanation we will use public_html as a placeholder for whatever the provider used. Typically, but not always, that folder won't have anything in it you really need and can be deleted. But unless it is empty do not do that just yet. Instead, change the name to public_html_bak. Then install (or upload) CodeIgniter at /some/path/to/. Then change the name of the folder public that CodeIgnier created to public_html.

In \Config\App

PHP Code:
$baseURL = 'https://mydomain.com';

You may also want to consider using a virtual machine (VM) instead of exposing a work in progress to the whole wide world? You can set up the VM to exactly match the OS and app stack your eventual hosting provider uses. There are several free VMs available such as VirtualBox and VMware Workstation Player."

Currently the documentation reads:
"Manual Installation

The CodeIgniter 4 framework repository holds the released versions of the framework. It is intended for developers who do not wish to use Composer.

Develop your app inside the app folder, and the public folder will be your public-facing document root. Do not change anything inside the system folder!

Note: This is the installation technique closest to that described for CodeIgniter 3.
Installation

Download the latest version, and extract it to become your project root.
Setting Up

None"

Just a thought.

Again many thanks for your help.
Reply
#7

If everything is under public_html which my server is all you need to do is
is rename CodeIgniters 4 public folder to public_html and ftp all files
to the root above public_html.
What did you Try? What did you Get? What did you Expect?

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

@68thorby68 I tried, but it didn't get approved. See: https://github.com/codeigniter4/CodeIgniter4/pull/2768
Reply
#9

Thanks jreklund. There is so, so much lacking in the documentation, especially for newbies like me (I dont come from Ci2 or Ci3).

For example prepared queries DO NOT WORK and report errors when following the documentation to the letter (https://forum.codeigniter.com/showthread.php?tid=76743). Is this error expected? Is this a "real error"? is it a notice? Extending the documentation would do the product untold good.

This is NOT a good look for what is essentially a new product and I for one am losing patience with not being able to follow the published documents, and execute Ci code. To be honest the time I've wasted would probably have been better spent learning the complexities of Laraval or Symfony. Anyway, rant over, many thanks.
Reply
#10

(This post was last modified: 06-15-2020, 12:45 PM by jreklund.)

You don't have mysqlnd driver installed.
https://www.php.net/manual/en/mysqli-stm...lt-mysqlnd

Requirements:
https://codeigniter.com/user_guide/intro...ments.html

Did you see that I asked you to turn on private messages? You have them blocked.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB