abydahana / aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based) just by writing single controller. Yet it's reusable, scalable and ready to use!
https://www.aksaracms.com
MIT License
107 stars 47 forks source link

Public folder visible on the URL #582

Closed FlavioSuarez closed 1 month ago

FlavioSuarez commented 1 month ago

Hi,

Started 2 fresh installs of Aksara 5.1.6 version (one in basic mode and other in developer mode) with the current CI version (4.5.5). In both installs the /public/ folder appears on the URL. Changing the 'ENVIRONMENT' setting has no effect.

I have a 5.1.1 version installed (with the 'ENVIRONMENT' setted to 'development') with CI 4.5.3 and the '/public/' folder don't appears on the URL...

Am I missing something?

TIA and keep the good work!!

abydahana commented 1 month ago

You need to point your sub/domain to /path/to/aksaracms/public directly or follow this step instead: https://github.com/abydahana/aksara/discussions/439

FlavioSuarez commented 1 month ago

Hi,

I'm in my local machine using Laragon (same as XAMPP) as development environment. The same Laragon on wich I run the older version working ok... The CI's BaseURL config seems ok: "http://aksara-main.test/public/" The routes seems ok, too. So, it seems it's nothing related with your advices...

I did a fresh install of the 5.1.1 released version here at home (wich Composer downloaded the current CI 4.5.5) and the "/public/" appears on the URL too. As I said, the ok version (at work) runs on CI 4.5.3. Could be the CI version the reason of different behavior? I'll do more tests on monday at work...

Ah, I forgot to mention the error I get on the console: "Unchecked runtime.lastError: The message port closed before a response was received."... The message link's text is "aksara-main.test/:1" but points to "http://aksara-main.test/public/"

TIA. Best regards.

mdestafadilah commented 1 month ago

Hi,

Started 2 fresh installs of Aksara 5.1.6 version (one in basic mode and other in developer mode) with the current CI version (4.5.5). In both installs the /public/ folder appears on the URL. Changing the 'ENVIRONMENT' setting has no effect.

I have a 5.1.1 version installed (with the 'ENVIRONMENT' setted to 'development') with CI 4.5.3 and the '/public/' folder don't appears on the URL...

Am I missing something?

TIA and keep the good work!!

what's your server using? nginx, apacher, litespeed or others?

abydahana commented 1 month ago

I tested both Apache and Nginx

FlavioSuarez commented 1 month ago

Apache 2.4.59-win64-VS17 PHP 8.3.8-x64 [TS] MySQL 8.4.0

I did a fresh install of 5.1.1 release, developer mode (without sample) and CI 4.5.5, here at work and the /public/ folder appears on the URL too... I downloaded the 5.1.1 release, unziped it into an empty folder and ran composer install wich downloaded CI 4.5.5. When I open the new site and start the install process, the /public/ folder already appears.

The ok 5.1.1 (on CI 4.5.3) version was formerly a 5.0.6 version wich was updated to 5.1.0 and after to 5.1.1, by copying the new released files over the priors. Also, the app Description don't appears on the footer of the ok version, while it does on the NOT OK version...

Later I'll try to do a fresh install forcing the CI 4.5.3 and see what happens... [ADD] Same result with /public/ folder in the URL... :-(

[ADD] The config.php files are equal (besides the ENCRYPTION_KEY, COOKIE_NAME and DB_DATABASE values)...

FlavioSuarez commented 1 month ago

More info:

On the CI's debugbar, I can see that BaseURL is setted to "http://aksara-main.test/public/" instead of "http://aksara-main.test". Couldn't find where this '/public/' is appended to the $baseURL...

abydahana commented 1 month ago

More info:

On the CI's debugbar, I can see that BaseURL is setted to "http://aksara-main.test/public/" instead of "http://aksara-main.test". Couldn't find where this '/public/' is appended to the $baseURL...

Could you please share your virtual host config?

FlavioSuarez commented 1 month ago

This is the content created by Laragon on the hosts file:

127.0.0.1 aksara-511.test #laragon magic!
127.0.0.1 aksara-main.test #laragon magic!
127.0.0.1 aksaracms.test #laragon magic!

mdestafadilah commented 1 month ago

This is the content created by Laragon on the hosts file:

127.0.0.1 aksara-511.test #laragon magic! 127.0.0.1 aksara-main.test #laragon magic! 127.0.0.1 aksaracms.test #laragon magic!

i'm using laragon too, but not try on localhost, may you can use this

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ahntest.net
    DocumentRoot /home/www/ahntest.net

    Alias /testberg /home/www/testberg
    <Directory "/home/www/testberg">
        Options +Indexes
        AllowOverride All
    </Directory>
</VirtualHost>

