1.网上下载goahead-3.1.1-0-src.tgz包
2.解压
tar -zxvf goahead-3.1.1-0-src.tgz
3.编译
cd goahead-3.1.1-0
make CC=arm-none-linux-gnueabi-gcc ARCH=arm
在linux-arm-default/bin中可以找到goahead
4.测试修改
运行./goahead测试
问题1:
goahead: 0: Can't get host address for host dvr: errno 11 goahead: 0: Can't initialize server. Exiting.
出处:goahead-3.1.1-0\src\http.c文件的setLocalHost函数
if ((hp = gethostbyname(host)) == NULL) { //MHB 2013-10-22 出错地方 error("Can't get host address for host %s: errno %d", host, errno); //----这 return -1; } memcpy((char*) &intaddr, (char *) hp->h_addr_list[0], (size_t) hp->h_length); ipaddr = inet_ntoa(intaddr); //一切的操作目的是获取ipaddr websSetIpAddr(ipaddr); websSetHost(ipaddr);
修改:
#if 0 if ((hp = gethostbyname(host)) == NULL) { //MHB 2013-10-22 error("Can't get host address for host %s: errno %d", host, errno); return -1; } memcpy((char*) &intaddr, (char *) hp->h_addr_list[0], (size_t) hp->h_length); ipaddr = inet_ntoa(intaddr); #else //MHB 2013-10-22 换种方式获取ip地址 (ipv4) int sockfd; struct sockaddr_in sin; struct ifreq ifr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == -1) { return -1; } strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); //网卡多的得修改下 ifr.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) { return -1; } memcpy(&sin, &ifr.ifr_addr, sizeof(sin)); ipaddr=inet_ntoa(sin.sin_addr); #endif websSetIpAddr(ipaddr); websSetHost(ipaddr);
问题2:
goahead: 0: Can't open config file route.txt goahead: 0: Can't initialize server. Exiting.
解决方法:
拷贝goahead-3.1.1-0\src\route.txt文件到goahead同目录下
问题3:
网页存放位置
解决方法:
存放网页在goahead同目录下的web目录下,web目录手工创建一个便是
打开浏览器输入 ip地址