Go Down

Topic: uhttpd config, index file, php vs. html (Read 12879 times) previous topic - next topic

5a2v0

Hi, in my Yun I installed PHP and it work fine..
Now I have a question:

If I put in the /www dir a index.php file and then go to http://my.yun.ip , the webserver redirects me to: http://my.yun.ipcgi-bin/luci/webpanel/homepage because in the /www dir there is a index.html file that does the redirect ..

How can I set index.php priority instead of html files ?

I tried to set in the /etc/config/uhttpd file the "option index_page" or "option index_file" as described here: http://wiki.openwrt.org/doc/uci/uhttpd.
After saving changes, i always did a utttpd restart but no one solution worked...

sonnyyu

#1
May 23, 2014, 02:53 pm Last Edit: May 23, 2014, 04:38 pm by sonnyyu Reason: 1
The output of

Code: [Select]
uci show uhttpd

if you are missing:

Code: [Select]
uhttpd.main.index_page=index.php

then need run:

Code: [Select]
uci set uhttpd.main.index_page=index.php
uci commit
/etc/init.d/uhttpd restart


empty cache of browser, at chrome clean the History, restart browser and visit http://ip_address_yun/.

5a2v0

thanks for the reply... the command
Quote
uci show uhttpd
didn't display the index_page=index.php...
I tried again to add the line:

Code: [Select]
option index_page       index.php

to the config and restarted it....now it works... (maybe before i did some mistake!)

now the command output is:
Code: [Select]
uhttpd.main.index_page=index.php

5a2v0

Hi, another time here because my old problem become my new problem...the situation:


/www folder is like original, with the index.html that works properly with the yun control page (I can connect using http://yun.ip/)

/www/keystore_manager_example/ have a index.html that doesn't work (I can't connect using http://yun.ip/keystore_manager_example but I can by adding /index.html)

/www/sd/ have a index.php that works properly (I can connect using http://yun.ip/sd/)


the uhttpd config:

Code: [Select]

        # Index file to use for directories, e.g. add index.php when using php
        list index_page         'index.html'
        list index_page         'index.php'


the command uci show uhttpd tells me:

Code: [Select]
uhttpd.main.index_page=index.html index.php

Why the index.html in the dir keystore_manager_example doesn't work ?

federicofissore

index_page is not a "list" option, so you can set only one. Easy trick is to always use index.html and it redirect to index.php when appropriate

federicofissore

No, I've played and googled around a bit, but seems like both index_file and index_page do not work as lists, so you can only specify one

federicofissore

#6
Oct 29, 2014, 01:26 pm Last Edit: Oct 29, 2014, 01:27 pm by Federico Fissore
OK I was able to achieve it by manually editing /etc/config/uhttpd, adding
Code: [Select]

list index_page index.htm index.html index.php

Notice the absence of both quotes and double quotes

However, this makes uci break with
Code: [Select]

uci: Parse error (too many arguments) at line 15, byte 37


so think twice about using it: it looks like uhttpd supports something uci doesn't :)

5a2v0

From here: link

I read:
Code: [Select]
index_file file name no index.html, index.htm, default.html, default.htm Index file to use for directories, e.g. add index.php when using php
index_page file name no index.html Index file to use for directories, e.g. add index.php when using php (last, 20131015, replace index_file ?) should be noted: list index_page "index.html"


and if I put in my config file:

Code: [Select]
        # Index file to use for directories, e.g. add index.php when using php
        option index_page         'index.html'
        option index_page         'index.php'


the command uci show uhttpd tells me:

Code: [Select]
uhttpd.main.index_page=index.html index.php

infact i have a index.php in /sd that works! and the index.html in the /www that works also...the only one that doesn't work is the index.html in the /keystore_manager_example dir

sonnyyu

#8
Oct 29, 2014, 06:51 pm Last Edit: Oct 29, 2014, 06:53 pm by sonnyyu
To support both index.html and index.php same time:

Code: [Select]
uci set uhttpd.main.index_page='index.php index.html'
uci commit
/etc/init.d/uhttpd restart


Code: [Select]
uci show uhttpd
...
uhttpd.main.index_page=index.html index.php
...


Code: [Select]
nano /etc/config/uhttpd
...
option index_page 'index.html index.php'
...


The order of index.html index.php  is very important, the last one has high high priority.

"index.html index.php" ; index.php  shows first, if index.php is missing then shows index.html.
"index.php index.html"; index.html shows first.

5a2v0

#9
Oct 30, 2014, 12:30 pm Last Edit: Oct 30, 2014, 12:31 pm by 5a2v0
@sonnyyu tried right now ! Same result...


http://yun.ip/ ==> open automatically http://yun.ip/cgi-bin/luci/webpanel/homepage

http://yun.ip/sd/ ==> open automatically the php files http://yun.ip/sd/index.php

but

http://yun.ip/keystore_manager_example/ ==> DOESN'T open the index.html file !! It returns the error "No such file or directory" ... I have to manually write:

http://yun.ip/keystore_manager_example/index.html for open the page !!!

sonnyyu

It works for me.

after backup your own data,

Code: [Select]
/usr/bin/reset-to-factory-anyway

will bring your Yun  back to factory default. then retry it.

federicofissore

The order of index.html index.php  is very important, the last one has high high priority.
Ahh that what brought to think it wasn't working: I thought first had higher priority. Clear now, even if counter intuitive

vitas76

#12
Nov 20, 2016, 09:20 am Last Edit: Nov 20, 2016, 02:17 pm by vitas76
Maybe too late but for everyone, I have The same problem and fix it.
If you need in webserver "uhttpd" run together html and php index ;)
Here is oficial man: https://wiki.openwrt.org/doc/uci/uhttpd#using_php5
Speed tutorial:
  • Must install PHP5:
    opkg update
    opkg install php5 php5-cgi
  • Must edit uhttpd config file
    vi /etc/config/uhttpd
    now must add 3 rows (lines)[without number & colon]:
    1:list interpreter '.php=/usr/bin/php-cgi'
    2:list index_page 'index.html, default.html, index.php'
    3:option index_file 'index.html, default.html, index.php'
  • And now just only restart uhttpd server:
    /etc/init.d/uhttpd restart
  • If you want can you control it:
    uci show uhttpd

When you will see in uci list this 3 lines as:
uhttpd.main.interpreter='.php=/usr/bin/php-cgi'
uhttpd.main.index_page='index.html, default.html, index.php'
uhttpd.main.index_file='index.html, default.html, index.php'

Quote
You're a winner :)

Go Up