CodeIgniter Forums
Change localhost:8080 to custom domain CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Change localhost:8080 to custom domain CI4 (/showthread.php?tid=84948)



Change localhost:8080 to custom domain CI4 - refs - 11-27-2022

Hi,

I'm quite new in CI4, but use CI3 for view years.

I saw a video on youtube where someone change app.php to set CI4 custom domain and remove index.php

here's the link
Code:
https://www.youtube.com/watch?v=yoKTE5J5T7g


this is how exactly i want CI4 work in my localhost (I'm using apache2)

but, since i saw documentation of CI4 where i can run

Code:
php spark serve


and my CI4 run when accesed from
Code:
localhost:8080


is there any way to change that
Code:
localhost:8080
to something like
Code:
http://localhost/mypCI4
so i can access my ci project with "php spark serve" but with my custom domain in localhost ?

im trying to add in .env something like
Code:
app.baseURL=http://localhost/mypCI4
but it's not working

Thanks in advance


RE: Change localhost:8080 to custom domain CI4 - kenjis - 11-27-2022

I recommend you set up Apache or something.

There is no way to change the path (`/mypCI4`).


RE: Change localhost:8080 to custom domain CI4 - refs - 11-27-2022

(11-27-2022, 01:17 AM)kenjis Wrote: I recommend you set up Apache or something.

There is no way to change the path (`/mypCI4`).

So, is it mean that CI4 domain will stay like "localhost:8080" if i use php spark serve ?

and it's also mean i can't have multiple project using CI4 in same host ?


RE: Change localhost:8080 to custom domain CI4 - JustJohnQ - 11-27-2022

If you set up Apache (for example WAMP www.wampserver.com) you can add virtual hosts. You can do this by adding a host name to the file hosts (in windows\system32\drivers\etc), for example:
Code:
127.0.0.1 mypCI4.local
Then add a virtual host in httpd-vhosts.conf :

Code:
<VirtualHost *:80>
ServerName mypCI4.local
ServerAlias www.mypCI4.local
DocumentRoot "d:/projects/mypCI4/public"
<Directory  "d:/projects/mypCI4/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
After restarting Apache you should be able to access your CI4 installation on www.mypCI4.local.
See https://noobietech.com/create-a-virtual-host-in-wamp-windows/
You won't be able to use php spark serve this way, but you can setup multiple installations now.


RE: Change localhost:8080 to custom domain CI4 - kenjis - 11-27-2022

(11-27-2022, 02:03 AM)refs Wrote: So, is it mean that CI4 domain will stay like "localhost:8080" if i use php spark serve ?

"php spark serve" is a server for development.
You can change hostname (=localhost) and port number (=8080).
See "php spark help serve"

But there is no way to change the URI path.
And if you change the hostname, the hostname must be resolved.
For example, you need to add it in your hosts file.

(11-27-2022, 02:03 AM)refs Wrote: and it's also mean i can't have multiple project using CI4 in same host ?

If you mean you want to server like:
http://example.com/project1/
http://example.com/project2/
You cannot use "php spark serve" because it cannot set the URI path (/project1/).

But of course you can do it with Apache.


RE: Change localhost:8080 to custom domain CI4 - refs - 11-27-2022

(11-27-2022, 02:25 AM)JustJohnQ Wrote: If you set up Apache (for example WAMP www.wampserver.com) you can add virtual hosts. You can do this by adding a host name to the file hosts (in windows\system32\drivers\etc), for example:
Code:
127.0.0.1 mypCI4.local
Then add a virtual host in httpd-vhosts.conf :

Code:
<VirtualHost *:80>
ServerName mypCI4.local
ServerAlias www.mypCI4.local
DocumentRoot "d:/projects/mypCI4/public"
<Directory  "d:/projects/mypCI4/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
After restarting Apache you should be able to access your CI4 installation on www.mypCI4.local.
See https://noobietech.com/create-a-virtual-host-in-wamp-windows/
You won't be able to use php spark serve this way, but you can setup multiple installations now.

hmm,,interesting, okay, will try it

(11-27-2022, 04:05 AM)kenjis Wrote:
(11-27-2022, 02:03 AM)refs Wrote: So, is it mean that CI4 domain will stay like "localhost:8080" if i use php spark serve ?

"php spark serve" is a server for development.
You can change hostname (=localhost) and port number (=8080).
See "php spark help serve"

But there is no way to change the URI path.
And if you change the hostname, the hostname must be resolved.
For example, you need to add it in your hosts file.

(11-27-2022, 02:03 AM)refs Wrote: and it's also mean i can't have multiple project using CI4 in same host ?

If you mean you want to server like:
http://example.com/project1/
http://example.com/project2/
You cannot use "php spark serve" because it cannot set the URI path (/project1/).

But of course you can do it with Apache.

okay, thanks for the information kenjis


RE: Change localhost:8080 to custom domain CI4 - ikesela - 11-27-2022

suggest using laragon (laragon.org). all out of the box (just make project under www folder, all automatic create domain each , project1.test, project2.test)


RE: Change localhost:8080 to custom domain CI4 - captain-sensible - 11-28-2022

laragon, looks interesting if your on windows. But for the time you invest in it to understand it ; you could put into that time into thinking of looking into using Linux as your OS. The benefit of that is that most web servers were using Linux. (Not sure how cloud factors into this now)

So if you run Linux as your OS , you have as part of the system as web server. You will learn about permissions , chmod and the rest


RE: Change localhost:8080 to custom domain CI4 - superior - 11-30-2022

Previously used MAMP-Pro that allows you to set hostnames from the program itself, you will have all tools at hand, Another solution would be to use Hosts file editor, easy to use and setup without any hassle on different OS. WAMP is another solution that allows you to edit virtual hosts in a simple way if you don't know how to handle this yourself.

Options:

- https://www.mamp.info/en/mamp-pro/windows/
- https://www.wampserver.com/en/
- https://hostsfileeditor.com/