// source: https://serverfault.com/a/347549

hope this help you little.

abydahana commented 1 month ago

This is the content created by Laragon on the hosts file: 127.0.0.1 aksara-511.test #laragon magic! 127.0.0.1 aksara-main.test #laragon magic! 127.0.0.1 aksaracms.test #laragon magic!

i'm using laragon too, but not try on localhost, may you can use this

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ahntest.net
    DocumentRoot /home/www/ahntest.net

    Alias /testberg /home/www/testberg
    <Directory "/home/www/testberg">
        Options +Indexes
        AllowOverride All
    </Directory>
</VirtualHost>

// source: https://serverfault.com/a/347549

hope this help you little.

Hi, please check the virtual host config under your nginx and make sure the "root" parameter is pointed to /public directly:

image

The final config should be like this:

server {
    listen 80;
    server_name aksara-main.test *.aksara-main.test;
    root "/path/to/aksaracms/public"; # LOOK AT THIS

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        autoindex on;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php_upstream;      
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

# This file is auto-generated.
# If you want Laragon to respect your changes, just remove the [auto.] prefix
# If you want to use SSL, enable it at: Menu > Nginx > SSL > Enabled
FlavioSuarez commented 1 month ago

Hi,

I don't use Nginx at all. Never used. Laragon settings are: Document root folder: "C:\laragon6\www" Auto-create Virtual Hosts: TRUE Hostname template: "{name}.test"

Laragon has worked with this settings since always. Other CodeIgniter projects had always worked with these settings, as does the aksara 5.0.6 updated to 5.1.1 In the .env file I always use something like app.baseURL = 'http://aksara-main.test/' Never had to put the "/public/" in the baseURL setting...

I have this issue just now with a fresh install of aksara...

abydahana commented 1 month ago

Laragon is using Nginx by default. You can check the screenshot on my previous reply just to make sure the virtual host are created correctly.

I tested with Laragon also and had no issue.

And there's no .env required in Aksara's project, so I wonder why you put .env in yours 😁

FlavioSuarez commented 1 month ago

You're using Laragon 5.0.0. Mine is 6.0.0. Nginx is disabled in my Preferences. I use only Apache. Ever. I know that Aksara don't needs the .env file. I use it on others CI projects, setting the BaseURL as I said and database credentials. Opening the CI's DebugBar I can see that the BaseURL is setted without the '/public/' on the updated Aksara 5.1.1. But on the fresh installs the BaseURL is setted with the '/public/'. The defined BASE_URL on the config.php seems ok. So, somewhere, sometime, the public $baseURL variable is getting the '/public/' added to the end of the URL..

Captura de tela 2024-10-01 123002

Captura de tela 2024-10-01 122802

Captura de tela 2024-10-01 123210

Thanks for your time with this issue... Hope we can find the answer to this mistery... :-)

mdestafadilah commented 1 month ago

Laragon is using Nginx by default. You can check the screenshot on my previous reply just to make sure the virtual host are created correctly.

I tested with Laragon also and had no issue.

And there's no .env required in Aksara's project, so I wonder why you put .env in yours 😁

Sir, we can choose nginx or apache as webservice ... 02-10-2024 08-44-10

but this is very mistery ... can you downgrade your laragon version sir @FlavioSuarez only for testing...

i'm using laragon 4 but with apache and php newest.

FlavioSuarez commented 1 month ago

Bingo!!! Found it!!! Now I see what you both mean with

Could you please share your virtual host config?

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ahntest.net
    DocumentRoot /home/www/ahntest.net

    Alias /testberg /home/www/testberg
    <Directory "/home/www/testberg">
        Options +Indexes
        AllowOverride All
    </Directory>
</VirtualHost>

I was looking for in the "hosts" file. But right now I had an insight and found these settings on the Apache > sites-enabled > *.conf files On the working site, the "DocumentRoot" and "Directory" have "/public" on the path. On the NOT working site, they doesn't.

Then the 2nd insight was: The ok site was created by running a Composer installation, while in the not-ok sites I did a manual installation. In the manual installation I first created a blank project on Laragon by going to Quick App > Blank (wich created the folder, the database and the .conf file without the "/public" on the "DocumentRoot" and "Directory" settings) and then I did the manual installation into this folder. Tested right now doing a Composer installation and all seems ok again!!

Thank you so much for your help, guys!! Re-starting my testing project from zero... Keep the good work! This project is really awesome!

image

image

abydahana commented 1 month ago

Great to know. Now it's clear that the main cause is the virtual host did not created a config like expected.

FlavioSuarez commented 1 month ago

Yes. The Laragon's Quick App > Blank don't know if has to add "/public" at the end... So, the best advice is to allways use the Composer Installation when using Laragon...