| 1 | |
|---|
| 2 | Welcome! |
|---|
| 3 | -------- |
|---|
| 4 | Installing LiveJournal should be extremely simple. If it's not, then |
|---|
| 5 | we consider it a bug and you should report it. Email |
|---|
| 6 | bradfitz@livejournal.com with any questions or errors you find in this |
|---|
| 7 | document. |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | Assumptions |
|---|
| 11 | ----------- |
|---|
| 12 | We're going to assume that: |
|---|
| 13 | |
|---|
| 14 | -- you have basic Unix skills. |
|---|
| 15 | -- you can install Apache |
|---|
| 16 | -- you can install MySQL |
|---|
| 17 | |
|---|
| 18 | We'll walk you through everything else, including configuring Apache |
|---|
| 19 | and MySQL for LiveJournal. |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | Conventions |
|---|
| 23 | ----------- |
|---|
| 24 | Through this document we'll use the following conventions. To run a |
|---|
| 25 | command as a normal user (usually user 'lj'), we'll use a normal shell |
|---|
| 26 | prompt character '$'. |
|---|
| 27 | |
|---|
| 28 | $ example |
|---|
| 29 | |
|---|
| 30 | To run a command as root we'll use a hash: |
|---|
| 31 | |
|---|
| 32 | # apachectl graceful |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | Creating an 'lj' user (optional) |
|---|
| 36 | --------------------- |
|---|
| 37 | If you want the LiveJournal code to run as a user other than what your |
|---|
| 38 | webserver runs as, then you'll need suEXEC support in Apache. You're |
|---|
| 39 | free to figure that out yourself. We'll assume your webserver is |
|---|
| 40 | running as user 'lj', though it doesn't have to run as any certain |
|---|
| 41 | user to work. |
|---|
| 42 | |
|---|
| 43 | If you do use suEXEC, you'll need a User directive in your livejournal |
|---|
| 44 | Vhost, as well as some different options to start the FastCGI process. |
|---|
| 45 | You can read more about that at www.fastcgi.com. |
|---|
| 46 | |
|---|
| 47 | Installing the files |
|---|
| 48 | -------------------- |
|---|
| 49 | In the past, the mandatory path for Livejournal was /home/lj/ but that |
|---|
| 50 | isn't true anymore. However, since that's where most people install |
|---|
| 51 | it, we'll assume that's where it is for the rest of this document. |
|---|
| 52 | |
|---|
| 53 | # mkdir /home/lj |
|---|
| 54 | # chown lj.lj /home/lj |
|---|
| 55 | |
|---|
| 56 | Note that the tarball creates a directory ("LiveJournal-YYYYMMDD"), so you'll |
|---|
| 57 | either want to untar at /home/ and then rename that directory to be lj, or |
|---|
| 58 | do something like: |
|---|
| 59 | |
|---|
| 60 | $ cd /home/lj |
|---|
| 61 | $ tar zxvf LiveJournal-YYYYMMDD.tar.gz |
|---|
| 62 | $ mv LiveJournal-YYYYMMDD/* . |
|---|
| 63 | $ rm -r LiveJournal-YYYYMMDD |
|---|
| 64 | |
|---|
| 65 | Perl modules: |
|---|
| 66 | ------------- |
|---|
| 67 | LiveJournal requires several Perl modules to be installed. |
|---|
| 68 | Installing these modules requires a fully working perl and C development |
|---|
| 69 | environment (including gcc and make). |
|---|
| 70 | |
|---|
| 71 | If you are unfamilar with installing modules, the simplest method is to enter |
|---|
| 72 | the following command from a root shell prompt: |
|---|
| 73 | |
|---|
| 74 | # perl -MCPAN -e shell |
|---|
| 75 | |
|---|
| 76 | Once the Perl interpreter has loaded (and been configured), you can install |
|---|
| 77 | modules by issuing the command 'install MODULENAME'. |
|---|
| 78 | |
|---|
| 79 | The first thing you should do is upgrade your CPAN: |
|---|
| 80 | |
|---|
| 81 | cpan> install Bundle::CPAN |
|---|
| 82 | |
|---|
| 83 | Once it's done, type: |
|---|
| 84 | |
|---|
| 85 | cpan> reload cpan |
|---|
| 86 | |
|---|
| 87 | Now, install the following modules: |
|---|
| 88 | |
|---|
| 89 | Bundle::libnet |
|---|
| 90 | Digest::MD5 |
|---|
| 91 | Image::Size |
|---|
| 92 | FCGI |
|---|
| 93 | MIME::Lite |
|---|
| 94 | Compress::Zlib |
|---|
| 95 | MIME::Base64 |
|---|
| 96 | URI::URL |
|---|
| 97 | HTML::Tagset |
|---|
| 98 | HTML::Parser |
|---|
| 99 | LWP::Simple |
|---|
| 100 | LWP::UserAgent |
|---|
| 101 | Time::DaysInMonth |
|---|
| 102 | GD |
|---|
| 103 | GD::Graph |
|---|
| 104 | GD::Text |
|---|
| 105 | Bundle::Mysql |
|---|
| 106 | Mail::Address |
|---|
| 107 | Proc::ProcessTable |
|---|
| 108 | SOAP::Lite |
|---|
| 109 | Unicode::MapUTF8 |
|---|
| 110 | |
|---|
| 111 | If you're using Debian this should get everything: |
|---|
| 112 | |
|---|
| 113 | # apt-get install libwww-perl libfcgi-perl libmime-lite-perl \ |
|---|
| 114 | libsoap-lite-perl libgd-perl liburi-perl \ |
|---|
| 115 | libimage-size-perl libdbd-mysql-perl libdbi-perl \ |
|---|
| 116 | libnet-perl libdigest-md5-perl libgd-graph-perl \ |
|---|
| 117 | libgd-text-perl libcompress-zlib-perl \ |
|---|
| 118 | libunicode-maputf8-perl libproc-process-perl \ |
|---|
| 119 | libapache-mod-fastcgi |
|---|
| 120 | |
|---|
| 121 | NOTE: there used to be three custom LJ:: modules that needed |
|---|
| 122 | installing. We no longer install those in the system. Instead LJ |
|---|
| 123 | uses them right out of ~lj/cgi-bin/LJ/*. If you have those old LJ |
|---|
| 124 | modules installed, it's best to go remove them since Perl will prefer |
|---|
| 125 | system-level ones over local ones. |
|---|
| 126 | |
|---|
| 127 | Apache Modules: |
|---|
| 128 | --------------- |
|---|
| 129 | You'll need the following Apache modules running (either statically or |
|---|
| 130 | as DSOs): |
|---|
| 131 | |
|---|
| 132 | Standard: |
|---|
| 133 | mod_env |
|---|
| 134 | mod_setenvif |
|---|
| 135 | mod_alias |
|---|
| 136 | mod_expires |
|---|
| 137 | mod_actions |
|---|
| 138 | mod_rewrite |
|---|
| 139 | mod_mime_magic |
|---|
| 140 | mod_mime |
|---|
| 141 | |
|---|
| 142 | Special: |
|---|
| 143 | mod_fastcgi -- from http://www.fastcgi.com/ |
|---|
| 144 | |
|---|
| 145 | NOTE: It is critical that mod_mime_magic appear in the Apache config |
|---|
| 146 | file before mod_mime, otherwise none of the LiveJournal pages |
|---|
| 147 | will work. See http://httpd.apache.org/docs/mod/mod_mime_magic.html |
|---|
| 148 | if you'd like more information. |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | Configuring Apache |
|---|
| 152 | ------------------ |
|---|
| 153 | You need to add a <VirtualHost> section in Apache's httpd.conf file. |
|---|
| 154 | See INSTALL.apache.txt for an example that you'll only need to modify |
|---|
| 155 | slightly (only the hostname). |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | Making a MySQL database for livejournal |
|---|
| 159 | --------------------------------------- |
|---|
| 160 | First, are you running a recent MySQL? You should be at least |
|---|
| 161 | 3.23.38, especially if you'll be running a high-volume LJ site with |
|---|
| 162 | replication. If you're running 3.23.x, you'll probably be okay. If |
|---|
| 163 | you're running 3.22.x, you definitely need to upgrade. |
|---|
| 164 | |
|---|
| 165 | Login to MySQL as the root MySQL user and create the database that |
|---|
| 166 | will hold the LiveJournal data: |
|---|
| 167 | |
|---|
| 168 | $ mysql -uroot -p |
|---|
| 169 | |
|---|
| 170 | mysql> CREATE DATABASE livejournal; |
|---|
| 171 | mysql> GRANT ALL PRIVILEGES ON livejournal.* TO |
|---|
| 172 | lj@'127.0.0.1' IDENTIFIED BY 'ljpass'; |
|---|
| 173 | |
|---|
| 174 | You can change the usernames and passwords above. We'll set those in |
|---|
| 175 | ljconfig.pl in a moment. |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | Setting up LJHOME environment variable |
|---|
| 179 | -------------------------------------- |
|---|
| 180 | Be aware that nearly all LiveJournal code depends on the $LJHOME |
|---|
| 181 | environment variable being set to the top-level directory that |
|---|
| 182 | LiveJournal is installed at. |
|---|
| 183 | |
|---|
| 184 | The Apache configuration in INSTALL.apache.txt has the necessary |
|---|
| 185 | directives to make sure the web code always has $LJHOME set, but if |
|---|
| 186 | you're running LJ maintenance commands from a terminal, you'll need to |
|---|
| 187 | make sure $LJHOME is set for yourself. |
|---|
| 188 | |
|---|
| 189 | The easiest way is to put the following in your ~/.bash_profile: |
|---|
| 190 | |
|---|
| 191 | LJHOME=/home/lj; export LJHOME |
|---|
| 192 | |
|---|
| 193 | This is assuming you use bash. If that doesn't work and you don't |
|---|
| 194 | know what your shell reads on start-up, try ~/.profile. |
|---|
| 195 | |
|---|
| 196 | Test that it's set: |
|---|
| 197 | |
|---|
| 198 | $ . ~/.bash_profile |
|---|
| 199 | $ echo $LJHOME |
|---|
| 200 | |
|---|
| 201 | You should see it spit out /home/lj (or whatever you set it |
|---|
| 202 | to... depending on where you installed the code). |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | Configuring LiveJournal |
|---|
| 206 | ----------------------- |
|---|
| 207 | You need to make a LiveJournal configuration file. There's an example |
|---|
| 208 | ljconfig.pl in the doc directory by the name of "ljconfig.pl.txt". |
|---|
| 209 | You need to copy this file to cgi-bin/ljconfig.pl and then edit it to |
|---|
| 210 | suit your needs. |
|---|
| 211 | |
|---|
| 212 | $ cd /home/lj |
|---|
| 213 | $ cp doc/ljconfig.pl.txt cgi-bin/ljconfig.pl |
|---|
| 214 | |
|---|
| 215 | The reason it's not there already is so that future upgrades don't |
|---|
| 216 | destroy your configuration. The end of ljconfig.pl reads in |
|---|
| 217 | ljdefaults.pl so that if we add new options, ljdefaults.pl will be |
|---|
| 218 | updated and will set sane defaults. After an upgrade you want to |
|---|
| 219 | glance at ljdefaults.pl (or the original doc/ljconfig.pl.txt) and see |
|---|
| 220 | if there are any new options. |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | Populating the Database |
|---|
| 224 | ------------------------ |
|---|
| 225 | This is almost the final step to having a fully working LJ database, |
|---|
| 226 | and it is one of the easiest. |
|---|
| 227 | |
|---|
| 228 | Assuming you've done everything above, all you have to do is: |
|---|
| 229 | |
|---|
| 230 | $ cd /home/lj |
|---|
| 231 | $ bin/upgrading/update-db.pl --runsql --populate |
|---|
| 232 | |
|---|
| 233 | That'll bring your database schema up-to-date and populate it with any |
|---|
| 234 | look-up data it needs. |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | Installing the crontabs |
|---|
| 238 | ----------------------- |
|---|
| 239 | From the LiveJournal user account (or whatever user is running LJ), |
|---|
| 240 | you need to install some crontabs. These are periodic commands that |
|---|
| 241 | run and manage your LiveJournal installation. |
|---|
| 242 | |
|---|
| 243 | Type: |
|---|
| 244 | |
|---|
| 245 | $ crontab -e |
|---|
| 246 | |
|---|
| 247 | This will bring up either your $EDITOR, or vi. If you want to set |
|---|
| 248 | your editor explicitly, do: |
|---|
| 249 | |
|---|
| 250 | $ EDITOR=pico crontab -e |
|---|
| 251 | |
|---|
| 252 | [Note: prolonged use of pico can cause insanity. You are encouraged |
|---|
| 253 | to learn emacs or vi.] |
|---|
| 254 | |
|---|
| 255 | Now, enter the following stuff between the dotted lines below. Not |
|---|
| 256 | all of it is necessary. See the comments below. The LJHOME= line is |
|---|
| 257 | required. See the section above about how the $LJHOME environment |
|---|
| 258 | variable is required everywhere. This is another place. |
|---|
| 259 | |
|---|
| 260 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 261 | LJHOME=/home/lj |
|---|
| 262 | MAILTO=youremail@wherever.com |
|---|
| 263 | |
|---|
| 264 | # Essential: |
|---|
| 265 | * * * * * /home/lj/bin/ljmaint.pl db_batchdelete >/dev/null |
|---|
| 266 | * */12 * * * /home/lj/bin/ljmaint.pl clean_caches >/dev/null |
|---|
| 267 | |
|---|
| 268 | # Optional, if you want birthday mail, and the random user feature: |
|---|
| 269 | # (you can remove parts) |
|---|
| 270 | 5 1 * * * /home/lj/bin/ljmaint.pl bdaymail build_randomuserset >/dev/null |
|---|
| 271 | |
|---|
| 272 | # If you want statistics: |
|---|
| 273 | 30 1 * * * /home/lj/bin/ljmaint.pl genstats genstatspics >/dev/null |
|---|
| 274 | 5 2 * * 0 /home/lj/bin/ljmaint.pl genstats_weekly > /dev/null |
|---|
| 275 | |
|---|
| 276 | # If you're running a high-load site with $LJ::BUFFER_QUERIES on, |
|---|
| 277 | # there's another one to install: |
|---|
| 278 | */5 * * * * /home/lj/bin/qbufferd.pl >/dev/null |
|---|
| 279 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|---|
| 280 | |
|---|
| 281 | If query buffering is off, you can still run that, but it's not |
|---|
| 282 | needed. Packagers should make their packages install it, since |
|---|
| 283 | it doesn't hurt if it's running and not used. It'll die off |
|---|
| 284 | right away if it realizes it's not needed. Otherwise it'll |
|---|
| 285 | start up in the background and run every 10 seconds or so. |
|---|
| 286 | Future startups by cron will only make sure it hasn't died (like |
|---|
| 287 | if the database dies). |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | Finishing up |
|---|
| 291 | ------------ |
|---|
| 292 | You should now just about have a working LiveJournal |
|---|
| 293 | installation. There are many things you can still do, but all are |
|---|
| 294 | outside the scope of this document. |
|---|
| 295 | |
|---|
| 296 | If you haven't restarted Apache, you'll want to do that now: |
|---|
| 297 | |
|---|
| 298 | # apachectl restart |
|---|
| 299 | |
|---|
| 300 | The last thing you will need to do is create the system user that'll |
|---|
| 301 | have privileges to give privileges to other users. |
|---|
| 302 | |
|---|
| 303 | $ bin/upgrading/make_system.pl |
|---|
| 304 | |
|---|
| 305 | It'll prompt you for the password to use for the system account and |
|---|
| 306 | then sets it all up. |
|---|
| 307 | |
|---|
| 308 | You now have the ability to login to your LJ site as user "system" |
|---|
| 309 | with the password you set and then grant priviledges from the admin |
|---|
| 310 | section to other users: |
|---|
| 311 | |
|---|
| 312 | http://your-lj-server/admin/priv/ |
|---|
| 313 | |
|---|
| 314 | If you have any questions, join the "lj_dev" community on |
|---|
| 315 | LiveJournal.com and post your questions. We'd love to help you out. |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | More reading |
|---|
| 319 | ------------ |
|---|
| 320 | It's recommended that you read the file "CVS.txt" for instructions on |
|---|
| 321 | how to stay up-to-date with the latest LiveJournal code. |
|---|
| 322 | |
|---|