Compiling a new php installation

Hey, I’ve tried to follow the instructions in the wiki to compile my own php installation so I can set some things myself (, specifically, I need zip and rar functionality (I need to be able to check the contents, add new files to the archives, and compress uncompressed files), and I need a 20 megabyte upload limit, not 7. I cannot, however, get this to work, I have followed the instructions to the letter and it just does not work. Can anyone please help me with this, the “error” I seem to be getting is toward the end where I have to paste the code, then hit esc and then type :wq, well, I can paste it just fine, but when I hit esc it does nothing, it doesn’t close the file, so I just tried continuing, hitting esc then typing :wq, then closing the connection, then opening it up and continuing the instructions, but I can’t do the chmod +x installscript step, it says the file does not exist, but when I try to do vim installscript again, it says that a file named installscript.swp already exists. Am I doing something wrong?

Yep. You are having trouble operating vim (which is an editor). I just reviewed the instructions, and they do work if executed as instructed.

You only made it worse when you decided to proceed anyway when you didn’t understand / get the expected response from the editor when you hit ESC, and then closed the “connection”.

I assume by this that you mean you terminated the ssh connection to the shell, with vim still having installscript" still open for editing - which left a .swp file there “stranded”, creating problems when you try to re-edit that same filename.

A couple of suggestions:

  1. If you are gonna learn to do all this, unless you have a very good reason (such as your script just will not work with PHP5, and you can’t make it work by updating it to work with PHP5), don’t install a custom PHP4 - install PHP5 instead.

  2. If vim is giving you grief, don’t use it. - instead of creating the installscript file with vim, use pico, or joe, as shell editors instead. They are generally much more easily managed by users not familiar with the shell than either vi or vim.

  3. If you read the instructions carefully, you will realize that all steps 2, 3, and 4 accomplish is to get a copy of the appropriately modified (3rd line changed, case sensitive, to that of your domain) into the appropriate directory of your user space - there are lots of ways to do this, almost all of them easier than using vim, if you don’t understand how to use vim (IMHO). See my suggestion 2, or do it in any “pure text” editor (not a wordprocessor) on your own computer and ftp it up into the directory. You will want to use an editor that saves the file with *nix line-endings, or run a conversion program either on your own computer or via the shell to convert the line endings as needed (you did not say what OS you are using, and the conversions needed are dependent on that).

That said, if you want to follow the directions in the wiki exactly for creating the installscript file, you can also just carefully re-read the instructions, and try again, after you clean up the messed up .swp file and read up a bit on the use of vim. At the shell prompt type:

man vim (the means the “Enter” key-don’t actually type that part :wink: )

to read through the documentation for vim (until you understand what the ESC, :wq does) or google for a tutorial on the use of vim. You might want to even play around using a file named “testvim” or something else until you can get steps 2-4 to work for you.

To get rid of the .swp file that is keeping you from “trying again” with the instructions, at the shell prompt type

rm installscript.swp

That should put you back in shape to try again - but again I recommend that you consider using a different editor / method for getting the modified installscript file into the directory, and that you consider using PHP5 instead.


I actually could upgrade the script that I am using, but when I changed to using php5, my site practically broke, I am using a lot of mysql functions, on a LOT of pages, and they seem to not work in php5, otherwise I would use php5. It would take a while to go through and update everything. That being said, I still do not understand, I typed “vim installscript”, changed the third line of the code, hit “i” for insert mode, pasted the code, then hit esc and it did nothing. I am using putty from the windows command prompt, my OS is, obviously, Windows XP.

All this being said, when this is installed, will I be able to change the defualt upload_max_filesize from 7 to 20 megs? That, and having zip and rar functionality are really the only reasons I am doing this, but it is required for a project.

Thank you for your help, but I’m afraid I’ll still need a little more.

MySQL functions themselves should not present any problems between PHP versions, but the use of variables in those functions may very well be a problem, particularly if you are relying on register_globals being on and using those variables :wink: Saying “my site practically broke” isn’t very helpful; posting some of the error messages would be - it may well be that a few re-defined variables, the use of different variable names, or other simple fix would eliminate the majority of your problems.

When you hit the ESC key in vim it might appear that it “did nothing”, but that is not true - you just didn’t notice what it did - it signaled the vim editor to expect another action. Did you review the vim manual as I suggested, or review a vim tutorial? (actually, I guess you didn’t, given the time of your response :wink: ). The “expected action” is the entry of the “:” (command follows), and the w (which means “write the buffer”), and the “q” (which means “quit”) - all of which you would know if you rtfm as suggested.

I can’t tell you what you will see on your screen, as I don’t run putty under windows from the command line (I run it as a windows program, which then opens a terminal window on my machine, displays the shell terminal and provides terminal emulation).

Again, why are you torturing yourself with vim? I’ve described several easier ways for you to create that file - if you want to use vim, it will work, but you have to do it correctly and completely exactly as detailed in the article.

That will depend entirely on whether you have done it correctly, and if you properly manipulate the .htaccess file to use your installation, and if you modify the php.ini correctly to make the change. The article warned you: The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.

Frankly, if you are having this much trouble using vim to get the installscript on the server, I don’t think you ought to be messing with it.

You can much more easily change the max_file_upload_size by just using a modified php.ini file (also in the wiki) than by installing a custom PHP. Either way , understand that if you bork it up, support will not sort it out for you.

As zlib is one of the packages in the installscript, I think it will give you the zip functions - I don’t know about rar (I never use it).

If you have a specific question, that indicates you have read the man pages and maybe a tutorial or two, and you have an additional question, feel free to post it and I’ll try to help again - but at this point I’m concerned that you are getting yourself into a mess, and I don’t really want to encourage that. I think you are better off re-evaluating why your script(s) “practically broke” your site under PHP 5 than you are just assuming a custom PHP4 installation will fix things - from what I have read so far in this thread, I can almost guarantee that it will not.

Also, simply installing a custom PHP4 per that wiki article will do nothing toward changing your allowable file upload size - that’s a function of a php.ini setting, l and you have not even addressed that yet.


Well…ok then, I read an article about using a custom php.ini file, some of it made sense, but some of it seemed so vague, I understand that this is for advanced users, but I need this.

When I say “practically broke” I mean that a lot of my mysql queries stopped working, none (that I know of) depend on globals, they just stopped working. It was mostly inserts that stopped working, and I never got an error message, it just didn’t work. There were a few select queries that didn’t work either on my news pages, I don’t know why, they just didn’t, so I switched back.

If someone could just give me simple instructions on what to do to change the upload_max_filesize from 7M to 20M, I will be happy.

Finally, I see that zlib version 1.2.2 is installed and support is enabled, However, since I have php 4, I require ZZIPlib to be installed, and not zlib. It is not absolutely imperative that I be able to upload zip files, I can stick with the two base formats that I want to be able to upload, since I have a library that can put them into a zip archive, but it would be nice to allow people to upload in zip or rar formats.

And thank you again for helping out someone (who seems to be a complete noob.) I’m not a noob really, I just never really needed to know ssh, so I didn’t, I’m quite good at php.

It does not get any easier than this:

This article, as published, set a 100MB upload_max_filesize - you can modify it as needed if all you need is 20 MB.

Thoroughly tested, it works.


Well I followed those instructions, and also some that elaborated a bit here on the forums, created a file named (minus the quotes) “php_update” in I chmodded that file, ran it, it gave me this error:

: command not found2:
: command not found5:
: command not found8:
: No such file or directory./

and it generated these weird copies of php.ini and php.cgi, and now I cannot delete those two files to start over. I’m sorry, I’m not being stubborn. This is what I did:

I opened shell in command prompt by using putty’s plink, I typed my username and password, I then typed:

mkdir ~/

after which I verified that a folder named cgi-bin was on the server at, and it was there. I then opened notepad and pasted this code:



cp /usr/local/bin/php "$CGIFILE"
cp /etc/php/php.ini “$INIFILE”

perl -p -i -e ‘
s/.post_max_size./post_max_size = 100M/;
s/.upload_max_filesize./upload_max_filesize = 100M/;
’ “$INIFILE”[/quote]
And changed it to:



cp /usr/local/bin/php "$CGIFILE"
cp /etc/php/php.ini “$INIFILE”

perl -p -i -e ‘
s/.post_max_size./post_max_size = 25M/;
s/.upload_max_filesize./upload_max_filesize = 25M/;
’ “$INIFILE”[/quote]
Saved it as “php_update” (no extension) and uploaded it to cgi-bin, I was located, at that moment, in my site directory (/ and I typed chmod x php_update…I got an error, that that file didn’t exist, so I navigated to the cgi-bin directory in the shell window and typed chmod x php_update, there was no error, so I typed ./php_update, and I get the error I put above. I checked in my cgi-bin folder and there were three files:


When I tried to download php.ini to my desktop from ftp, it would not let me, saying the file did not exist, but no matter how many times I refresh, it is still there in the folder. I opened net2ftp and tried to view it through there, it says that it does not exist, but I can see it right there. When I tried to delete the entire folder, it says that it deleted php_update successfully, but not php.cgi or php.ini. I have no clue what I broke, but it doesn’t look good.

There, I outlined exactly what I did, in order, in full detail, is there something I did wrong?

Well, you didn’t follow the instructions. :wink:

Per your description of what you did, you went straight to the “update” step, and completely skipped the first step after creating the directory, which is as follows:

[quote]Create a script to retrieve the latest copy of php.cgi and php.ini

Make a file in ~/ called containing the following, where 100M contains whatever file size limit you like, and [your website directory] is appropriately substituted.

For PHP4:

CGIFILE="$HOME/[your website directory]/cgi-bin/php.cgi"
INIFILE="$HOME/[your website directory]/cgi-bin/php.ini"
rsync -a /dh/cgi-system/php.cgi “$CGIFILE”


cp /etc/php/cgi/php.ini “$INIFILE”

perl -p -i -e ‘
s/.post_max_size./post_max_size = 100M/;
s/.upload_max_filesize./upload_max_filesize = 100M/;
’ “$INIFILE”[/quote]
You omitted this step completely, and if you look at the code, you will see that was the source of the error messages you got; since you never copied the original DH php.ini file from it’s default location into your cgi-bin before running the “update” script (which is actually a later step) the perl instructions could not be properly executed - the error messages explain that. (also note that these scripts shold not be placed in the CGI bin - Make a file in ~/ called - the php-update script should be in the same location, not in cgi-bin)

I warned you that you needed to follow the directions - and you didn’t even make it past the second instruction (sigh).

It should have been in your ~/ directory

because you uploaded it to the wrong place (cgi-bin).

From there, one error compounded with the next and the whole thing got borked.

Note that you should never have even created (it does have a file type if you follow the directions) until after you had sucessfully created and executed, configured your domain as instructed, and tested to see that it worked. Only then do you create, which you should run weekly, or so, bia a cron job (though if everything else was done correctly in the article you can run it manually instead.


Use a real FTP client, or the shell, to delete everything you can out of cgi-bin (even the whole directory if you can). There is no reason, if you have told me everything, that you should not be able to delete the php.cgi, php.ini, and update-php files from that directory.

Start over following the directions in the article. If you get creative, and try to modify the process, unless you understand what is happening with the bash and perl scripts, you are likely to fail again; if you follow the instructions (stopping when you don’t understand something and googling it, or asking here, rather than charging ahead in some other way that may have effects you don’t understand), you will succeed.

The short version of the process you are trying to accomplish, via these scripts, goes something like this:

  1. Get copies of DH default php.cgi and php.ini files and store them in your own space in cgi-bin
  2. Modify (via the perl sections of the script) that php.ini to change the parameter you want to modify
  3. Install a crom job to do this weekly so that you will stay current with DH’s installation of PHP4 or PHP5.

These two simple scripts, which only vary by one line, accomplish all of this in a few seconds - but you have to create them, place them in the right places, make them executable, and run them in the proper order for the process to work.


Ok, I appreciate that you are trying to help me, but please do not talk down to me, I am making an honest effort to learn here, the least you could do is talk to me like I am on a level playing field, I told you, I’m not trying to be stubborn, or seem stupid, I am a very intelligent person and I am a very fast learner, sometimes it just requires patience. And, for the record, I followed the instructions EXACTLY! Here:

These instructions never did do the first step, I’m sorry.

I’ll try to follow the instructions in the wiki to the letter and see what happens, hopefully everything will turn out ok.

Edit: ok, Here goes nothing, I tried the instructions there, and like I said, I cannot delete the cgi-bin folder from my server, becuase it says that php.ini and php.cgi do not exist, but the folder and the files are right there, so I cannot create a new cgi-bin folder either, becuase the shell complains that the file already exists. Is there anything I can do? I can rename the folder itself then ceate a new cgi-bin but honestly, I need to get rid of those two files, they will annow the crap out of me if they are there. I have tried using windows ftp,, and the shell to delete the files, all of them display the file, all of them say that the file does not exist when I try to delete it.

I got it! You go then: pick any link/instruction you feel like following (irrespective of the link I referred you to when you asked for “simple” instructions earlier in the thread) and you go with that - or not, or whatever.

I apologize profusely if taking the time to point out precisely why you were having problems is “talking down to you”. Since we are on a “level playing field”, you really don’t need any more of my help, being a “a very intelligent person” and “a very fast learner” , you shouldn’t really need anyone’s help on this at all - maybe you are just having a bad day. :wink:

Obviously, I could (and probably should) have found a more useful way to have spent the time I spent trying to help you on this (like, say, spending the better part of an hour picking fly foo out of pepper). Actually, I should have seen this coming when you couldn’t be bothered to work your way through why you couldn’t operate vim - I never learn. :frowning:

Good luck. I’m sure that you will eventually accomplish something.


Although rlparker somewhat suggested finding an alternative method to get what you want, I really suggest that you find a completely alternative method to doing what you want.

My reason why:

rlparker already pointed out where you went wrong, what you did wrong, and what you could do to fix it.
You refuse to accept that, and I personally wouldn’t work with you anymore either.
However, let’s see if we can point you in at least the right direction…

It would seem you don’t have any grasp on how to work in the unix shell, which is by NO means unusual for a beginner. So given that fact, I strongly recommend reviewing this article in the wiki first:

As you said, you don’t understand why the shell (webftp/etc) is saying php.ini and php.cgi don’t exist. I’m not really sure if that’s the case, but let’s try some things first.
Login to your shell via putty and issue something similar to the following command: cd /home/yourusername/

If that command works, which is moving you from your home directory (/home/yourusername) to your domain’s cgi-bin directory which we’ll assume was already created, then issue the following command afterwards: ls -l

This command should list the contents of the cgi-bin directory. If you don’t see php.ini and php.cgi listed after running it, then you didn’t complete one of the steps in the wiki as you claim you did. If you do see them there, they should be owned by your user.
The output should look something similar to this:

Your’s probably won’t have all the fancy coloring, but the files should be owned by your user and in a group that looks something similar to the one I have listed.
If it’s not owned by you, then you’ll need to file a ticket and explain this to DH support. If it is owned by you… then again, you’re doing something wrong. I’m not sure what, because deleting it via the webftp/normal ftp should work just fine. That itself is quite puzzling…

Good luck either way :slight_smile:

Thank you for your reply, and rlparker, I was not implying that I know more than you, but the constant use of these was making me feel like you were degrading me, it was just kinda…getting me a little down, I appreciate that you were trying to help me.

I use shell from command prompt, using putty (I copied the files into C:\WINDOWS\system32 and I call it up by typing plink It works the same I think. Anyways, the files were there, when I typed dir when inside the cgi-bin folder in shell, it showed two files, php.cgi\r\r and php.ini\r\r, when I tried rm php.cgi\r\r or rm php.cgi they said the file was not there, when I tried deleting them from ftp, or, or a program called Faststeam NETfile, none worked, they all said that the file was not there, but it was there, plain as day, I could see it. Anyways, I sent a request to dreamhost and they got rin of it, somehow, and I deleted my cgi-bin file. I have the, the contents of which are:

rsync -a /dh/cgi-system/php.cgi “$CGIFILE”


cp /etc/php/cgi/php.ini “$INIFILE”

perl -p -i -e ‘
s/.post_max_size./post_max_size = 25M/;
s/.upload_max_filesize./upload_max_filesize = 25M/;
’ “$INIFILE”[/quote]

rsync -a /dh/cgi-system/php.cgi “$CGIFILE”

perl -p -i -e ‘
s/.post_max_size./post_max_size = 25M/;
s/.upload_max_filesize./upload_max_filesize = 25M/;
’ “$INIFILE”[/quote]
I will do this:

in shell, I will type:

mkdir ~/

Then I will upload to ~/ (the root, I’m assuming,) and I will, in shell, type:

chmod +x

Then I will type:


If there is the Bad interpreter error, I will type:


If there are no errors, I will add:

Options +ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

To my .htaccess file, I will then upload the previously mentioned file and convert it to unix mode like this:


I will then set up a cron job to update the files weekly by typing:

crontab -e

And typing:

@weekly /home/halo2freeek/

In the text editor that comes up.

If I do these, to the letter, will this work?

And again, thank you for your support, I couldn’t have gotten this for without you guys.

AHHHH!!! Ok, I’m sorry for the double post, I did these instructions, exactly how I wrote them, ok, so when I’m done, I checked my phpinfo page and it said that post_max_size and upload_max_filesize are 40M, good, so I tried to upload a 9.2 meg file, and it says “Internet Explorer cannot display the webpage” blah blah. What did I do wrong? I tried twice.

I also tried a 7.43 meg file, bigger than the dreamhost max of 7 megs, and it did work, so something is going on.

Nope, nothings wrong. You’re just encountering the standard memory limit that PHP has also set.

So in your php.ini file, you should probably change the ‘memory_limit’ value to 5-10megs higher than your upload_max_filesize value. :slight_smile:

I assume that all I have to do is download the php.inin that I have stored now on my server, and then change the value manually, but how would I go about updating my file to also reflect these changes?

edit: memory_limit is set to 90M, I set post_max_size and upload_max_filesize to 40, do I have to clear the memory?

Good luck with your custom PHP setup.
I’m done helping you, as the answers to your questions you can figure out yourself. Google and the wiki work wonders :slight_smile: