Recently I went looking for a solution for backing up from a Plesk server to S3: what I settled on was surprisingly simple.
I started with a simple list of criteria, but as I went looking for a solution, and as I continued to find no good ones, my list got longer. I have a tendency to be quite OK with the bare bones if I'm going to be using an existing system, but if I have to build it myself, I'm normally happy to add more features.
I started with basically "I want to be able to backup files and databases", but the solution I ended up with also gave me the following features:
- backup multiple domains
- along with files and databases, backup the actual domain configuration and mail if required
- rotate backups automatically
- define the frequency of backups and the number of backups to keep before rotating
- open source
- a simple interface right in Plesk
So what did I do?
I don't know, really, if this is a super smart way to do it, or just a cop-out, but basically I realised that hey, the Plesk backup manager already let's us do all of the above... except for the S3 part. All that I ended up doing was installing s3cmd from http://s3tools.org and setting it up to do the syncing to S3, looking at the location on the server that Plesk puts it backups.
So basically, users (or I) define backup rules for each domain as needed (via the Plesk UI) and then s3cmd runs with the sync option once a day.
With s3cmd located in my /root/cli-tools directory, and assuming s3://example.com is the name of the bucket I will use, the actual cron tab entry I use is as simple as:
cd /var/lib/psa/dumps; /root/cli-tools/s3/s3cmd -c /root/cli-tools/s3/s3cfg --delete-removed -H --no-progress sync domains s3://example.com/backups
UPDATE: as per a comment by Rutger below, you may actually want to use:
cd /var/lib/psa/dumps;
/root/cli-tools/s3/s3cmd -c /root/cli-tools/s3/s3cfg --delete-removed -H
--no-progress sync clients s3://example.com/backups
instead of, or possibly in association with, the above line.
When I commission a new Plesk server, I just copy the s3cmd directory over, create a new bucket and I'm done.
The only downsides I see, really, are that if I wanted to just have a single rule for all of the domains, I couldn't. Also, I'm assuming that all of the backups have been run when the cron job runs once a day. Not that that matters too much, as I could just bump the cron job up to hourly if I liked and I wouldn't see much difference.
I think the biggest negative to this approach is that I'm pushing backups explicitly even if what has been backed up actually hasn't changed. That is to say, if Plesk does a backup everyday, then I push a new backup every day... even if nothing has changed since the last backup.
Anyway, I hope this helps someone as for me it was completely obvious once I realised it, but it took me an embarrassingly long time to get to it.
Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts
Monday, June 10, 2013
Wednesday, February 13, 2013
A Friendly Reminder About Something I'd Already Paid For
A few weeks ago I purchased a product online called Texture Packer Pro. The purchase went completely smoothly and without a hitch.
Imagine my surprise, then, when I received an email about my purchase the other day. To be honest, I was a little concerned.
Opening the email was a pleasant surprise. Simply put, the email was a timely reminder about the fact that I should expect a certain payee on my credit card statement, telling me how much it was for, who the payee was and, especially, what the purchase was for.
Such a simple little thing, at the right moment, and there will no longer even be a second of doubt when I look at my statement. I loved it, and intend to do a similar thing as soon as I start selling online, too.
And for what it's worth, if you're looking for a tool to resize and place images into a texture map (and let's face it, who isn't looking for one?) I can totally recommend it!
Imagine my surprise, then, when I received an email about my purchase the other day. To be honest, I was a little concerned.
Opening the email was a pleasant surprise. Simply put, the email was a timely reminder about the fact that I should expect a certain payee on my credit card statement, telling me how much it was for, who the payee was and, especially, what the purchase was for.
Such a simple little thing, at the right moment, and there will no longer even be a second of doubt when I look at my statement. I loved it, and intend to do a similar thing as soon as I start selling online, too.
And for what it's worth, if you're looking for a tool to resize and place images into a texture map (and let's face it, who isn't looking for one?) I can totally recommend it!
Monday, February 6, 2012
Setting Up Percona, Galera and SphinxSE
In the last project I worked on, I had a chance to play with what I would consider improvements to the typical MySQL install that most of us use. There were three aspects to what we were looking for:
As far as the MySQL fork is concerned: there are a number of projects that are based off of MySQL that have either improved or replaced the main InnoDB storage engine. These generally provide faster services than the traditional MySQL but some also add some extra features. For this, we wanted to try the Percona Server.
Multimaster replication in MySQL generally is a hassle to setup: not so much on the 'creation' side but on the redundancy side. It's pretty easy to set it up to run, but setting it up to fail 'correctly' generally involves other systems. We had heard of Galera and figured that this might be a good time to try it. Galera is basically a system that links in with the MySQL server/s, but at the same time talks amongst itself to ensure that all of the servers are in sync. If a new server comes up or an old server goes down, Galera is there talking, making sure that everything is still organised correctly.
Sphinx is basically a super fast full text searching service: it is much faster than, and more capable than, the traditional MySQL text searches. While Sphinx has a couple of different ways it can be interacted with, the Sphinx Storage Engine intrigued us. SphinxSE allows you to essentially tunnel through from a 'normal' MySQL table right through to Sphinx allowing you to do the Sphinx searching as 'just another' INNER JOIN in your query.
So with that in mind, we went searching for a solution that was already made :)
Unfortunately we weren't able to find anything complete... they were either missing the Galera component or the SphinxSE part.
So, for anyone interested in setting something like this up themselves, I've put together a quick little hacky guide to try. Hopefully everything makes as much sense as it can. If you read the instructions you'll see that we are using some custom (and possibly strange) directories for things like where the Sphinx data will go, as well as the MySQL/Percona data/configuration etc. You will also notice that there's a point where you download a patch file to apply to Sphinx: this is based on an older patch file for Percona that was aimed at an older version of Sphinx. It just makes sure that the SE will build.
Some final notes: I did all of this a while ago and so some things have changed since then. Galera has been updated since I wrote these instructions, as has Sphinx. I also just saw that Percona is expecting a beta release at the end of February 2012 of their 'Percona XtraDB Cluster' server which, from what I understand, is Percona with Galera built into it. So with that in mind, this is really just some notes on how to get things working if you're super keen on at least playing with this stuff. Oh yeah, and these notes are all based off of Ubuntu 11.10 Server. It assumes that you haven't already installed MySQL, as that gets to be a problem (as you're basically going to be trying to replace it). And with that in mind, here goes...
Be nice to yourself: become root...
Update and get some things you'll need...
Make your newly configured application:
Now, we enable Galera...
Edit
Enable the WSREP user so that it can read from and write to the databases:
Finally, run MySQL from the command line to get the CLI and run:
- Naturally we were looking for a system that had the reliability of MySQL, but at the same time we were itching to try some of the forks that have evolved from that codebase.
- We were hoping to get a better multimaster redundancy system setup than the traditional process.
- We were hoping to get SphinxSE involved.
As far as the MySQL fork is concerned: there are a number of projects that are based off of MySQL that have either improved or replaced the main InnoDB storage engine. These generally provide faster services than the traditional MySQL but some also add some extra features. For this, we wanted to try the Percona Server.
Multimaster replication in MySQL generally is a hassle to setup: not so much on the 'creation' side but on the redundancy side. It's pretty easy to set it up to run, but setting it up to fail 'correctly' generally involves other systems. We had heard of Galera and figured that this might be a good time to try it. Galera is basically a system that links in with the MySQL server/s, but at the same time talks amongst itself to ensure that all of the servers are in sync. If a new server comes up or an old server goes down, Galera is there talking, making sure that everything is still organised correctly.
Sphinx is basically a super fast full text searching service: it is much faster than, and more capable than, the traditional MySQL text searches. While Sphinx has a couple of different ways it can be interacted with, the Sphinx Storage Engine intrigued us. SphinxSE allows you to essentially tunnel through from a 'normal' MySQL table right through to Sphinx allowing you to do the Sphinx searching as 'just another' INNER JOIN in your query.
So with that in mind, we went searching for a solution that was already made :)
Unfortunately we weren't able to find anything complete... they were either missing the Galera component or the SphinxSE part.
So, for anyone interested in setting something like this up themselves, I've put together a quick little hacky guide to try. Hopefully everything makes as much sense as it can. If you read the instructions you'll see that we are using some custom (and possibly strange) directories for things like where the Sphinx data will go, as well as the MySQL/Percona data/configuration etc. You will also notice that there's a point where you download a patch file to apply to Sphinx: this is based on an older patch file for Percona that was aimed at an older version of Sphinx. It just makes sure that the SE will build.
Some final notes: I did all of this a while ago and so some things have changed since then. Galera has been updated since I wrote these instructions, as has Sphinx. I also just saw that Percona is expecting a beta release at the end of February 2012 of their 'Percona XtraDB Cluster' server which, from what I understand, is Percona with Galera built into it. So with that in mind, this is really just some notes on how to get things working if you're super keen on at least playing with this stuff. Oh yeah, and these notes are all based off of Ubuntu 11.10 Server. It assumes that you haven't already installed MySQL, as that gets to be a problem (as you're basically going to be trying to replace it). And with that in mind, here goes...
Be nice to yourself: become root...
sudo -sMake sure that for all of the main repositories (at least) you not only have the deb repos, but also the deb-src repos. This can be checked in
/etc/apt/sources.list.Update and get some things you'll need...
apt-get update apt-get install dpkg-dev bzr cmake cmake-curses-gui chkconfig libssl0.9.8 apt-get build-dep mysql-serverCreate a MySQL user: this would normally be done by the MySQL installation.
groupadd mysql useradd -g mysql mysqlGet some directories ready.
mkdir /etc/mysql mkdir /etc/mysql/conf.d mkdir /var/lib/mysql mkdir /var/lib/mysql/data chown -R mysql:mysql /etc/mysql chown -R mysql:mysql /etc/mysql/conf.d chown -R mysql:mysql /var/lib/mysql mkdir /etc/sphinx mkdir /var/lib/sphinx mkdir /var/lib/sphinx/log mkdir /var/lib/sphinx/dataStart getting source...
cd /usr/local/src wget http://launchpad.net/galera/1.x/21.1.0/+download/galera-21.1.0-amd64.deb dpkg -i galera-21.1.0-amd64.deb bzr branch lp:~vadim-tk/percona-server/percona-5.5.15-galera wget http://www.sphinxsearch.com/files/sphinx-2.0.1-beta.tar.gz tar -zxvf sphinx-2.0.1-beta.tar.gz wget http://files.codefromaway.net/sphinx-2.0.1-beta-to-sphinx-2.0.1-beta-5.5.15.patch cd sphinx-2.0.1-beta patch -p1 < ../sphinx-2.0.1-beta-to-sphinx-2.0.1-beta-5.5.15.patch cp -R mysqlse ../percona-5.5.15-galera/storageBuild and install Percona
cd ../percona-5.5.15-galera ccmake .You will be given a UI at this point... press 'c' for configure, then 'e' to exit help then finally 't' to toggle to advanced mode. Now, scroll through the list and edit the following values (setting them to the values listed):
CMAKE_INSTALL_PREFIX /usr/bin/mysql INSTALL_MYSQLDATADIR /var/lib/mysql/data MYSQL_DATADIR /var/lib/mysql/data SYSCONFDIR /etc/mysql WITH_READLINE ON WITH_WSREP ONNow press 'c' for configure, 'e' to exit help and then 'g' to finally generate the configuration file.
Make your newly configured application:
make make test make installBuild and install Sphinx
cd /usr/local/src/sphinx-2.0.1-beta ./configure --prefix=/usr/bin/sphinx --sysconfdir=/etc/sphinx --libdir=/usr/libs --datarootdir=/var/lib/sphinx --with-mysql --with-mysql-includes=/usr/bin/mysql/include --with-mysql-libs=/usr/bin/mysql/lib make installPrepare some shared libraries. Create
/etc/ld.so.conf.d/mysql.conf and then:
echo "/usr/bin/mysql/lib" > /etc/ld.so.conf.d/mysql.conf ldconfigStart getting Percona ready by copying configuration files as well as the init script for the service:
cd /usr/bin/mysql cp ./support-files/my-medium.cnf /etc/mysql/my.cnf cp ./support-files/wsrep.cnf /etc/mysql/conf.d/wsrep.cnf cp ./support-files/mysql.server /etc/init.dEdit the
/etc/mysql/conf.d/wsrep.cnf file and set the following values:wsrep_provider=/usr/lib/galera/libgalera_smm.so wsrep_cluster_address="gcomm://" wsrep_sst_auth=wsrep_sst:some_random_passwordNOTE: the wsrep_cluster_address line is initially commented out! you have to remove the commenting hash AS WELL as make the gcomm change... Also note that the 'some_random_password' will get used towards the end of this whole process, so remember it!
Now, we enable Galera...
Edit
/etc/mysql/my.cnf: add the following lines to the end of the file:binlog_format=row !includedir /etc/mysql/conf.dEdit
/etc/bash.bashrc and add the following lines:PATH=$PATH:/usr/bin/mysql/bin:/usr/bin/sphinx/bin export PATHReload bashrc so that the MySQL binaries and Sphinx binaries are now in your path:
source /etc/bash.bashrc source ~/.bashrcPrepare the MySQL database and finally start the service!
./scripts/mysql_install_db --basedir=/usr/bin/mysql --user=mysql --datadir=/var/lib/mysql/data /etc/init.d/mysql.server startUse the following two lines to get MySQL to load on startup:
chkconfig --list mysql.server chkconfig mysql.server on --level 2,3,4,5Restart the server now, just to be sure :)
Enable the WSREP user so that it can read from and write to the databases:
mysql -u root -e "SET wsrep_on=OFF; DELETE FROM mysql.user WHERE user='';" mysql -u root -e "SET wsrep_on=OFF; GRANT ALL ON *.* TO wsrep_sst@'%' IDENTIFIED BY 'some_random_password';"'some_random_password' is what we remembered back up towards the middle of this process.
Finally, run MySQL from the command line to get the CLI and run:
INSTALL PLUGIN sphinx SONAME 'ha_sphinx.so';You should now have Percona up and running with Galera replication and SphinxSE on the side. Have fun... I hope it helps *someone*!
Wednesday, December 28, 2011
Is Google (and mod_pagespeed) the Poor Man's CDN?
EDIT: As per the comment by barryhunter below, this whole article is bogus. The CDN stuff was something I found under the 'Page Speed' heading but is related to Page Speed Service, as opposed to mod_pagespeed itself... Sorry for the confusion.
Since it was available as a browser plugin, I've been intrigued by the Page Speed concepts that Google have promoted. There was just something about the entire project that I loved... the fact that people out there are so passionate about these ideas that they were writing code to help me better understand the problems my site was having... it's a great project.
Then when the Page Speed module for Apache was released, I was blown away. Automating the work that can be done, basically 'earning' a lot of the benefits of the Page Speed knowledge, simply by installing an extension to Apache... again, just fantastic.
But to be honest, lately, I've been ignoring it. We installed it on our servers, appreciated the work that it was doing for us and then we moved on.
Just recently, though, when trying to explain the concepts to a workmate, I had reason to look back at the site and read through the documentation again. Now admittedly I have not had any need for a content distribution network until recently. In fact, if it wasn't for a friend of mine I still would have no need for it. So I don't know if it is my 'new found knowledge' of CDNs, new changes to mod_pagespeed or a combination of both, but looking back over the documentation I found something really cool: mod_pagespeed has some 'proxying' options that will proxy your images, JS and CSS!
Basically by enabling these options, mod_pagespeed will rewrite your HTML so that the CSS, JS and images are 'proxied' through the Google network. That is to say, instead of requesting http://www.example.com/my.css, the rewritten HTML will have the browser request something like http://3-www-accel-pss.googleusercontent.com/www.example.com/my.css. These servers appear to be a CDN: that is to say, the browser is sent to the nearest server.
And the best thing? It's free! For now, at least.
So that was my little 'excitement' for the day. If you can't afford to pay for a CDN and you have enough control over your server, do yourself a favour: install mod_pagespeed and turn on the proxying features.
Since it was available as a browser plugin, I've been intrigued by the Page Speed concepts that Google have promoted. There was just something about the entire project that I loved... the fact that people out there are so passionate about these ideas that they were writing code to help me better understand the problems my site was having... it's a great project.
Then when the Page Speed module for Apache was released, I was blown away. Automating the work that can be done, basically 'earning' a lot of the benefits of the Page Speed knowledge, simply by installing an extension to Apache... again, just fantastic.
But to be honest, lately, I've been ignoring it. We installed it on our servers, appreciated the work that it was doing for us and then we moved on.
Just recently, though, when trying to explain the concepts to a workmate, I had reason to look back at the site and read through the documentation again. Now admittedly I have not had any need for a content distribution network until recently. In fact, if it wasn't for a friend of mine I still would have no need for it. So I don't know if it is my 'new found knowledge' of CDNs, new changes to mod_pagespeed or a combination of both, but looking back over the documentation I found something really cool: mod_pagespeed has some 'proxying' options that will proxy your images, JS and CSS!
Basically by enabling these options, mod_pagespeed will rewrite your HTML so that the CSS, JS and images are 'proxied' through the Google network. That is to say, instead of requesting http://www.example.com/my.css, the rewritten HTML will have the browser request something like http://3-www-accel-pss.googleusercontent.com/www.example.com/my.css. These servers appear to be a CDN: that is to say, the browser is sent to the nearest server.
And the best thing? It's free! For now, at least.
So that was my little 'excitement' for the day. If you can't afford to pay for a CDN and you have enough control over your server, do yourself a favour: install mod_pagespeed and turn on the proxying features.
Tuesday, October 19, 2010
Static Analysis with PHP CodeSniffer
PHP CodeSniffer is a great tool to have in your development
environment. Originally developed to ensure that your code matches your
coding standards, I think its strength is somewhere else...
If you take the time to read through some of the coding standards that ship with PHP CodeSniffer, you will find that some of them don't really relate to coding standards exactly. Some are more related to code analysis, and after a recent update to a project I was working on, I think that this is PHP CodeSniffer's real strength...
You may recall from an earlier post that one of the projects I was working on used an in house DB abstraction layer. For reasons that are probably obvious, we began porting our code to MDB2. It was a large codebase, with queries sprinkled throughout. Quickly we realised that search and replace was not going to cut it, as we needed to begin using a result set variable.
The original class used a single variable for the connection and the result set. That is to say, with the single variable you would connect to the database, make the query and then iterate over the result set. MDB2 is different (and in this regard, more like the basic MySQL functions in PHP) in that you have one variable for the connection, call the query on that connection and then store the return value into another variable (the result set). So in effect, you use one variable for some things (calling queries, getting error messages and so on) and another for iterating over the results. Our problem with porting was that our class used one variable for all of that, so we couldn't easily search and replace.
So what to do? Well naturally we could have looked everywhere for any instance where we made a connection, then ensured that the variable was used correctly, as were any variables returned from function calls. Or, we could have automated it.
So automate it I did.
I had been playing with PHP CodeSniffer anyway, and so I saw a great use for it here. Of course, it's really the tokeniser that we're taking advantage of, but PHPCS does a great job of providing us with extra features related to moving through the token list.
A couple of hours later, I had written the sniff. But what does it do? Well basically it looks for function calls that make a connection to the database. When it finds that, it looks back a little bit and determines the variable name that was being assigned to. We now know a variable that holds a DB connection, and with a little bit more magic, we can determine the scope that this variable is used in. Now look around in that scope, and ensure that when that variable gets used, it gets used in the right context. Let's go a bit deeper though... if the connection gets used in the right function, we know that the return value is a result set. Surely we can then iterate through it, doing the same work, testing that it gets used correctly?
And that's what I did. Because we were using MDB2, I even had more information... using reflection, I was able to determine return types of all sorts of functions and functions that existed on all sorts of classes. I could make sure that those variables were used correctly and that any functions called on those variables were valid for their class.
It was great, even if I do say so myself! In a couple of hours, I was able to test our entire codebase and ensure, recursively, that all of the variables that we were assigning to, passing as parameters, and calling functions on were being used in the right context.
And we found a heap of places where our attempts at porting went wrong. Which is what it's all about.
After that, I went nuts with static analysis. I started looking even at the queries that were being called and checking that when doing a SELECT COUNT, for example, that we used the queryOne function to just grab the value instead of returning it into an array to simply pull it out from $row[0].
I also wrote another sniff that ensured that when using references in a foreach loop, that we unset the by-reference variable before reusing it (so as to make sure we didn't accidentally overwrite part of the initial array).
I think using PHP CodeSniffer this way is awesome. It takes care of so much stuff and when adding in reflection on classes it's amazing what can be achieved in just a few lines of code.
I'd love to hear if you have ever solved a static analysis problem with PHP CodeSniffer!
If you take the time to read through some of the coding standards that ship with PHP CodeSniffer, you will find that some of them don't really relate to coding standards exactly. Some are more related to code analysis, and after a recent update to a project I was working on, I think that this is PHP CodeSniffer's real strength...
You may recall from an earlier post that one of the projects I was working on used an in house DB abstraction layer. For reasons that are probably obvious, we began porting our code to MDB2. It was a large codebase, with queries sprinkled throughout. Quickly we realised that search and replace was not going to cut it, as we needed to begin using a result set variable.
The original class used a single variable for the connection and the result set. That is to say, with the single variable you would connect to the database, make the query and then iterate over the result set. MDB2 is different (and in this regard, more like the basic MySQL functions in PHP) in that you have one variable for the connection, call the query on that connection and then store the return value into another variable (the result set). So in effect, you use one variable for some things (calling queries, getting error messages and so on) and another for iterating over the results. Our problem with porting was that our class used one variable for all of that, so we couldn't easily search and replace.
So what to do? Well naturally we could have looked everywhere for any instance where we made a connection, then ensured that the variable was used correctly, as were any variables returned from function calls. Or, we could have automated it.
So automate it I did.
I had been playing with PHP CodeSniffer anyway, and so I saw a great use for it here. Of course, it's really the tokeniser that we're taking advantage of, but PHPCS does a great job of providing us with extra features related to moving through the token list.
A couple of hours later, I had written the sniff. But what does it do? Well basically it looks for function calls that make a connection to the database. When it finds that, it looks back a little bit and determines the variable name that was being assigned to. We now know a variable that holds a DB connection, and with a little bit more magic, we can determine the scope that this variable is used in. Now look around in that scope, and ensure that when that variable gets used, it gets used in the right context. Let's go a bit deeper though... if the connection gets used in the right function, we know that the return value is a result set. Surely we can then iterate through it, doing the same work, testing that it gets used correctly?
And that's what I did. Because we were using MDB2, I even had more information... using reflection, I was able to determine return types of all sorts of functions and functions that existed on all sorts of classes. I could make sure that those variables were used correctly and that any functions called on those variables were valid for their class.
It was great, even if I do say so myself! In a couple of hours, I was able to test our entire codebase and ensure, recursively, that all of the variables that we were assigning to, passing as parameters, and calling functions on were being used in the right context.
And we found a heap of places where our attempts at porting went wrong. Which is what it's all about.
After that, I went nuts with static analysis. I started looking even at the queries that were being called and checking that when doing a SELECT COUNT, for example, that we used the queryOne function to just grab the value instead of returning it into an array to simply pull it out from $row[0].
I also wrote another sniff that ensured that when using references in a foreach loop, that we unset the by-reference variable before reusing it (so as to make sure we didn't accidentally overwrite part of the initial array).
I think using PHP CodeSniffer this way is awesome. It takes care of so much stuff and when adding in reflection on classes it's amazing what can be achieved in just a few lines of code.
I'd love to hear if you have ever solved a static analysis problem with PHP CodeSniffer!
Monday, November 30, 2009
Setting Up Redmine in A Shared Hosting Environment
Let's face it: providing issue tracking and a nice looking web interface to your code
is a must if you want to get your clients involved in your development
process.
Redmine is an awesome issue tracker that's written in Ruby on Rails: it's extremely pretty (which everyone loves) and has some fantastic plugins to integrate with all sorts of things, including your source control system (more on that some other time!) While Ruby is not a language that I'm familiar with, I have never been one to turn my back on a solution solely for the language that it was written in. To be perfectly honest, if I did this I probably never would have gotten into PHP in the first place!
Redmine is very similar to Trac (if you have any experience with it), except for the fact that it supports multiple projects. When I first saw Redmine I was working with a shared hosting service and had never deployed a Ruby application in my life. What follows is essentially a step-by-step process for setting this up in your own shared hosting environment. It discusses version 0.8.5, but mainly because that was the version that was available when I created my notes: I doubt newer versions are massively different to set up.
Prerequisites
Unfortunately there are a couple of prerequisites for you to get Redmine working with your hosting environment. Firstly, and probably most naturally, it needs to support Ruby on Rails applications. It also needs access to some sort of source control system: I have my installation linked to Subversion, but it does support a number of systems and so you should be able to get something working, at least. Finally, you need to have SSH access to your account. Luckily, my hosting company provided all three of these features with my account, so I was really lucky :)
Finally, there is the prerequisite that at the end of this process, you want to use a subdomain to host your Redmine installation. I have no doubt it's simple to set this up in a subdirectory instead, but the point is that this was my goal and this was what I did to get there.
Anyway, with that out of the way, let's get started...
Getting Started...
We start our process in the cPanel interface. Head into the database management area:
1) create a database for Redmine. As per the usual cPanel result, I called my database 'redmine' and ended up with a database named 'myusername_redmine'.
2) create a database user. Again, I named my 'redmine', which resulted in a user actually named 'myusername_redmine'.
3) give the new user full rights to the new database
4) in your domain management area, create a subdomain (I used code.mydomain.com, which resulted in a directory being created at ~/public_html/code)
5) in your Rails applications area, create a Rails application named 'redmine'
6) if the newly created application is already running, stop it
7) download the file redmine-0.8.5.tar.gz from http://rubyforge.org/frs/?group_id=1850
8) upload the redmine-0.8.5.tar.gz file to your home directory on the hosting server
Cracking the shell...
Open your SSH interface and keep going...
9) switch to the ~/etc/rails_apps/redmine directory
10) delete everything in the directory: rm -rf *
11) copy redmine-0.8.5.tar.gz from your home directory to ~/etc/rails_apps/redmine
12) extract the file: tar -zxvf redmine-0.8.5.tar.gz
13) switch into the redmine-0.8.5 directory and move everything to the parent directory: mv * ..
14) switch back to the parent directory and remove the now empty redmine-0.8.5 directory: rmdir redmine-0.8.5
15) copy the example database YML file: cp config/database.yml.example config/database.yml
16) open config/database.yml in your editor of choice
17) Find the section that looks like:
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password
and set the correct value for the 'database' line, the 'username' line and the 'password' line.
18) save the file and exit back to the command line
19) create the database structure: rake db:migrate RAILS_ENV="production"
20) add the default configuration data: rake redmine:load_default_data RAILS_ENV="production"
Back to cPanel
Head back to the cPanel interface for a moment.
21) add a rewrite for the Redmine application: on the Rails application page, click 'Create a Rewrite' for the Redmine application. On the next page, change the dropdown so that it has the correct subdomain selected. Leave the text box empty and click 'Save'.
22) start the Redmine application
Back to SSH One Last Time...
Back in your SSH interface:
23) edit the .htaccess file in the directory that was originally created for your subdomain. In my case, this is the ~/public_html/code/.htaccess file
24) after the line:
RewriteRule ^/?$ "http\:\/\/127\.0\.0\.1\:12012%{REQUEST_URI}" [P,QSA,L]
add the line:
RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12012%{REQUEST_URI}" [P,QSA,L]
NOTE: in the URLs above there is a port number: that port points to the Rails app and it may be different for your particular Redmine installation. Maybe it would be better to say copy the first line, paste it and then change the '^/?$' to '^(.*)$' in that newly pasted line. (Thanks to memebenegas for pointing this out).
25) save the file and exit back to the command line
26) send your browser to the subdomain you created and see your Redmine application running. Default username is 'admin', default password is 'admin'.
And that's that: you now have your own installation of Redmine. Your co-developers will appreciate you and your clients will love you.
Redmine is an awesome issue tracker that's written in Ruby on Rails: it's extremely pretty (which everyone loves) and has some fantastic plugins to integrate with all sorts of things, including your source control system (more on that some other time!) While Ruby is not a language that I'm familiar with, I have never been one to turn my back on a solution solely for the language that it was written in. To be perfectly honest, if I did this I probably never would have gotten into PHP in the first place!
Redmine is very similar to Trac (if you have any experience with it), except for the fact that it supports multiple projects. When I first saw Redmine I was working with a shared hosting service and had never deployed a Ruby application in my life. What follows is essentially a step-by-step process for setting this up in your own shared hosting environment. It discusses version 0.8.5, but mainly because that was the version that was available when I created my notes: I doubt newer versions are massively different to set up.
Prerequisites
Unfortunately there are a couple of prerequisites for you to get Redmine working with your hosting environment. Firstly, and probably most naturally, it needs to support Ruby on Rails applications. It also needs access to some sort of source control system: I have my installation linked to Subversion, but it does support a number of systems and so you should be able to get something working, at least. Finally, you need to have SSH access to your account. Luckily, my hosting company provided all three of these features with my account, so I was really lucky :)
Finally, there is the prerequisite that at the end of this process, you want to use a subdomain to host your Redmine installation. I have no doubt it's simple to set this up in a subdirectory instead, but the point is that this was my goal and this was what I did to get there.
Anyway, with that out of the way, let's get started...
Getting Started...
We start our process in the cPanel interface. Head into the database management area:
1) create a database for Redmine. As per the usual cPanel result, I called my database 'redmine' and ended up with a database named 'myusername_redmine'.
2) create a database user. Again, I named my 'redmine', which resulted in a user actually named 'myusername_redmine'.
3) give the new user full rights to the new database
4) in your domain management area, create a subdomain (I used code.mydomain.com, which resulted in a directory being created at ~/public_html/code)
5) in your Rails applications area, create a Rails application named 'redmine'
6) if the newly created application is already running, stop it
7) download the file redmine-0.8.5.tar.gz from http://rubyforge.org/frs/?group_id=1850
8) upload the redmine-0.8.5.tar.gz file to your home directory on the hosting server
Cracking the shell...
Open your SSH interface and keep going...
9) switch to the ~/etc/rails_apps/redmine directory
10) delete everything in the directory: rm -rf *
11) copy redmine-0.8.5.tar.gz from your home directory to ~/etc/rails_apps/redmine
12) extract the file: tar -zxvf redmine-0.8.5.tar.gz
13) switch into the redmine-0.8.5 directory and move everything to the parent directory: mv * ..
14) switch back to the parent directory and remove the now empty redmine-0.8.5 directory: rmdir redmine-0.8.5
15) copy the example database YML file: cp config/database.yml.example config/database.yml
16) open config/database.yml in your editor of choice
17) Find the section that looks like:
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password
and set the correct value for the 'database' line, the 'username' line and the 'password' line.
18) save the file and exit back to the command line
19) create the database structure: rake db:migrate RAILS_ENV="production"
20) add the default configuration data: rake redmine:load_default_data RAILS_ENV="production"
Back to cPanel
Head back to the cPanel interface for a moment.
21) add a rewrite for the Redmine application: on the Rails application page, click 'Create a Rewrite' for the Redmine application. On the next page, change the dropdown so that it has the correct subdomain selected. Leave the text box empty and click 'Save'.
22) start the Redmine application
Back to SSH One Last Time...
Back in your SSH interface:
23) edit the .htaccess file in the directory that was originally created for your subdomain. In my case, this is the ~/public_html/code/.htaccess file
24) after the line:
RewriteRule ^/?$ "http\:\/\/127\.0\.0\.1\:12012%{REQUEST_URI}" [P,QSA,L]
add the line:
RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12012%{REQUEST_URI}" [P,QSA,L]
NOTE: in the URLs above there is a port number: that port points to the Rails app and it may be different for your particular Redmine installation. Maybe it would be better to say copy the first line, paste it and then change the '^/?$' to '^(.*)$' in that newly pasted line. (Thanks to memebenegas for pointing this out).
25) save the file and exit back to the command line
26) send your browser to the subdomain you created and see your Redmine application running. Default username is 'admin', default password is 'admin'.
And that's that: you now have your own installation of Redmine. Your co-developers will appreciate you and your clients will love you.
Subscribe to:
Posts (Atom)