赞
踩
陈拓 2020/08/21-2020/10/25
相关文档:
《Ubuntu设置Nginx支持CGI》https://blog.csdn.net/chentuo2000/article/details/109205483
《树莓派安装Web服务器Boa和CGIC》https://blog.csdn.net/chentuo2000/article/details/108535232
cat /etc/issue
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt update或者sudo apt-get update
sudo apt upgrade或者sudo apt-get upgrade
sudo su root
进入我的工作目录:
cd ct
下载链接地址:
http://www.boa.org/boa-0.94.14rc21.tar.gz
下载:
wget -c http://www.boa.org/boa-0.94.14rc21.tar.gz
tar zxvf boa-0.94.14rc21.tar.gz
apt-get install bison flex byacc m4
cd boa-0.94.14rc21
./configure
make
1) 创建/etc/boa目录
mkdir /etc/boa
2) 将生成的可执行程序以及配置文件复制到/etc/boa/目录下
cp src/boa src/boa_indexer /etc/boa
cp examples/boa.conf /etc/boa/
mkdir /var/log/boa/
mkdir /var/www/
mkdir /var/www/cgi-bin
nano /etc/boa/boa.conf
cat /etc/boa/boa.conf | grep -v "^#"
Port 8080
User root
Group root
ErrorLog /var/log/boa/error_log # 调试完可以注释掉
AccessLog /var/log/boa/access_log # 调试完可以注释掉
DocumentRoot /var/www
UserDir public_html
DirectoryIndex index.html
KeepAliveMax 1000
KeepAliveTimeout 10
MimeTypes /etc/mime.types
DefaultType text/plain
CGIPath /bin:/usr/bin:/usr/local/bin
Alias /doc /usr/doc
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
在/var/www/目录下创建简单的index.html文件。
nano /var/www/index.html
- <html>
- <body>
- <h1>Hello Pi BOA.</h1>
- </body>
- </html>
sudo /etc/boa/boa
ps -ef | grep boa
在浏览器地址栏输入http://192.168.1.8:8080/
复制一个名为favicon.ico的图标文件到/var/www/目录
刷新浏览器。
CGIC是一个C语言cgi库,最新版本2.08,可以从github下载。
Github网址:https://github.com/boutell/cgic
退出root,在普通用户账户下操作。
git clone https://github.com/boutell/cgic.git
mkdir cgic_test
cd cgic_test
nano test.c
- #include <stdio.h>
-
- int main(void)
- {
- printf("Content-Type:text/plain;charset=us-ascii\n\n");
- printf("Hello World\n\n");
- return 0;
- }
gcc -o test.cgi test.c
./test.cgi
将test.cgi复制到/var/www/cgi-bin
sudo cp test.cgi /var/www/cgi-bin
http://192.168.1.8:8080/cgi-bin/test.cgi
先找到rc-local.service文件
编辑rc-local.service
sudo nano /lib/systemd/system/rc-local.service
添加
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
Ubuntu18.04没有/etc/rc.local,建立一个。
sudo nano /etc/rc.local
- #!/bin/sh -e
-
- # startup boa
- /etc/boa/boa
-
- exit 0
sudo chmod 755 /etc/rc.local
sudo reboot
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。