📄 install.sgml
字号:
<note><title>Please Report Problems</title><para>If your system is not automatically recognized by configure and you have to do this, please send email to <ulink url="mailto:scrappy@hub.org">scrappy@hub.org</ulink> with the output of the program <application>./config.guess</application>. Indicate what the template file should be.</para></note></Para></step><Step Performance="optional"><Para>Choose configuration options. Check <xref linkend="config" endterm="install-config">for details. However, for a plain-vanilla first installation with no extraoptions like multi-byte character support or locale collation support it maybe adequate to have chosen the installation areas and to run configure withoutextra options specified. The configure script accepts many additional options that you can use if you don't like the default configuration. To see them all, type<ProgramListing> ./configure --help</ProgramListing> Some of the more commonly used ones are:<ProgramListing> --prefix=BASEDIR Selects a different base directory for the installation of the <ProductName>Postgres</ProductName> configuration. The default is /usr/local/pgsql. --with-template=TEMPLATE Use template file TEMPLATE - the template files are assumed to be in the directory src/template, so look there for proper values. --with-tcl Build interface libraries and programs requiring Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh. --with-perl Build the Perl interface library. --with-odbc Build the ODBC driver package. --enable-hba Enables Host Based Authentication (DEFAULT) --disable-hba Disables Host Based Authentication --enable-locale Enables USE_LOCALE --enable-cassert Enables ASSERT_CHECKING --with-CC=compiler Use a specific C compiler that the configure script cannot find. --with-CXX=compiler --without-CXX Use a specific C++ compiler that the configure script cannot find, or exclude C++ compilation altogether. (This only affects libpq++ at present.)</ProgramListing></Para></step><Step Performance="required"><Para>Here is the configure script used on a Sparc Solaris 2.5 system with <filename>/opt/postgres</filename> specified as the installation base directory:<ProgramListing>$ ./configure --prefix=/opt/postgres \ --with-template=sparc_solaris-gcc --with-pgport=5432 \ --enable-hba --disable-locale</ProgramListing><tip><para> Of course, you may type these three lines all on the same line.</para></tip></Para></Step></substeps></step><Step Performance="required"><Para>Install the <application>man</application> and<acronym>HTML</acronym> documentation. Type<ProgramListing>$ cd /usr/src/pgsql/doc$ gmake install</ProgramListing></para><para>The documentation is also available in Postscript format. Look for filesending with <filename>.ps.gz</filename> in the same directory.</para></step><Step Performance="required"><Para>Compile the program. Type<ProgramListing>$ cd /usr/src/pgsql/src$ gmake all >& make.log &$ tail -f make.log</ProgramListing></Para><Para> The last line displayed will hopefully be <programlisting>All of PostgreSQL is successfully made. Ready to install.</programlisting>Remember, <Quote>gmake</Quote> may be called <Quote>make</Quote> onyour system. At this point, or earlier if you wish, type control-C to get out of tail. (If you have problems later on you may wish to examine file make.log for warning and error messages.)<note><para>You will probably find a number of warning messages in make.log. Unless you have problems later on, these messages may be safely ignored.</para></note></para><Para> If the compiler fails with a message stating that the <application>flex</application> command cannot be found then install <application>flex</application> as described earlier. Next, change directory back to this directory, type <programlisting>$ gmake clean</programlisting>then recompile again.</Para><Para> Compiler options, such as optimization and debugging, may be specified on the command line using the COPT variable. For example, typing<ProgramListing>$ gmake COPT="-g" all >& make.log &</ProgramListing> would invoke your compiler's <option>-g</option> option in all steps of the build. See <filename>src/Makefile.global.in</filename> for further details.</Para></Step><Step Performance="required"><Para> Install the program. Type<ProgramListing>$ cd /usr/src/pgsql/src$ gmake install >& make.install.log &$ tail -f make.install.log</ProgramListing></Para><Para> The last line displayed will be <programlisting>gmake[1]: Leaving directory `/usr/src/pgsql/src/man'</programlisting>At this point, or earlier if you wish, type control-C to get out of tail.Remember, <Quote>gmake</Quote> may be called <Quote>make</Quote> onyour system.</Para></Step><Step Performance="required"><Para>If necessary, tell your system how to find the new shared libraries. You cando <emphasis>one</emphasis> of the following, preferably the first:</para><SubSteps><Step Performance="optional"><Para> As root, edit file <filename>/etc/ld.so.conf</filename>. Add a line<programlisting><FileName>/usr/local/pgsql/lib</FileName></programlisting>to the file. Then run command <Command>/sbin/ldconfig</Command>.</Para></Step><Step Performance="optional"><Para> In a bash shell, type<ProgramListing> export LD_LIBRARY_PATH=/usr/local/pgsql/lib</ProgramListing></Para></Step><Step Performance="optional"><Para> In a csh shell, type<ProgramListing> setenv LD_LIBRARY_PATH /usr/local/pgsql/lib</ProgramListing></para></Step></SubSteps><Para> Please note that the above commands may vary wildly for different operating systems. Check the platform specific notes, such as those for Ultrix4.x or and for non-ELF Linux.</Para><Para> If, when you create the database, you get the message <programlisting>pg_id: can't load library 'libpq.so'</programlisting> then the above step was necessary. Simply do this step, then try to create the database again.</Para></Step> <Step Performance="optional"> <Para> If you used the <option>--with-perl</option> option to configure, check the install log to see whether the Perl module was actually installed. If you've followed our advice to make the Postgres files be owned by an unprivileged userid, then the Perl module won't have been installed, for lack of write privileges on the Perl library directories. You can complete its installation, either now or later, by becoming the user that does own the Perl library (often root) (via <command>su</command>) and doing <ProgramListing> $ cd /usr/src/pgsql/src/interfaces/perl5 $ gmake install </ProgramListing> </Para> </Step> <Step Performance="required"> <Para> If it has not already been done, then prepare account <literal>postgres</literal> for using <ProductName>Postgres</ProductName>. Any account that will use <ProductName>Postgres</ProductName> must be similarly prepared. </para> <para> There are several ways to influence the runtime environment of the <ProductName>Postgres</ProductName> server. Refer to the <citetitle>Administrator's Guide</citetitle> for more information. <note> <para> The following instructions are for a bash/sh shell. Adapt accordingly for other shells. </para> </note> </Para> <substeps> <Step Performance="required"> <Para> Add the following lines to your login environment: shell, <filename>~/.bash_profile</filename>: <ProgramListing> PATH=$PATH:/usr/local/pgsql/bin MANPATH=$MANPATH:/usr/local/pgsql/man PGLIB=/usr/local/pgsql/lib PGDATA=/usr/local/pgsql/data export PATH MANPATH PGLIB PGDATA </ProgramListing> </Para> </step> <Step Performance="required"> <para> Several regression tests could fail if the user's locale collation scheme is different from that of the standard <literal>C</literal> locale. </para> <para> If you configure and compile <ProductName>Postgres</ProductName> with <option>--enable-locale</option> then you should set the locale environment to <quote><literal>C</literal></quote> (or unset all <quote>LC_*</quote> variables) by putting these additional lines to your login environment before starting <application>postmaster</application>: <ProgramListing> LC_COLLATE=C LC_CTYPE=C export LC_COLLATE LC_CTYPE </ProgramListing> <ProgramListing> </ProgramListing> </para> </step> <Step Performance="required"> <Para> Make sure that you have defined these variables before continuing with the remaining steps. The easiest way to do this is to type: <ProgramListing> $ source ~/.bash_profile </ProgramListing> </Para> </Step> </substeps> </step><Step Performance="required"><Para> Create the database installation from your <ProductName>Postgres</ProductName> superuser account (typically account <literal>postgres</literal>).<Emphasis>Do not do the following as root!</Emphasis>This would be a major security hole. Type<ProgramListing>$ initdb</ProgramListing></Para></Step><Step Performance="required"><Para> Set up permissions to access the database system. Do this by editing file <filename>/usr/local/pgsql/data/pg_hba.conf</filename>. The instructions are included in the file. (If your database is not located in the default location, i.e. if <envar>PGDATA</envar> is set to point elsewhere, then the location of this file will change accordingly.) This file should be made read only again once you are finished. If you are upgrading from v6.0 or later you can copy file <filename>pg_hba.conf</filename> from your old database on top of the one in your new database, rather than redoing the file from scratch.</Para></Step><Step Performance="required"><para>Briefly test that the backend will start and run by running it fromthe command line.</para><substeps><Step Performance="required"><para> Start the postmaster daemon running in the background by typing<ProgramListing>$ cd$ nohup postmaster -i > pgserver.log 2>&1 &</ProgramListing></Para></Step><Step Performance="required"><para>Create a database by typing<ProgramListing>$ createdb</ProgramListing></para></step><Step Performance="required"><para>Connect to the new database:<ProgramListing>$ psql</ProgramListing></para></step><Step Performance="required"><para>And run a sample query:<ProgramListing>postgres=> SELECT datetime 'now';</ProgramListing></para></step><Step Performance="required"><para>Exit <application>psql</application>:<ProgramListing>postgres=> \q</ProgramListing></para></step><Step Performance="required"><para>Remove the test database (unless you will want to use it later for other tests):<ProgramListing>$ destroydb</ProgramListing></para></step></substeps></step><Step Performance="required"><Para> Run postmaster in the background from your <ProductName>Postgres</ProductName> superuser account (typically account <literal>postgres</literal>).<emphasis>Do not run <application>postmaster</application> from the root account!</emphasis></para><Para>Usually, you will want to modify your computer so that it will automatically start postmaster whenever it boots. It is not required; the <ProductName>Postgres</ProductName> server canbe run successfully from non-privileged accounts without root intervention.</para><para> Here are some suggestions on how to do this, contributed by various users.</para><para> Whatever you do, postmaster must be run by the <ProductName>Postgres</ProductName> superuser (<literal>postgres</literal>?)<emphasis>and not by root</emphasis>.This is why all of the examples below start by switching user (su) to postgres. These commands also take into account the fact that environment variables like PATH and PGDATA may not be set properly. The examples are as follows. Use them with extreme caution.<itemizedlist mark="bullet"><listitem><para>If you are installing from a non-privileged account and have no root access, thenstart the <application>postmaster</application> and send it to the background:<ProgramListing>$ cd$ nohup postmaster > regress.log 2>&1 &</ProgramListing></para></listitem><listitem><para>Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris 2.5.1 to contain the following single line:<programlisting>su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"</programlisting></para></listitem>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -