Removed hard coded directories (as reported by Ville Huhtala).
[koha.git] / installer-lite.pl
blob8edcd4a54247972a83749a433983aa967452cf87
1 #!/usr/bin/perl -w # please develop with -w
3 use diagnostics;
4 use strict; # please develop with the strict pragma
6 system('clear');
7 print qq|
8 *******************************************
9 * Welcome to the Koha Installation Guide *
10 *******************************************
12 This installer will guide you through the process of installing Koha.
13 It is not a completely automated installation, but a guide for further
14 information please read the documentation or visit the Koha website at
15 http://www.koha.org
17 To successfully use Koha you need some additional software:
19 * A webserver (It was built to work with Apache, but there is no reason
20 it should not work with any other webserver).
22 * Mysql (You could intead use postgres, or another sql based database)
24 * Perl
26 Are you ready to go through the installation process now? (Y/[N]):
29 my $answer = <STDIN>;
30 chomp $answer;
32 if ($answer eq "Y" || $answer eq "y") {
33 print "Beginning setup... \n";
34 } else {
35 print qq|
36 When you are ready to complete the installation just run this installer again.
38 exit;
41 print "\n";
45 # Test for Perl - Do we need to explicity check versions?
47 print "\nChecking that perl and the required modules are installed ...\n";
48 unless (eval "require 5.004") {
49 die "Sorry, you need at least Perl 5.004\n";
53 # Test for Perl Dependancies
55 my @missing = ();
56 unless (eval require DBI) { push @missing,"DBI" };
57 unless (eval require Date::Manip) { push @missing,"Date::Manip" };
58 unless (eval require DBD::mysql) { push @missing,"DBD::mysql" };
59 unless (eval require Set::Scalar) { push @missing,"Set::Scalar" };
62 # Print out a list of any missing modules
64 if (@missing > 0) {
65 print "\n\n";
66 print "You are missing some Perl modules which are required by Koha.\n";
67 print "Once these modules have been installed, rerun this installery.\n";
68 print "They can be installed by running (as root) the following:\n";
69 foreach my $module (@missing) {
70 print " perl -MCPAN -e 'install \"$module\"'\n";
71 exit(1);
72 }} else{
73 print "Perl and required modules appear to be installed, continuing...\n";
77 print "\n";
80 #KOHA conf
82 print qq|
83 Koha uses a small configuration file that is usually placed in your
84 /etc/ files directory (note: if you wish to place the koha.conf in
85 another location you will need to manually edit additional files).
87 We will help you to now create your koha.conf file, once this file
88 has been created, please copy it to your destination folder
89 (note: this may need to be done by your systems administrator).
92 my $dbname;
93 my $hostname;
94 my $user;
95 my $pass;
96 my $inc_path;
98 print "\n";
99 print "\n";
100 print qq|
101 Please provide the name of the mysql database that you wish to use
102 for koha. This is normally "Koha".
105 #Get the database name
106 do {
107 print "Enter database name:";
108 chomp($dbname = <STDIN>);
112 print "\n";
113 print "\n";
114 print qq|
115 Please provide the hostname for mysql. Unless the database is located
116 on another machine this is likely to be "localhost".
119 #Get the hostname for the database
120 do {
121 print "Enter hostname:";
122 chomp($hostname = <STDIN>);
126 print "\n";
127 print "\n";
128 print qq|
129 Please provide the name of the mysql user, who will have full administrative
130 rights to the $dbname database, when authenicating from $hostname.
131 It is recommended that you do not use your "root" user.
134 #Set the username for the database
135 do {
136 print "Enter username:";
137 chomp($user = <STDIN>);
141 print "\n";
142 print "\n";
143 print qq|
144 Please provide a password for the mysql user $user.
147 #Set the password for the database user
148 do {
149 print "Enter password:";
150 chomp($pass = <STDIN>);
153 print "\n";
154 print "\n";
155 print qq|
156 Please provide the full path to your Koha Intranet/Librarians installation.
157 Usually /usr/local/www/koha/htdocs
160 #Get the password for the database user
161 do {
162 print "Enter installation path:";
163 chomp($inc_path = <STDIN>);
167 #Create the configuration file
168 open(SITES,">koha.conf") or die "Couldn't create file.
169 Must have write capability.\n";
170 print SITES <<EOP
171 database=$dbname
172 hostname=$hostname
173 user=$user
174 password=$pass
175 includes=$inc_path/includes
178 close(SITES);
180 print "Successfully created the Koha configuration file.\n";
182 print "\n";
185 #SETUP Virtual Host Directives
187 #OPAC Settings
189 my $opac_svr_admin;
190 my $opac_docu_root;
191 my $opac_svr_name;
193 print qq|
194 You need to setup your Apache configuration file for the
195 OPAC virtual host.
197 Please enter the servername for the OPAC interface.
198 Usually opac.your.domain
200 do {
201 print "Enter servername address:";
202 chomp($opac_svr_name = <STDIN>);
206 print qq|
207 Please enter the e-mail address for your webserver admin.
208 Usually webmaster\@your.domain
210 do {
211 print "Enter e-mail address:";
212 chomp($opac_svr_admin = <STDIN>);
216 print qq|
217 Please enter the full path to your OPAC\'s document root.
218 usually something like \"/usr/local/www/opac/htdocs\".
220 do {
221 print "Enter Document Roots Path:";
222 chomp($opac_docu_root = <STDIN>);
227 # Update Apache Conf File.
229 open(SITES,">>koha-apache.conf") or die "Couldn't write to file.
230 Must have write capability.\n";
231 print SITES <<EOP
233 <VirtualHost $opac_svr_name>
234 ServerAdmin $opac_svr_admin
235 DocumentRoot $opac_docu_root
236 ServerName $opac_svr_name
237 ErrorLog logs/opac-error_log
238 TransferLog logs/opac-access_log common
239 </VirtualHost>
243 close(SITES);
247 #Intranet Settings
249 my $intranet_svr_admin;
250 my $intranet_svr_name;
252 print qq|
253 You need to setup your Apache configuration file for the
254 Intranet/librarian virtual host.
256 Please enter the servername for your Intranet/Librarian interface.
257 Usually koha.your.domain
259 do {
260 print "Enter servername address:";
261 chomp($intranet_svr_name = <STDIN>);
265 print qq|
266 Please enter the e-mail address for your webserver admin.
267 Usually webmaster\@your.domain
269 do {
270 print "Enter e-mail address:";
271 chomp($intranet_svr_admin = <STDIN>);
277 # Update Apache Conf File.
279 open(SITES,">>koha-apache.conf") or die "Couldn't write to file.
280 Must have write capability.\n";
281 print SITES <<EOP
283 <VirtualHost $intranet_svr_name>
284 ServerAdmin $intranet_svr_admin
285 DocumentRoot $inc_path
286 ServerName $intranet_svr_name
287 ErrorLog logs/opac-error_log
288 TransferLog logs/opac-access_log common
289 </VirtualHost>
293 close(SITES);
296 print "Successfully created the Apache Virtual Host Configuration file.\n";
298 system('clear');
299 print qq|
300 *******************************************
301 * Koha Installation Guide - Continued *
302 *******************************************
304 In order to finish the installation of Koha, there is still a couple
305 of steps that you will need to complete.
307 * Setup mysql
308 1. Create a new mysql database called for example Koha
309 From command line: mysqladmin -uroot -ppassword create Koha
311 2. Set up a koha user and password in mysql
312 Log in to mysql: mysql -uroot -ppassword
314 To create a user called "koha" who has full administrative
315 rights to the "Koha" database when authenticating from
316 "localhost", enter the following on mysql command line:
318 grant all privileges on Koha.* to koha\@localhost identified by 'kohapassword'\;
320 Press ENTER, and if you see no errors then enter \q to quit mysql.
323 3. Use the mysql script to create the tables
324 mysql -uusername -ppassword Koha < koha.mysql
326 4. Update your database tables
327 perl updatedatabase -I /pathtoC4
330 * Koha.conf
331 1. Copy Koha.conf to /etc/
332 If you wish to locate the file in another location please read
333 the INSTALL and Hints files.
338 # It is completed
340 print "\nCongratulations ... your Koha installation is complete!\n";
341 print "\nYou will need to restart your webserver before using Koha!\n";