Installing Nginx on a Raspberry Pi
1 | sudo apt-get install nginx |
Enter the following command in the terminal to start the web server on the Raspberry Pi.
1 | sudo systemctl start nginx |
Access Raspberry Pi IP address:80 to verify successful installation
1 | http://192.168.124.248:80/ |
Add php and sqlite3 support
Add php source
1 | sudo apt install software-properties-common |
Start sqlite3 support
1 | sudo apt install php-sqlite3 sqlite3 |
Installing php components
1 | sudo apt install php-redis |
Configuring NGINX for PHP
1 | sudo apt-get install php7.4-fpm php7.4-mbstring php7.4-mysql php7.4-curl php7.4-gd php7.4-curl php7.4-zip php7.4-xml -y |
Modify the configuration file
sudo vim /etc/nginx/nginx.conf index index.html index.htm; change into index index.php index.html index.htm;
1
2
3
4
5
6
7
8
92. ```bash
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#} change into1
2
3
4location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
NGINX reloading configuration
1 | sudo systemctl reload nginx |
Edit index.php file
1 | sudo vim /var/www/html/index.php |
If it can be displayed properly, the configuration is fine.
1 | Find the value of Loaded Configuration File in the display, usually `/etc/php/7.4/fpm/php.ini'. |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment