TOLDOTECHNIK / buildroot-webkit

Buildroot WebKit fullscreen browser for Raspberry Pi. Suitable for HTML 5 user interfaces or digital signage / kiosk installations. It also can be used as a fullscreen video loop player. Ready to use RPi Zero/W and RPi 3 B SD card images are available.
244 stars 53 forks source link

How start apache2 server? #13

Closed MaximMikulich closed 5 years ago

MaximMikulich commented 5 years ago

I disabled nodejs and installed apache2, php, how to start now properly? I have a white screen

TOLDOTECHNIK commented 5 years ago

Try to display the PHP info message in your index file:

<?php
phpinfo();
?>

If there's no output, have a look in the /etc/init.d folder. Is there a init script for apache/php? Is the apache server running? Check the output of htop command on the fly. We cannot get you more support on this.

TOLDOTECHNIK commented 5 years ago

Try to use this script: https://github.com/buildroot/buildroot/blob/master/package/apache/S50apache Put it in the /etc/init.d folder and make it executable chmod +x S50apache Maybe you need something similar for PHP.

TOLDOTECHNIK commented 5 years ago

Try to remove S30nodeserver and reboot again.

MaximMikulich commented 5 years ago

in /var/logs/error_log

[Thu Sep 05 11:19:22.927420 2019] [mpm_event:crit] [pid 0:tid 1996308464] (70023)This function has not been implemented on this platform: AH00495: Couldn't create a Thread Safe Pollset. Is it supported on your platform?Also check system or user limits!
[Thu Sep 05 11:19:22.927866 2019] [:emerg] [pid 0:tid 1996308464] AH00017: Pre-configuration failed, exiting

httpd not running

TOLDOTECHNIK commented 5 years ago

Apache2

Apache2 with PHP works absolutely fine. For the setup there are a few things you have to keep in mind. To make it simple, here's a short step by step guide:

make menuconfig Target packages -> Networking applications -> [x] apache (default settings) Target packages -> Interpreter languages and scripting -> [x] php │ │ [x] Apache interface make

Write the image to the SD card. Then do some adjustments on your Raspberry Pi rm /etc/init.d/S30nodeserver nano /etc/init.d/S50apache

#!/bin/sh
#
# Start the apache service ...
#

rm /var/logs/httpd.pid   #Quick and dirty fix for: Apache error “Error retrieving pid file /var/logs/httpd.pid”

APACHE_DIR=/usr/bin

case "$1" in
  start)
    echo "Starting apache web server..."
    $APACHE_DIR/apachectl -k start
    ;;
  stop)
    echo -n "Stopping apache web server..."
    $APACHE_DIR/apachectl -k stop
    ;;
  restart|reload)
    $APACHE_DIR/apachectl -k stop
    $APACHE_DIR/apachectl -k start
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart}"
    exit 1
esac

exit $?

make the script executable with chmod +x /etc/init.d/S50apache

To enable PHP you need to modify the httpd.conf file

nano /etc/apache2/httpd.conf

Add following to the <Directory "/usr/htdocs"> node DirectoryIndex index.php and insert this at the end of the file:

<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
  SetHandler application/x-httpd-php
</FilesMatch>

This is the folder for the web files: /usr/htdocs/

To check if PHP works a test file can be created. nano /usr/htdocs/index.php

<?php
phpinfo();
?>

Restart the Apache web server by calling /etc/init.d/S50apache restart or reboot the device.

You can put all of the modified files into the board/toldotechnik_rpi/rootfs-overlay/ directory so that they are included after every build of the image.

NGINX

However, we recommend using the NGINX web server. It is much faster and comes already with a predefined init script (/etc/init.d/S50nginx).

make menuconfig Target packages -> Networking applications -> [x] nginx (default settings) Target packages -> Interpreter languages and scripting -> [x] php │ │ [x] FPM interface

make

Write the image on the SD card.

rm /etc/init.d/S30nodeserver

This is the folder for the web files: /usr/html

To enable PHP you need to modify /etc/nginx/nginx.conf

nano /etc/nginx/nginx.conf

Put this in the http { server { ... } } node.

 location ~ \.php$ {
     fastcgi_pass  unix:/var/run/php-fpm.sock;
     include       fastcgi.conf;
 }

If index.php should be called by default, adjust the location node as follows.

location / {
  root   html;
  index  index.php index.html index.htm;
}

/etc/init.d/S50nginx restart

A prebuilt NGINX/PHP image for RPi3 can be downloaded here: https://dev.toldotechnik.li/download/sdcardRPi3-NGINX-PHP-Python.img.zip

MaximMikulich commented 5 years ago

@TOLDOTECHNIK I did) rebuilt and it worked) But thanks for the detailed description! It will help someone!

ghost commented 2 years ago

@TOLDOTECHNIK i want NGINX/PHP image for "RPi0 w" pleas