Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30
  1. #21

    Hi IM back with a new problem, how can you let ur webserver support PHP and MYSQL?

  2. #22
    Quote Originally Posted by poymode View Post
    Hi IM back with a new problem, how can you let ur webserver support PHP and MYSQL?
    For PHP support I think you need an interpreter or something.

  3. #23
    Quote Originally Posted by poymode View Post
    Hi IM back with a new problem, how can you let ur webserver support PHP and MYSQL?
    Hi,

    If you're making your own server, I really suggest that you just concentrate on the web server so that it will be less complicated.

    Anyway, there are many ways to let your server support PHP. A very easy way is to let your server pipe its output to PHP:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <string.h>
    
    int main(int argc, char **argv)
    {
            pid_t id;
            int count;
            int fildes[2];
            char php_code[] = "<?php echo \"Hello world!\n\"; ?>";
    
            pipe(fildes);
    
            if ((id = fork()) == 0) {
                    /* we are in the child */
                    close(0);         /* close stdin */
                    dup(fildes[0]);   /* put read end of pipe into stdin index */
                    close(fildes[1]); /* close "write" end of pipe */
    
                    if (execlp("php-cgi", NULL) < 0) {
                            printf("execl failed\n");
                            exit(1);
                    }
            } else {
                    /* we are in the parent */
                    /* close "read" end of pipe */
                    close(fildes[0]);
                    /* send code to PHP interpreter */
                    write(fildes[1], php_code, strlen(php_code));
                    /* close write end to tell sort we are done */
                    close(fildes[1]);
                    id = wait(NULL); /* wait for child */
            }
    
            return(0);
    }
    Here's the output:
    Code:
    simoncpu@localhost:/tmp$ gcc -o pipe-sample pipe-sample.c
    simoncpu@localhost:/tmp$ ./pipe-sample
    Content-type: text/html
    
    Hello world!
    You can also bind PHP to an address and port, and communicate to it via sockets but it's a bit complicated. Just google for "socket programming" for more info.

    Please note that the above code works for PHP-CGI only. Enjoy!
    Last edited by simoncpu; 08-12-2008 at 12:19 PM.

  4. #24
    Quote Originally Posted by simoncpu View Post
    Hi,

    If you're making your own server, I really suggest that you just concentrate on the web server so that it will be less complicated.

    Anyway, there are many ways to let your server support PHP. A very easy way is to let your server pipe its output to PHP:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <string.h>
    
    int main(int argc, char **argv)
    {
            pid_t id;
            int count;
            int fildes[2];
            char php_code[] = "<?php echo \"Hello world!\n\"; ?>";
    
            pipe(fildes);
    
            if ((id = fork()) == 0) {
                    /* we are in the child */
                    close(0);         /* close stdin */
                    dup(fildes[0]);   /* put read end of pipe into stdin index */
                    close(fildes[1]); /* close "write" end of pipe */
    
                    if (execlp("php-cgi", NULL) < 0) {
                            printf("execl failed\n");
                            exit(1);
                    }
            } else {
                    /* we are in the parent */
                    /* close "read" end of pipe */
                    close(fildes[0]);
                    /* send code to PHP interpreter */
                    write(fildes[1], php_code, strlen(php_code));
                    /* close write end to tell sort we are done */
                    close(fildes[1]);
                    id = wait(NULL); /* wait for child */
            }
    
            return(0);
    }
    Here's the output:
    Code:
    simoncpu@localhost:/tmp$ gcc -o pipe-sample pipe-sample.c
    simoncpu@localhost:/tmp$ ./pipe-sample
    Content-type: text/html
    
    Hello world!
    You can also bind PHP to an address and port, and communicate to it via sockets but it's a bit complicated. Just google for "socket programming" for more info.

    Please note that the above code works for PHP-CGI only. Enjoy!
    I am not an expert (yet) in Linux or C programming language. Why not you compile with a php-devel package? Para at least you can include a php library in your webserver.

  5. #25
    It seems a little complicated for me and maybe I can't do it that quick.

    I have wondered upon another idea, how about web serving using mobile devices?
    if dili kaya sa cell phones then possible ba sa PDA's and smartphones?

    naa naba ing.ana? Java lang guro gamiton?

  6. #26
    Quote Originally Posted by poymode View Post
    It seems a little complicated for me and maybe I can't do it that quick.

    I have wondered upon another idea, how about web serving using mobile devices?
    if dili kaya sa cell phones then possible ba sa PDA's and smartphones?

    naa naba ing.ana? Java lang guro gamiton?
    Para nako impractical mo develope ug webserver on PDA or cellphone.

  7. #27
    Yepp impractical, pero morag lingaw ni nga project. I think it has uses which we haven't thought of yet though.

    BTW, I've tried running Apache on my HP iPAQ H5550 before. I tried both Familiar Linux and Ångström Distribution operating systems:



    (I only have a screenshot for Ångström; I reformatted my iPAQ already... sorry)

    Good luck on your project! Have fun, and enjoy programming! w00t!

    [ simon.cpu ]

  8. #28
    Quote Originally Posted by simoncpu View Post
    Yepp impractical, pero morag lingaw ni nga project. I think it has uses which we haven't thought of yet though.

    BTW, I've tried running Apache on my HP iPAQ H5550 before. I tried both Familiar Linux and Ångström Distribution operating systems:



    (I only have a screenshot for Ångström; I reformatted my iPAQ already... sorry)

    Good luck on your project! Have fun, and enjoy programming! w00t!

    [ simon.cpu ]
    ahhhh..pang thesis rajud ni amo, myta nindot ang gawas, myta sugtan sad

    anyway bro simon, na try nimo ug access ang website nga na host sa imong apache sa mga PDA nmu thru PC web browser like firefox or IE?

    naa ba na IP ang PDA?

    murag, if naa IP ang PDA, lets say 124.124.1.124, kung mu type ko ana sa firefox nya naay index.html imong PDA, ma kita?

  9. #29
    Quote Originally Posted by poymode View Post
    anyway bro simon, na try nimo ug access ang website nga na host sa imong apache sa mga PDA nmu thru PC web browser like firefox or IE?

    naa ba na IP ang PDA?

    murag, if naa IP ang PDA, lets say 124.124.1.124, kung mu type ko ana sa firefox nya naay index.html imong PDA, ma kita?

    Yepp yepp... basically, mora ra jud ug normal PC ang gawas... pwede pa gani ka maka SSH. Cool kaayo... =)

  10. #30
    Junior Member
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    200
    wow nindota ani oi...

  11.    Advertisement

Page 3 of 3 FirstFirst 123

Similar Threads

 
  1. What makes you proud of your boyfriend/girlfriend?
    By madzZz in forum "Love is..."
    Replies: 266
    Last Post: 03-13-2018, 11:44 AM
  2. What makes you LAUGH?
    By sab0y in forum General Discussions
    Replies: 567
    Last Post: 11-04-2013, 08:07 PM
  3. What situations make you emotional?
    By kayc in forum General Discussions
    Replies: 347
    Last Post: 06-03-2011, 08:02 PM
  4. Doesn't make sense...
    By davidofflyts in forum Food & Dining
    Replies: 48
    Last Post: 05-04-2009, 10:33 PM
  5. What makes a good musician?
    By fingolfin in forum Music & Radio
    Replies: 124
    Last Post: 03-13-2008, 11:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top