Installing php4 in a php5 environment












0















While there are many answers about running php5 and php4 together I haven't found answers that address my specific scenario.



I setup a new Ubuntu 12.4 server installed apache 2 and PHP 5.3.
I have a need to run php 4.4.9 due to having to work with an old CMS system was written long ago, still maintained and encounters errors when run via php5.



So php5 is running as an apache module.



I want to run php4 and everything points to having to run that as cgi. I've seen the solutions where people had to change file extensions to .php4 and run them through cgi handler, but I don't have that as an option for either php4 or php5. Too many files and the codebase is shared.



First question, can I install php4 as a module as well? followup, what's best way to do that?



second question, can I have the handler that switches to php4 do so on a directory path instead of just *.php4? So I could tell it a list of directories or use multiple <Directory> blocks to have just php files in those directories run as php4.



thanks,
- keith










share|improve this question





























    0















    While there are many answers about running php5 and php4 together I haven't found answers that address my specific scenario.



    I setup a new Ubuntu 12.4 server installed apache 2 and PHP 5.3.
    I have a need to run php 4.4.9 due to having to work with an old CMS system was written long ago, still maintained and encounters errors when run via php5.



    So php5 is running as an apache module.



    I want to run php4 and everything points to having to run that as cgi. I've seen the solutions where people had to change file extensions to .php4 and run them through cgi handler, but I don't have that as an option for either php4 or php5. Too many files and the codebase is shared.



    First question, can I install php4 as a module as well? followup, what's best way to do that?



    second question, can I have the handler that switches to php4 do so on a directory path instead of just *.php4? So I could tell it a list of directories or use multiple <Directory> blocks to have just php files in those directories run as php4.



    thanks,
    - keith










    share|improve this question



























      0












      0








      0








      While there are many answers about running php5 and php4 together I haven't found answers that address my specific scenario.



      I setup a new Ubuntu 12.4 server installed apache 2 and PHP 5.3.
      I have a need to run php 4.4.9 due to having to work with an old CMS system was written long ago, still maintained and encounters errors when run via php5.



      So php5 is running as an apache module.



      I want to run php4 and everything points to having to run that as cgi. I've seen the solutions where people had to change file extensions to .php4 and run them through cgi handler, but I don't have that as an option for either php4 or php5. Too many files and the codebase is shared.



      First question, can I install php4 as a module as well? followup, what's best way to do that?



      second question, can I have the handler that switches to php4 do so on a directory path instead of just *.php4? So I could tell it a list of directories or use multiple <Directory> blocks to have just php files in those directories run as php4.



      thanks,
      - keith










      share|improve this question
















      While there are many answers about running php5 and php4 together I haven't found answers that address my specific scenario.



      I setup a new Ubuntu 12.4 server installed apache 2 and PHP 5.3.
      I have a need to run php 4.4.9 due to having to work with an old CMS system was written long ago, still maintained and encounters errors when run via php5.



      So php5 is running as an apache module.



      I want to run php4 and everything points to having to run that as cgi. I've seen the solutions where people had to change file extensions to .php4 and run them through cgi handler, but I don't have that as an option for either php4 or php5. Too many files and the codebase is shared.



      First question, can I install php4 as a module as well? followup, what's best way to do that?



      second question, can I have the handler that switches to php4 do so on a directory path instead of just *.php4? So I could tell it a list of directories or use multiple <Directory> blocks to have just php files in those directories run as php4.



      thanks,
      - keith







      apache2 php






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 17 '12 at 18:28







      keith73

















      asked Jul 17 '12 at 18:18









      keith73keith73

      112




      112






















          3 Answers
          3






          active

          oldest

          votes


















          0














          php4 and php5 are incompatible with each other. You will either need to use the old, unsupported version (which you will ahve to build from source), or use php5 and update your systems. You cannot run them both simultaneously without breakage.






          share|improve this answer































            0














            You could set up php4 to run under a different webserver entirely, either apache 1.3 or lighthttpd. Just set that webserver to listen on a different port (not port 80), and either use that directly or set up some amount of rewriterules in apache2 to direct the php4 requests to the other webserver.



            That would be a lot of work and setup though, potentially more than just using CGI.






            share|improve this answer































              0














              For the first question, I don't believe this is wise even if possible - which it may be, I don't know anyone who has tried it.



              For the second question, you can indeed do this.



              However, you need to tell Apache which handler to use for the folders containing your PHP4 application.



              The normal way to make php4 run as cgi is:



              Add Handler php-script .php4
              Action php-script /cgi-bin/php4


              But this isn't quite what you want so we need to change to something like this:



              RemoveHandler .php 
              Add Handler php-script .php
              Action php-script /cgi-bin/php4


              You may need to add an ExecCGI option to the applications root folder too.



              I can't test that at the moment so there's a chance it wont work. As an alternative, you could put in a rewrite that changed all .php file requests to .php4



              Note that this is all dependent on having sufficient rights to make these changes either in a .htaccess file or in an apache conf file (which requires rights to restart the apache server).



              UPDATE: the more I think about my answer the less I think it will work. Checking the mod_php5 conf file, I can see that the handler is actually set against a mime type application/x-httpd-php so you'd have to adjust that as well I think.



              So maybe the rewrite is best.



              There is another possibility though. If you have access to the apache configuration files, you could empty /etc/apache/mods-available/php5.conf and move the contents into a site specific configuration. Then you could put a php4 specific configuration into another virtual host or even into a folder - though in that case, you'll probably need to include the php5 config in several places (for each application root folder on your web server).



              UPDATE 2: In fact, the answer to quesition 1 is also "yes", this is, in fact possible. You can run both by making use of suPHP. Though you should read about the possible limitations of running PHP this way.






              share|improve this answer

























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f164783%2finstalling-php4-in-a-php5-environment%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                php4 and php5 are incompatible with each other. You will either need to use the old, unsupported version (which you will ahve to build from source), or use php5 and update your systems. You cannot run them both simultaneously without breakage.






                share|improve this answer




























                  0














                  php4 and php5 are incompatible with each other. You will either need to use the old, unsupported version (which you will ahve to build from source), or use php5 and update your systems. You cannot run them both simultaneously without breakage.






                  share|improve this answer


























                    0












                    0








                    0







                    php4 and php5 are incompatible with each other. You will either need to use the old, unsupported version (which you will ahve to build from source), or use php5 and update your systems. You cannot run them both simultaneously without breakage.






                    share|improve this answer













                    php4 and php5 are incompatible with each other. You will either need to use the old, unsupported version (which you will ahve to build from source), or use php5 and update your systems. You cannot run them both simultaneously without breakage.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 17 '12 at 18:37









                    Thomas WardThomas Ward

                    44.3k23124176




                    44.3k23124176

























                        0














                        You could set up php4 to run under a different webserver entirely, either apache 1.3 or lighthttpd. Just set that webserver to listen on a different port (not port 80), and either use that directly or set up some amount of rewriterules in apache2 to direct the php4 requests to the other webserver.



                        That would be a lot of work and setup though, potentially more than just using CGI.






                        share|improve this answer




























                          0














                          You could set up php4 to run under a different webserver entirely, either apache 1.3 or lighthttpd. Just set that webserver to listen on a different port (not port 80), and either use that directly or set up some amount of rewriterules in apache2 to direct the php4 requests to the other webserver.



                          That would be a lot of work and setup though, potentially more than just using CGI.






                          share|improve this answer


























                            0












                            0








                            0







                            You could set up php4 to run under a different webserver entirely, either apache 1.3 or lighthttpd. Just set that webserver to listen on a different port (not port 80), and either use that directly or set up some amount of rewriterules in apache2 to direct the php4 requests to the other webserver.



                            That would be a lot of work and setup though, potentially more than just using CGI.






                            share|improve this answer













                            You could set up php4 to run under a different webserver entirely, either apache 1.3 or lighthttpd. Just set that webserver to listen on a different port (not port 80), and either use that directly or set up some amount of rewriterules in apache2 to direct the php4 requests to the other webserver.



                            That would be a lot of work and setup though, potentially more than just using CGI.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 17 '12 at 19:36









                            ImaginaryRobotsImaginaryRobots

                            7,17042636




                            7,17042636























                                0














                                For the first question, I don't believe this is wise even if possible - which it may be, I don't know anyone who has tried it.



                                For the second question, you can indeed do this.



                                However, you need to tell Apache which handler to use for the folders containing your PHP4 application.



                                The normal way to make php4 run as cgi is:



                                Add Handler php-script .php4
                                Action php-script /cgi-bin/php4


                                But this isn't quite what you want so we need to change to something like this:



                                RemoveHandler .php 
                                Add Handler php-script .php
                                Action php-script /cgi-bin/php4


                                You may need to add an ExecCGI option to the applications root folder too.



                                I can't test that at the moment so there's a chance it wont work. As an alternative, you could put in a rewrite that changed all .php file requests to .php4



                                Note that this is all dependent on having sufficient rights to make these changes either in a .htaccess file or in an apache conf file (which requires rights to restart the apache server).



                                UPDATE: the more I think about my answer the less I think it will work. Checking the mod_php5 conf file, I can see that the handler is actually set against a mime type application/x-httpd-php so you'd have to adjust that as well I think.



                                So maybe the rewrite is best.



                                There is another possibility though. If you have access to the apache configuration files, you could empty /etc/apache/mods-available/php5.conf and move the contents into a site specific configuration. Then you could put a php4 specific configuration into another virtual host or even into a folder - though in that case, you'll probably need to include the php5 config in several places (for each application root folder on your web server).



                                UPDATE 2: In fact, the answer to quesition 1 is also "yes", this is, in fact possible. You can run both by making use of suPHP. Though you should read about the possible limitations of running PHP this way.






                                share|improve this answer






























                                  0














                                  For the first question, I don't believe this is wise even if possible - which it may be, I don't know anyone who has tried it.



                                  For the second question, you can indeed do this.



                                  However, you need to tell Apache which handler to use for the folders containing your PHP4 application.



                                  The normal way to make php4 run as cgi is:



                                  Add Handler php-script .php4
                                  Action php-script /cgi-bin/php4


                                  But this isn't quite what you want so we need to change to something like this:



                                  RemoveHandler .php 
                                  Add Handler php-script .php
                                  Action php-script /cgi-bin/php4


                                  You may need to add an ExecCGI option to the applications root folder too.



                                  I can't test that at the moment so there's a chance it wont work. As an alternative, you could put in a rewrite that changed all .php file requests to .php4



                                  Note that this is all dependent on having sufficient rights to make these changes either in a .htaccess file or in an apache conf file (which requires rights to restart the apache server).



                                  UPDATE: the more I think about my answer the less I think it will work. Checking the mod_php5 conf file, I can see that the handler is actually set against a mime type application/x-httpd-php so you'd have to adjust that as well I think.



                                  So maybe the rewrite is best.



                                  There is another possibility though. If you have access to the apache configuration files, you could empty /etc/apache/mods-available/php5.conf and move the contents into a site specific configuration. Then you could put a php4 specific configuration into another virtual host or even into a folder - though in that case, you'll probably need to include the php5 config in several places (for each application root folder on your web server).



                                  UPDATE 2: In fact, the answer to quesition 1 is also "yes", this is, in fact possible. You can run both by making use of suPHP. Though you should read about the possible limitations of running PHP this way.






                                  share|improve this answer




























                                    0












                                    0








                                    0







                                    For the first question, I don't believe this is wise even if possible - which it may be, I don't know anyone who has tried it.



                                    For the second question, you can indeed do this.



                                    However, you need to tell Apache which handler to use for the folders containing your PHP4 application.



                                    The normal way to make php4 run as cgi is:



                                    Add Handler php-script .php4
                                    Action php-script /cgi-bin/php4


                                    But this isn't quite what you want so we need to change to something like this:



                                    RemoveHandler .php 
                                    Add Handler php-script .php
                                    Action php-script /cgi-bin/php4


                                    You may need to add an ExecCGI option to the applications root folder too.



                                    I can't test that at the moment so there's a chance it wont work. As an alternative, you could put in a rewrite that changed all .php file requests to .php4



                                    Note that this is all dependent on having sufficient rights to make these changes either in a .htaccess file or in an apache conf file (which requires rights to restart the apache server).



                                    UPDATE: the more I think about my answer the less I think it will work. Checking the mod_php5 conf file, I can see that the handler is actually set against a mime type application/x-httpd-php so you'd have to adjust that as well I think.



                                    So maybe the rewrite is best.



                                    There is another possibility though. If you have access to the apache configuration files, you could empty /etc/apache/mods-available/php5.conf and move the contents into a site specific configuration. Then you could put a php4 specific configuration into another virtual host or even into a folder - though in that case, you'll probably need to include the php5 config in several places (for each application root folder on your web server).



                                    UPDATE 2: In fact, the answer to quesition 1 is also "yes", this is, in fact possible. You can run both by making use of suPHP. Though you should read about the possible limitations of running PHP this way.






                                    share|improve this answer















                                    For the first question, I don't believe this is wise even if possible - which it may be, I don't know anyone who has tried it.



                                    For the second question, you can indeed do this.



                                    However, you need to tell Apache which handler to use for the folders containing your PHP4 application.



                                    The normal way to make php4 run as cgi is:



                                    Add Handler php-script .php4
                                    Action php-script /cgi-bin/php4


                                    But this isn't quite what you want so we need to change to something like this:



                                    RemoveHandler .php 
                                    Add Handler php-script .php
                                    Action php-script /cgi-bin/php4


                                    You may need to add an ExecCGI option to the applications root folder too.



                                    I can't test that at the moment so there's a chance it wont work. As an alternative, you could put in a rewrite that changed all .php file requests to .php4



                                    Note that this is all dependent on having sufficient rights to make these changes either in a .htaccess file or in an apache conf file (which requires rights to restart the apache server).



                                    UPDATE: the more I think about my answer the less I think it will work. Checking the mod_php5 conf file, I can see that the handler is actually set against a mime type application/x-httpd-php so you'd have to adjust that as well I think.



                                    So maybe the rewrite is best.



                                    There is another possibility though. If you have access to the apache configuration files, you could empty /etc/apache/mods-available/php5.conf and move the contents into a site specific configuration. Then you could put a php4 specific configuration into another virtual host or even into a folder - though in that case, you'll probably need to include the php5 config in several places (for each application root folder on your web server).



                                    UPDATE 2: In fact, the answer to quesition 1 is also "yes", this is, in fact possible. You can run both by making use of suPHP. Though you should read about the possible limitations of running PHP this way.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Jul 17 '12 at 20:08

























                                    answered Jul 17 '12 at 19:37









                                    Julian KnightJulian Knight

                                    1,4201018




                                    1,4201018






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f164783%2finstalling-php4-in-a-php5-environment%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                        Mangá

                                        Eduardo VII do Reino Unido