Tiny Core Linux
Tiny Core Extensions => TCE Q&A Forum => Topic started by: Adam on April 05, 2017, 09:35:04 AM
-
Hi all,
I've Apache & PHP installed on TCL. By default, there is index.html in /usr/local/apache2/htdocs. I've removed that file and replaced it with index.php. Code as below.
However, it seems like the Apache unable to process index.php automatically as seen in the screenshot below. Please advise.
tc@box:~$ df -h | grep apache
/dev/loop22 944.0K 944.0K 0 100% /tmp/tcloop/apache2
/dev/loop23 3.3M 3.3M 0 100% /tmp/tcloop/apache2-mod-php5
tc@box:~$
tc@box:~$ cd /usr/local/apache2/htdocs
tc@box:/usr/local/apache2/htdocs$ ls -lh
total 4
lrwxrwxrwx 1 root root 55 Apr 5 13:24 index.html -> /tmp/tcloop/apache2/usr/local/apache2/htdocs/index.html
-rw-r--r-- 1 tc staff 20 Apr 4 18:27 index.php
tc@box:/usr/local/apache2/htdocs$ rm -f index.html
tc@box:/usr/local/apache2/htdocs$ ls -lh
total 4
-rw-r--r-- 1 tc staff 20 Apr 4 18:27 index.php
tc@box:/usr/local/apache2/htdocs$
tc@box:/usr/local/apache2/htdocs$ lynx localhost
Index of /
Index of /
* index.php
tc@box:/usr/local/apache2/htdocs$ cat index.php
<?php
phpinfo();
?>
tc@box:/usr/local/apache2/htdocs$
This is another test
tc@box:/usr/local/apache2/htdocs$ cat index.html
<html>
<body>
This is HTML!
</body>
</html>
tc@box:/usr/local/apache2/htdocs$ cat index.php
<?php
echo 'This is PHP!';
?>
tc@box:/usr/local/apache2/htdocs$
index.php file is executed instead of index.php
tc@box:/usr/local/apache2/htdocs$ lynx localhost
This is HTML!
I'm able to execute index.php manually
tc@box:/usr/local/apache2/htdocs$ lynx localhost/index.php
This is PHP!
However, Apache still can't process index.php even though index.html has been removed.
tc@box:/usr/local/apache2/htdocs$ ls -lh
total 8
-rw-r--r-- 1 tc staff 44 Apr 5 13:54 index.html
-rw-r--r-- 1 tc staff 30 Apr 5 13:57 index.php
tc@box:/usr/local/apache2/htdocs$ rm -f index.html
tc@box:/usr/local/apache2/htdocs$ ls -lh
total 4
-rw-r--r-- 1 tc staff 30 Apr 5 13:57 index.php
tc@box:/usr/local/apache2/htdocs$ lynx localhost
Index of /
Index of /
* index.php
-
Hi Adam
The php executable is in php5.tcz
Did you load it ?
-
Hi Adam
The php executable is in php5.tcz
Did you load it ?
I've apache2-mod-php5.tcz installed. I thought this apache comes with php?
Title: apache2-mod-php5.tcz
Description: php5 - Apache 2 module and extensions
Version: 5.4.3
Author: Various
Original-site: http://www.php.net
Copying-policy: GPL (see /usr/local/share/doc/License/apache2-mod-php5.txt)
Size: 3.4M
Extension_by: gutmensch
Tags: apache php module version 5
Comments: For use with apache2.tcz extension. This extension does not depend on php5.tcz, nor are they related.
Usage: Install and restart your Apache Web Server. If your httpd.conf is not
in the default location, you have to add "Include conf/php5/mod_php5.conf" manually
to your conf.
Suhosin extension by Stefan Esser is included.
Edit /usr/local/apache2/conf/php5/php.ini to your needs and add to backup.
Do the same with the extension configuration files in /usr/local/apache2/conf/php5/extensions/.
IMPORTANT: For some of the included extensions you need special additional libraries,
please take a look into dist.ini.
---
This extension is PPI compatible.
Change-log: 2010/05/30 Initial version 5.3.2
2010/07/02 Corrected mysql flags to use mysqlnd, removed kerberos flag because it is only for imap
2010/07/02-1 Added postgresql support
2010/07/02-2 Added enchant support
2010/08/20 Bump to 5.3.3
2010/09/14 PHP module is automatically added to Apache by mod_php5.conf file.
2010/09/14-1 Added xsl extension
2010/10/16 Added bsddb and iodbc support, moved extensions to dist.ini, extracted more extensions
2010/11/02 Added mbstring
Current: 2012/05/07 Updated to PHP 5.4.3
-
I am having the same issue.
In fact, when I reboot, the default index.html is written back into the htdocs folder every time and it takes priority over the index.php
Even if I delete all of the .html files in the htdocs directory, when opening a browser of the location it simply displays an index of the files there instead of running the index.php
I have installed the php5.tcz to load on boot. Is there something else I need to add to bootlocal.sh to make it available to the apache2-mod-pho5.tcz module? This module is already called out specifically in the httpd.conf file.
BKM
-
I am having the same issue.
In fact, when I reboot, the default index.html is written back into the htdocs folder every time and it takes priority over the index.php
Even if I delete all of the .html files in the htdocs directory, when opening a browser of the location it simply displays an index of the files there instead of running the index.php
I have installed the php5.tcz to load on boot. Is there something else I need to add to bootlocal.sh to make it available to the php apache module?
BKM
Exactly!
tc@box:~$ cat /opt/.filetool.lst
opt
home
/etc/passwd
/etc/shadow
/usr/local/etc/ssh
/etc/sudoers
/etc/resolv.conf
/usr/local/var/lib/slocate/slocate.db
/usr/local/apache2/htdocs
tc@box:~$
I can delete the default index.html file (blue color), but the same file will be created again after reboot. Is it possible to remove this file permanently?
tc@box:/usr/local/apache2/htdocs$ ls -lh
total 8
lrwxrwxrwx 1 root root 55 Apr 5 14:01 index.html.bak -> /tmp/tcloop/apache2/usr/local/apache2/htdocs/index.html
-rw-r--r-- 1 tc staff 44 Apr 5 14:04 index.html.test
-rw-r--r-- 1 tc staff 30 Apr 5 13:57 index.php
tc@box:/usr/local/apache2/htdocs$
-
I've apache2-mod-php5.tcz installed. I thought this apache comes with php?
No, it's not a part of the dependence.
http://tinycorelinux.net/7.x/x86/tcz/apache2-mod-php5.tcz.tree (http://tinycorelinux.net/7.x/x86/tcz/apache2-mod-php5.tcz.tree)
-
I can't say for sure how the PHP5 extension is organized, but I can say that you need to enable PHP handling in apache by adding something like this to your httpd.conf file:
LoadModule php5_module modules/mod_php5.so (or whatever the php5 module name is)
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Use this instead for FPM:
<Proxy "fcgi://127.0.0.1:9000/" enablereuse=on max=10>
</Proxy>
<FilesMatch \.php$>
# Use the standard TCP socket
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</FilesMatch>
Usually these directives are in a separate include file. I'm using PHP7 on 64-bit so I'm guessing about your configuration. Don't forget to add your apache config files to /opt/.filetool.lst to make them persistent across reboots.
-
Hi Adam
tc@box:~$ cat /opt/.filetool.lst
opt
home
/etc/passwd
/etc/shadow
/usr/local/etc/ssh
/etc/sudoers
/etc/resolv.conf
/usr/local/var/lib/slocate/slocate.db
/usr/local/apache2/htdocs
tc@box:~$
You need to remove the leading / marks on those last 7 entries.
-
According to the info page of apache2-mod-php5.tcz
" For use with apache2.tcz extension. This extension does not depend on php5.tcz, nor are they related."
Once the apache2-mod-php5.tcz module is installed the appache2 config file is automatically updated with the following include statement:
Include conf/php5/mod_php5.conf
So everything should work. But it doesn't.
Additionally, I also have the usr/local/apache2/htdocs folder called out in my .filetool.lst but on reboot the index.html is added back to the htdocs directory even though it was deleted before the shutdown and forced backup. (and yes, mine is edited correctly without the leading / character)
BKM
-
Hi bkm
Additionally, I also have the usr/local/apache2/htdocs folder called out in my .filetool.lst but on reboot the index.html is added back to the htdocs directory even though it was deleted before the shutdown and forced backup. (and yes, mine is edited correctly without the leading / character)
BKM
The index.html file is being placed there when the Apache extension is loaded. Backup will only restore saved files, it will not
remove files that were not backed up. Add a command in bootlocal.sh to remove the unwanted file.
-
Add a command in bootlocal.sh to remove the unwanted file.
Done!!
Now all I need is a way to get the index.php to display when the site is accessed by a browser. Right now it displays an index of the contents of htdocs directory.
Not sure what is wrong with the php configuration. Trying to slug through the php.ini file now, but it is over 1800 lines of redundant confusion and so far nothing to indicate it to not be working properly.
BKM
-
Try adding this to your httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
-
8) 8) andyj 8) 8)
That did the trick. I would have been reading for months before I ever found that pearl of wisdom.
Anyone else reading this, remember to flush your browser cache before you retry you site ::)
Thank you!
BKM
-
Try adding this to your httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Yeah, that really does the trick. :)
And don't forget to restart the apache service.... of course :)
Many thanks andyj and others for helping. I really appreciate it :)
You guys are the awesome. 8)
tc@box:/usr/local/apache2/htdocs$ sudo apachectl -k restart
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
tc@box:/usr/local/apache2/htdocs$
tc@box:/usr/local/apache2/htdocs$ l
total 4
-rw-r--r-- 1 tc staff 30 Apr 6 02:06 index.php
tc@box:/usr/local/apache2/htdocs$
tc@box:/usr/local/apache2/htdocs$ cat index.php
<?php
echo 'This is PHP!';
?>
tc@box:/usr/local/apache2/htdocs$
tc@box:/usr/local/apache2/htdocs$ lynx localhost
This is PHP!
-
You need to remove the leading / marks on those last 7 entries.
Thanks Rich. May I know why? I still have those leading / marks on /opt/.filetool.lst but I don't have any problems with them.
As example, /etc/shadow file. I can change my password and use the same new password even after I reboot the TCL.
-
Hi Adam
I don't recall the entire explanation but I think it had something to do with how tar handles paths.
-
Try adding this to your httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Very cool and many thanks to andyj for this. I wound up adding it to the very end of the httpd.conf file and it worked. However, if you really want to do it the right way, this same IfModlue appears around line# 223 in the httpd.conf file. You can edit it in place to match the syntax provided by andyj.
(Umm... YES, I did read the whole danged file eventually looking for any other settings that might be useful. I was bored :P )
Just thought I would add this for those of us that like to do things cleanly when possible. 8)
BKM