Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How start apache2 server? #13

Closed
MaximMikulich opened this issue Sep 4, 2019 · 7 comments
Closed

How start apache2 server? #13

MaximMikulich opened this issue Sep 4, 2019 · 7 comments

Comments

@MaximMikulich
Copy link

MaximMikulich commented Sep 4, 2019

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

@TOLDOTECHNIK
Copy link
Owner

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
Copy link
Owner

TOLDOTECHNIK commented Sep 4, 2019

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
Copy link
Owner

TOLDOTECHNIK commented Sep 5, 2019

Try to remove S30nodeserver and reboot again.

@MaximMikulich
Copy link
Author

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
Copy link
Owner

TOLDOTECHNIK commented Sep 9, 2019

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

@TOLDOTECHNIK TOLDOTECHNIK reopened this Sep 9, 2019
@MaximMikulich
Copy link
Author

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

@ghost
Copy link

ghost commented Dec 7, 2021

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

@ghost ghost mentioned this issue Dec 7, 2021
Closed
@TOLDOTECHNIK TOLDOTECHNIK mentioned this issue Dec 9, 2021
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants