Quantcast
Channel: banana pi single board computer open source project official forum BPI team - Latest posts
Viewing all articles
Browse latest Browse all 44647

BPI-M2+ Weather station:Air pressure sensor, temperature sensor,light intensity sensor arduino lib

$
0
0

BPI-M2+ Weather station_11 create web server(nginx+php)

we need finish create nginx+php server

install nginx:


1 install nginx

sudo apt-get install nginx
  1. Modify Profile

    sudo nano /etc/nginx/sites-available/default

change web root directory

chane root to as below

#root /var/www/html;

root /home/pi/www;
  1. create a test page

    sudo nano /home/pi/www/index.html

edit index.html add below:

<h1>hello world!</h1>

save

4.reboot nginx

sudo nginx -s stop
sudo nginx

5 test
open browser and imput : 127.0.0.1

install PHP:


  1. download php

    wget –c http://cn2.php.net/distributions/php-5.4.45.tar.bz2

  2. unzip

    tar –jxvf php-5.4.45.tar.bz2

  3. Generate configuration files

    cd php-5.4.45
    ./configure --enable-fpm --with-mysql

erroe:

error:xml2-config not found. Please check your libxml2 installation

Execute the commands below:

sudo apt-get install libxml2-dev

rebuild makefile

../configure--enable-fpm --with-mysql
  1. compile

    ./make

  2. when compile finish , do install

    sudo makeinstall

  3. Create a configuration file, and copy it to the correct location.

    cp php.ini-development/usr/local/php/php.ini
    cp /usr/local/etc/php-fpm.conf.default/usr/local/etc/php-fpm.conf
    cp sapi/fpm/php-fpm /usr/local/bin

  4. set php.ini cgi.fix_pathinfo to 0 。

open php.ini:

sudo nano /usr/local/php/php.ini

find cgi.fix_pathinfo= and change it to 0

cgi.fix_pathinfo=0
  1. before you start php server ,need to editphp-fpm.conf file ,check php-fpm module use www-data user and www-data user group to run it,

    sudo nano /usr/local/etc/php-fpm.conf

change as below:

; Unix user/group of processes
; Note: The user is mandatory. If the groupis not set, the default user's group
;      will be used.
user = www-data
group = www-data
  1. start php-fpm server :

    ./usr/local/bin/php-fpm

  2. add php start when boot OS

edit rc.local

sudo nano /etc/rc.local

at exit 0 add below

sudo php-fpm &

change nginx configuration

  1. change main page and php configuration

    sudo nano/etc/nginx/sites-available/default

find index line ,add index.php, as below:

index index.php index.html index.htm

find php define line, change it as below:

location ~* .php$ {

fastcgi_index index.php;

fastcgi_pass 127.0.0.1:9000;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

}

  1. reboot nginx

    sudo nginx -s stop
    sudo nginx

  2. create a test page:

    sudo nano /home/pi/www/index.php

input

<? phpinfo(); ?>

save

  1. open brower ,and input :127.0.0.1

so all is working fine.


Viewing all articles
Browse latest Browse all 44647

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>