root/trunk/doc/INSTALL.txt @ 857

Revision 857, 9.9 KB (checked in by bradfitz, 11 years ago)

untabify

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2Welcome!
3--------
4Installing LiveJournal should be extremely simple.  If it's not, then
5we consider it a bug and you should report it.  Email
6bradfitz@livejournal.com with any questions or errors you find in this
7document.
8
9
10Assumptions
11-----------
12We're going to assume that:
13
14 -- you have basic Unix skills. 
15 -- you can install Apache
16 -- you can install MySQL
17
18We'll walk you through everything else, including configuring Apache
19and MySQL for LiveJournal.
20
21
22Conventions
23-----------
24Through this document we'll use the following conventions.  To run a
25command as a normal user (usually user 'lj'), we'll use a normal shell
26prompt character '$'.
27
28    $ example
29
30To run a command as root we'll use a hash:
31
32    # apachectl graceful
33
34
35Creating an 'lj' user  (optional)
36---------------------
37If you want the LiveJournal code to run as a user other than what your
38webserver runs as, then you'll need suEXEC support in Apache.  You're
39free to figure that out yourself.  We'll assume your webserver is
40running as user 'lj', though it doesn't have to run as any certain
41user to work.
42
43If you do use suEXEC, you'll need a User directive in your livejournal
44Vhost, as well as some different options to start the FastCGI process.
45You can read more about that at www.fastcgi.com.
46
47Installing the files
48--------------------
49In the past, the mandatory path for Livejournal was /home/lj/ but that
50isn't true anymore.  However, since that's where most people install
51it, 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
56Note that the tarball creates a directory ("LiveJournal-YYYYMMDD"), so you'll
57either want to untar at /home/ and then rename that directory to be lj, or
58do something like:
59
60   $ cd /home/lj
61   $ tar zxvf LiveJournal-YYYYMMDD.tar.gz
62   $ mv LiveJournal-YYYYMMDD/* .
63   $ rm -r LiveJournal-YYYYMMDD
64
65Perl modules:
66-------------
67LiveJournal requires several Perl modules to be installed.
68Installing these modules requires a fully working perl and C development
69environment (including gcc and make).
70
71If you are unfamilar with installing modules, the simplest method is to enter
72the following command from a root shell prompt:
73
74   # perl -MCPAN -e shell
75
76Once the Perl interpreter has loaded (and been configured), you can install
77modules by issuing the command 'install MODULENAME'.
78
79The first thing you should do is upgrade your CPAN:
80
81   cpan> install Bundle::CPAN
82
83Once it's done, type:
84
85   cpan> reload cpan
86
87Now, 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
111If 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
121NOTE: there used to be three custom LJ:: modules that needed
122installing.  We no longer install those in the system.  Instead LJ
123uses them right out of ~lj/cgi-bin/LJ/*.  If you have those old LJ
124modules installed, it's best to go remove them since Perl will prefer
125system-level ones over local ones.
126
127Apache Modules:
128---------------
129You'll need the following Apache modules running (either statically or
130as DSOs):
131
132Standard:
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
142Special:
143        mod_fastcgi     -- from http://www.fastcgi.com/
144
145NOTE: 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
151Configuring Apache
152------------------
153You need to add a <VirtualHost> section in Apache's httpd.conf file.
154See INSTALL.apache.txt for an example that you'll only need to modify
155slightly (only the hostname).
156
157
158Making a MySQL database for livejournal
159---------------------------------------
160First, are you running a recent MySQL?  You should be at least
1613.23.38, especially if you'll be running a high-volume LJ site with
162replication.  If you're running 3.23.x, you'll probably be okay.  If
163you're running 3.22.x, you definitely need to upgrade.
164
165Login to MySQL as the root MySQL user and create the database that
166will 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
174You can change the usernames and passwords above.  We'll set those in
175ljconfig.pl in a moment.
176
177
178Setting up LJHOME environment variable
179--------------------------------------
180Be aware that nearly all LiveJournal code depends on the $LJHOME
181environment variable being set to the top-level directory that
182LiveJournal is installed at.
183
184The Apache configuration in INSTALL.apache.txt has the necessary
185directives to make sure the web code always has $LJHOME set, but if
186you're running LJ maintenance commands from a terminal, you'll need to
187make sure $LJHOME is set for yourself.
188
189The easiest way is to put the following in your ~/.bash_profile:
190
191    LJHOME=/home/lj; export LJHOME
192
193This is assuming you use bash.  If that doesn't work and you don't
194know what your shell reads on start-up, try ~/.profile.
195
196Test that it's set:
197
198    $ . ~/.bash_profile
199    $ echo $LJHOME
200
201You should see it spit out /home/lj (or whatever you set it
202to... depending on where you installed the code).
203
204
205Configuring LiveJournal
206-----------------------
207You need to make a LiveJournal configuration file.  There's an example
208ljconfig.pl in the doc directory by the name of "ljconfig.pl.txt".
209You need to copy this file to cgi-bin/ljconfig.pl and then edit it to
210suit your needs.
211
212   $ cd /home/lj
213   $ cp doc/ljconfig.pl.txt cgi-bin/ljconfig.pl
214
215The reason it's not there already is so that future upgrades don't
216destroy your configuration.  The end of ljconfig.pl reads in
217ljdefaults.pl so that if we add new options, ljdefaults.pl will be
218updated and will set sane defaults.  After an upgrade you want to
219glance at ljdefaults.pl (or the original doc/ljconfig.pl.txt) and see
220if there are any new options.
221
222
223Populating the Database
224------------------------
225This is almost the final step to having a fully working LJ database,
226and it is one of the easiest.
227
228Assuming 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
233That'll bring your database schema up-to-date and populate it with any
234look-up data it needs.
235
236
237Installing the crontabs
238-----------------------
239From the LiveJournal user account (or whatever user is running LJ),
240you need to install some crontabs.  These are periodic commands that
241run and manage your LiveJournal installation.
242
243Type:
244
245    $ crontab -e
246
247This will bring up either your $EDITOR, or vi.  If you want to set
248your 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
255Now, enter the following stuff between the dotted lines below.  Not
256all of it is necessary.  See the comments below.  The LJHOME= line is
257required.  See the section above about how the $LJHOME environment
258variable is required everywhere.  This is another place.
259
260- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
261LJHOME=/home/lj
262MAILTO=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)
2705 1 * * * /home/lj/bin/ljmaint.pl bdaymail build_randomuserset >/dev/null
271
272# If you want statistics:
27330 1 * * * /home/lj/bin/ljmaint.pl genstats genstatspics >/dev/null
2745 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
281If query buffering is off, you can still run that, but it's not
282needed.  Packagers should make their packages install it, since
283it doesn't hurt if it's running and not used.  It'll die off
284right away if it realizes it's not needed.  Otherwise it'll
285start up in the background and run every 10 seconds or so.
286Future startups by cron will only make sure it hasn't died (like
287if the database dies).
288
289
290Finishing up
291------------
292You should now just about have a working LiveJournal
293installation. There are many things you can still do, but all are
294outside the scope of this document.
295
296If you haven't restarted Apache, you'll want to do that now:
297
298  # apachectl restart
299
300The last thing you will need to do is create the system user that'll
301have privileges to give privileges to other users.
302
303  $ bin/upgrading/make_system.pl
304
305It'll prompt you for the password to use for the system account and
306then sets it all up.
307
308You now have the ability to login to your LJ site as user "system"
309with the password you set and then grant priviledges from the admin
310section to other users:
311
312  http://your-lj-server/admin/priv/
313
314If you have any questions, join the "lj_dev" community on
315LiveJournal.com and post your questions.  We'd love to help you out.
316
317
318More reading
319------------
320It's recommended that you read the file "CVS.txt" for instructions on
321how to stay up-to-date with the latest LiveJournal code.
322
Note: See TracBrowser for help on using the browser.