目的
在拥有(花生壳)内网穿透的功能以后,直接将壳域名链接至index.html文件,达到浏览器地址栏直接输入壳域名或ip(http:abcd.edfg.oicp.vip)就能访问至index.html文件,直接进入主页的目的。
前期准备
我入手树莓派的时间有点晚,型号3B+,此时4B已发布接近半年。官网系统已更新至buster。
编辑器的选择:我使用的是vi(软件自带nano)
https://blog.youkuaiyun.com/kongguguren/article/details/80039922
PHP7 NGINX配置:
(PHP7安装有问题是因为版本号更新,全部改为当前最新就行:php7.3)
https://web-security.cn/rapberry_pi_4b_install_php7.3_nginx_mysql/
换源注意
换源参考地址:
https://blog.youkuaiyun.com/kxwinxp/article/details/78370980
https://www.cnblogs.com/500m/p/10668625.html
需要注意的是:你的树莓派安装的是什么版本一定要在对应的位置将版本号改成自己的:
例如:我的是buster
对于/etc/apt/sources.list 将中的stretch改为buster
1.deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
2.deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
对于 /etc/apt/sources.list.d/raspi.list将中的stretch改为buster
1.deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/ stretch main ui
2.deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/ buster main ui
相关介绍
参考:
https://blog.youkuaiyun.com/xdw1985829/article/details/38919495
(以下内容介于对于参考地址内的内容的个人理解,有错误请见谅。)
nginx:web服务器
Apache:web服务器
1.对于服务器的理解,存储,管理网页内容的工具,像一个箱子。
mysql:数据库管理系统
sqlite:轻型的数据库
2.数据库,动态网页的数据链接,比如网页中的图片、登录用户,用户的配置等都存在这个箱子里。
php:通用开源脚本语言
3.语言、框架,但是它起到什么作用并不是很理解。
LAMP:集成WEB服务器 ,包含很多组件
宝塔:集成WEB服务器 ,包含很多组件
wordpress:建站(博客)的工具,也可做为其后台管理,类似web服务器
typecho:同上,特点在于对于博客比较擅长
正式开始
基本配置PHP完成以后,常规的测试页如图:
图片是引用的
地址为:https://blog.youkuaiyun.com/m0_37259197/article/details/83039096
配置nginx文件后,重启服务(有可能出现重启服务失败,注意修改片段的==}前的注释符==),输入自己的IP就会出现下图,这个是条件1。
配置参考地址:https://web-security.cn/rapberry_pi_4b_install_php7.3_nginx_mysql/
sudo vi /etc/nginx/sites-enabled/default
sudo systemctl restart nginx
sudo vi /var/www/html/index.php
写入以下php代码并保存
<?php
phpinfo();
添加PHP测试页以后会出现下图2,条件2.
上传静态网页源码
通过ftp或者拷贝上传源码至(一般源码中index.html就是网站内容主页)
/var/www/html
上传参考:
https://blog.youkuaiyun.com/qq_41925396/article/details/84845217
注意事项
树莓派中的html文件夹的权限将影响文件传入,错误代码550一般是ftp的服务没配置好,553一般是文件夹权限,可以通过chown命令
chown命令使用方法 https://www.runoob.com/linux/linux-comm-chown.html
chown pi: /var/www/html
再次配置nginx文件
sudo vi /etc/nginx/sites-enabled/default
自server开始的文件片段,找到location / {
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 此处填写自己的ip或者壳域名;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
root /var/www/html;
# 重新定义下文件目录?小白,刚玩这个对这个的命名不是很清楚
index index.html;
# 索引需要当作主页的文件,我这边网页源码立面是index.html
try_files $uri $uri/ =404;
}
server_name 此处填写自己的ip或者壳域名;
root /var/www/html;
# 重新定义下文件目录?小白,刚玩这个对这个的命名不是很清楚index index.html;
# 索引需要当作主页的文件,我这边网页源码立面是index.html
参考:
https://www.cnblogs.com/kukudi/p/11496315.html
https://www.cnblogs.com/tujietg/p/10753041.html
(结束:小白本来想学习一下自建网页,但是无奈没那么多时间,系统学习网页,只能通过这一条路走通以后去修改源码,毕竟云服务器太贵,备案太麻烦)
参考文档
[1]: https://blog.youkuaiyun.com/kongguguren/article/details/80039922
[2]: https://blog.youkuaiyun.com/kxwinxp/article/details/78370980
[3]: https://www.cnblogs.com/500m/p/10668625.html
[4]: https://blog.youkuaiyun.com/xdw1985829/article/details/38919495
[5]: https://blog.youkuaiyun.com/m0_37259197/article/details/83039096
[6]:https://web-security.cn/rapberry_pi_4b_install_php7.3_nginx_mysql/
[7]:https://blog.youkuaiyun.com/qq_41925396/article/details/84845217
[8]:https://www.runoob.com/linux/linux-comm-chown.html
[9]:https://www.cnblogs.com/tujietg/p/10753041.html
[10]:https://www.cnblogs.com/kukudi/p/11496315.html