Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4--OpenWRT C CGI helloworld! #5

Open
cooljiansir opened this issue Nov 16, 2014 · 0 comments
Open

4--OpenWRT C CGI helloworld! #5

cooljiansir opened this issue Nov 16, 2014 · 0 comments

Comments

@cooljiansir
Copy link
Owner

OpenWRT C CGI helloworld!

We don't want to install php on our OpenWRT since it's too big,We can write a small cgi in c(like php)

You must finish the No.2 and No.3 issue first

cd /home/workplace/OpenWrt-SDK-ramips-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2
cd package/helloworld/src/
vi helloworld.c    #content as follow
#include <stdio.h>
#include <stdio.h> //getenv

int main(void){
        printf("Content-Type: text/html\n\n");
        printf("GET:%s\n",getenv("QUERY_STRING"));
        return 0;
}
cd ../../../
make 
cd bin/ramips/packages/
scp helloworld_1_ramips_24kec.ipk root@192.168.8.1:/usr/bin
ssh root@192.168.8.1
cd /usr/bin
opkg install helloworld_1_ramips_24kec.ipk 
cd /webroot/
mkdir cgi-bin
cd cgi-bin
cp /bin/helloworld ./

visit http://192.168.8.1:81/cgi-bin/helloworld?helloworld=cgi

For more about cgi c ,refer to http://blog.csdn.net/kaloha3/article/details/8548027

@cooljiansir cooljiansir changed the title OpenWRT C CGI helloworld! 4--OpenWRT C CGI helloworld! Nov 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant