Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having an application which is installed in multiple places. I would like to create a script which performs the upgrade of the application. Both mysql tables and the actual PHP-application needs to be upgraded.

Since this is the first time I'm doing this I am wondering which way I should go; creating the script in PHP or in Bash? What's the pros and cons for the two alternatives?

In the long run, it may be the case that one can do the upgrade for the application from the actual application, but in this first step I will run it from the shell.

I am using linux (CentOS), apache, mysql


Since I am going to inject information from a database into the script, I go with PHP.

Later on this script may be quite competent so I think it is easier to do it in PHP then Bash.

share|improve this question

closed as not constructive by Michael Hampton, John Gardeniers, Magellan, Ward, MadHatter Nov 10 '12 at 8:13

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
they should both handle this without issue. i guess my question to you is which language do you know better? maybe something to consider is bash is native and php is not. kinda feel like this is a is vim or nano the better editor question. –  austin Aug 24 '12 at 11:36
    
Well I know PHP better but I can solve it in bash as well so I don't think that matters in this case. But good point though! (nano btw... :) ) –  Nicsoft Aug 24 '12 at 11:47
add comment

3 Answers

i suggest you to use a tool like Rex or Capistrano for those tasks. With those tools you can write deployment instructions that can be also used by others.

share|improve this answer
    
Thanks, I was thinking about finding this kind of tool to do this. But I don't see good enough value (or I don't understand the value of such kind of tool). I assume one have to make a script for upgrading one instance and then the tool will help out upgrading all instances. It seems to provide little value because once I have created the script for one instance it's a tiny job to use it for other instance (just change one argument to the script). Or am I missing something important here? –  Nicsoft Aug 24 '12 at 9:47
    
@Nicsoft thats right. but when time goes by your script might grow and you have to extend it with features that might be already implemented by those tools. and then you have to take care that your script works for example with distribution upgrades, or if you need to deploy your scripts on other platforms. –  jfried Aug 24 '12 at 11:16
    
Thanks again. This may certainly be of interest in the future when number of instances and live-versions of the application grow. For the moment, I think I go without it in order to skip time needed in order to start using a new tool. –  Nicsoft Aug 24 '12 at 11:29
add comment

You should really supply the information about what kind of upgrade you are going to do in PHP. In general, it will be really easy to manage applications on multiple servers using bash by issuing direct SSH commands.

For example, if you're sure about doing SVN up in a directory, you can use something like this

ssh user@server.com 'svn up /path/to/php/app'

And to update the MySQL tables, you can use the MySQL cli client

ssh user@server.com 'mysql -e "[SQL STATEMENT]"'
share|improve this answer
    
Thanks! I think my question was related to which way is best to us, not HOW to do it. And you asked "what kind of upgrade", perhaps there are more things one can do while upgrading than I thought about, but upgrading php means upgrading existing files or adding new ones to the application directory and for MySQL it's about altering tables or inserting new values. –  Nicsoft Aug 24 '12 at 9:52
add comment

As an alternative you can use Chef or Puppet for such stuff. With these you can easily deploy from a central node based on the cookbooks(for chef) or recipes(for puppet) that you write.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.