Raspberry Pi (Raspberry Pi) Learning 11: Turn the Raspberry Pi into a Web server (GO)

Source: Internet
Author: User
Tags install php

Turn the Raspberry Pi into a Web server, you can control the Raspberry Pi by visiting the Web page, for example: Check the camera \ Turn on the light and so on.

The thought of Linux Web server, the first thing we think of IS, Apache + MYSQL + Php.

Raspberry Pi can install this lamp series, but Apache and MySQL for Raspberry Pi This small machine, is too heavy, mainly consumes more memory \ Slow disk size (about 200M)

So install a lightweight Web server.

By trial, the recommended combination is: Nginx + php + SQLite

Nginx is a lightweight Web server, not bad than Apache

SQLite is one of the most lightweight databases

PHP Everyone is familiar with the Web scripting language

1, install Nginx Web server (about 6MB)
sudo apt-get install Nginx

2, start Nginx
Sudo/etc/init.d/nginx start

Nginx www root directory default in/usr/share/nginx/www



3, install PHP and SQLite (about 3MB)
sudo apt-get install php5-fpm php5-sqlite

4, modify the Nginx configuration file
sudo nano/etc/nginx/sites-available/default

4.1 The Listen line is found, the # # comment in front of it is removed, and the modified content is as follows
Listen 80; # # Listen for IPv4.

4.2 Find index line, add index.php, modify content as follows
Index index.php index.html index.htm

4.3 Find the definition section of PHP, remove the comments of these lines, and modify the contents as follows
Location ~ \.php$ {
Fastcgi_pass Unix:/var/run/php5-fpm.sock;
Fastcgi_index index.php;
Include Fastcgi_params;
}

There are some other definitions in the PHP section, do not move it, for example:

# Fastcgi_split_path_info ...
# Fastcgi_pass 127.0.0.1:9000

5. Reload the Nginx configuration
Sudo/etc/init.d/nginx Reload

6, test, through the host's IE access to the Raspberry Pi, you can see the home page (indicating that the Web server has started properly)


<ignore_js_op>

7. Generate a PHP file in the Raspberry Pi and test the PHP

sudo nano/usr/share/nginx/www/test.php

Enter the following in the file

<? Phpinfo ();?>

Save to exit

IE visit this page, that PHP is OK


<ignore_js_op>

8, we also need to install an FTP server for downloading files to the Web

installation vsftpd, for Web content ftpd upload, installation method See Raspberry Pi (Raspberry) Learn to install the FTP server

9, generate a site administrator user, for FTP download Web site files, as follows

Add a user named WebAdmin

sudo useradd WebAdmin

Modify password for user WebAdmin
sudo passwd WebAdmin

As prompted, enter the password, for example: 123456

To have the user WebAdmin ownership of the WWW root directory
sudo chown-r webadmin/usr/share/nginx/www

Change the login directory for user WebAdmin to the WWW root directory

sudo usermod-d/usr/share/nginx/www WebAdmin

Restart VSFTPD

sudo service vsftpd restart

OK, configuration completed, user WebAdmin login FTP, will go directly to the WWW root directory, and can download files \ Create directory \ Delete files and so on.



This sticker was transferred from Jostudio's personal blog.

Raspberry Pi (Raspberry Pi) Learning 11: Turn the Raspberry Pi into a Web server (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.