mirror of https://github.com/tLDP/LDP
filename change; request of author
This commit is contained in:
parent
d6a0887a1d
commit
47c01e5990
|
@ -1,348 +0,0 @@
|
|||
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
|
||||
<article>
|
||||
|
||||
<artheader>
|
||||
<title>Sybase-PHP-Apache mini-HOWTO</title>
|
||||
<author>
|
||||
<firstname>Tyson</firstname>
|
||||
<othername>Lloyd</othername>
|
||||
<surname>Thwaites</surname>
|
||||
<affiliation>
|
||||
<address><email>tyson.lloydthwaites@ite.com.au</email></address>
|
||||
</affiliation>
|
||||
</author>
|
||||
|
||||
<abstract><para>This HOWTO explains how to set up a Linux machine to run
|
||||
an Apache web server using PHP to access a Sybase-ASE
|
||||
database. </para>
|
||||
</abstract>
|
||||
|
||||
<revhistory>
|
||||
<revision>
|
||||
<revnumber>1.1</revnumber>
|
||||
<date>2001-05-29</date>
|
||||
<authorinitials>TLT</authorinitials>
|
||||
<revremark>Updated environment configuration section, changed HOWTO name.</revremark>
|
||||
</revision>
|
||||
</revhistory>
|
||||
|
||||
</artheader>
|
||||
|
||||
<sect1 id="copyright"><title>Copyright and License</title>
|
||||
<para>This document is copyright 2001 by Tyson Lloyd Thwaites, and is released under the
|
||||
terms of the GNU Free Documentation License, which is hereby incorporated
|
||||
by reference. Send feedback to
|
||||
<ulink url="mailto:tyson.lloydthwaites@ite.com.au"><citetitle>tyson.lloydthwaites@ite.com.au</citetitle></ulink>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="instlinux"><title>Install Linux</title>
|
||||
<para>
|
||||
This howto assumes you have already installed a working Linux system.
|
||||
This howto is based on a Redhat 6.2 system. I would appreciate any
|
||||
feedback on setting this up on other distros.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The first thing you will have to do is uninstall the <filename>apache</filename>
|
||||
and <filename>mod_php</filename> rpms. Try the following:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
# rpm -e apache
|
||||
# rpm -e httpd
|
||||
# rpm -e mod_php
|
||||
# rpm -e php
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
That should get rid of them. Just to be sure, run this:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
# rpm -qa | less
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
and check that there is nothing to do with Apache or PHP
|
||||
left on you system.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="instsybase"><title>Install Sybase</title>
|
||||
<para>
|
||||
Download the Sybase-ASE files from
|
||||
<ulink url="http://linux.sybase.com">linux.sybase.com</ulink>. Sybase-ASE 11.0.3.3 is
|
||||
free for production. This howto refers to that version.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
First, install the Sybase RPMS as root:
|
||||
</para>
|
||||
<programlisting>
|
||||
# rpm -ivh sybase-ase-11_0_3_3-6_i386.rpm
|
||||
# rpm -ivh sybase-doc-11_0_3_3-6_i386.rpm
|
||||
# rpm -ivh sybase-ocsd-10_0_4-6_i386.rpm
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
For information on how to configure Sybase, read the instructions in the
|
||||
file <filename>/opt/sybase/doc/howto/howto-ase-quickstart.html</filename>. This document is very
|
||||
good, so we shouldn't need any more information here.
|
||||
</para>
|
||||
|
||||
<note><title>Hint</title><para>
|
||||
After you have installed the sample database and run a select against it,
|
||||
you can stop following the instructions. The rest of the howto goes on
|
||||
to uninstall the sample database, but we want to keep it for testing later.
|
||||
</para></note>
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="config"><title>Configure Environment</title>
|
||||
<para>
|
||||
After installing Sybase, you need to setup the Linux environment in order
|
||||
to allow clients to connect to the dataserver.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The first thing we need to do is to set certain environment variables in
|
||||
<filename>/etc/profile</filename>. Open <filename>/etc/profile</filename>
|
||||
as super user and insert the following lines:
|
||||
</para>
|
||||
<programlisting>
|
||||
export SYBASE=/opt/sybase
|
||||
export SYBPLATFORM=linux
|
||||
export LD_LIBRARY_PATH=$SYBASE/lib
|
||||
export LC_ALL=default
|
||||
export PATH="$SYBASE/bin:$PATH"
|
||||
export DSQUERY=SYBASE
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Next you need to change to permissions of the Sybase directory. This fixes
|
||||
some problems where PHP is unable to connect to the Sybase server.
|
||||
Run the following command as super user:
|
||||
</para>
|
||||
<programlisting>
|
||||
chown -R sybase:sybase /opt/sybase
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
To test whether your Sybase environment works, type the following:
|
||||
</para>
|
||||
<programlisting>
|
||||
# su - nobody
|
||||
$ isql -Usa -P
|
||||
1> sp_helpdb
|
||||
2> go
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
You should see a list of databases. To test whether you can use the sample
|
||||
datebase, now type:
|
||||
</para>
|
||||
<programlisting>
|
||||
1> use pubs2
|
||||
2> go
|
||||
1> select * from titles
|
||||
2> go
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If you a list, you have sucessfully set up Sybase.
|
||||
</para>
|
||||
|
||||
<note><title>NOTE</title><para>
|
||||
You may need to do the following in order for PHP to be able to access
|
||||
Sybase. Edit the file /opt/sybase/install/rc.sybase and remove the line
|
||||
that says:</para>
|
||||
<programlisting>
|
||||
unset LANG; unset LC_ALL; \ </programlisting>
|
||||
<para>
|
||||
I don't know why that line is there, but it can stuff things up.
|
||||
</para></note>
|
||||
|
||||
<para>
|
||||
You may also want to add sybase to the list of services to run at boot
|
||||
time. To do this execute the following commands:
|
||||
</para>
|
||||
<programlisting>
|
||||
# ln -s /opt/sybase/install/rc.sybase /etc/rc.d/init.d/sybase
|
||||
# ln -s /etc/rc.d/init.d/sybase /etc/rc.d/init.d/S15sybase
|
||||
# ln -s /etc/rc.d/init.d/sybase /etc/rc.d/init.d/K15sybase
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now Sybase will start at boot time.
|
||||
</para>
|
||||
|
||||
<sect2 id="preapache"><title>Preconfigure Apache</title>
|
||||
<para>
|
||||
Download and unpack the latest Apache distribution. In the Apache
|
||||
directory issue the following command:
|
||||
</para>
|
||||
<programlisting>
|
||||
# ./configure --prefix=/usr/local/apache
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
I think the 'prefix' value specifies where you want to store your html files;
|
||||
I just set it to the same as the apache install directory, where Apache will
|
||||
put its files when you run '<command>make install</command>'.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="instphp"><title>Install PHP</title>
|
||||
<para>
|
||||
Download the latest PHP distribution and unpack it.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Change to the <filename>php</filename> directory and run the <command>configure</command>
|
||||
script. You need to pass
|
||||
certains options to the script. To enable PHP access Sybase, you
|
||||
need <command>--with-sybase-ct</command>. You will also need to specify the web server interface
|
||||
to use; in our case, this is Apache, so we use <command>--with-apache</command>
|
||||
To build a CGI version of PHP, (which is also very useful as a shell scripting tool), just leave
|
||||
out the --with-apache.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Here is a complete configure script with the above two options, as well as
|
||||
a number of other options that are useful.
|
||||
</para>
|
||||
<programlisting>
|
||||
# ./configure --with-apache=../apache_1.3.19
|
||||
--with-sybase-ct=/opt/sybase --enable-bcmath --enable-calendar
|
||||
--enable-ctype --enable-exif --enable-ftp --enable-gd-imgstrttf
|
||||
--with-gd --enable-trans-sid --enable-shmop --enable-sockets
|
||||
--enable-sysvsem --enable-sysvshm --enable-wddx
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
You will need to change to apache path to wherever you unpacked your apache
|
||||
distribution.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If the configure scripts completes successfully, you can then proceed:
|
||||
</para>
|
||||
<programlisting>
|
||||
# make && make install
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
PHP should compile without any hitches. After it has installed, you need
|
||||
to install the <filename>php.ini</filename> file:
|
||||
</para>
|
||||
<programlisting>
|
||||
# cp php.ini-optimized /usr/local/lib/php.ini
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now we need to change a few things in <filename>/usr/local/lib/php.ini</filename>. Set the
|
||||
following parameters to the ones specified below:
|
||||
</para>
|
||||
<programlisting>
|
||||
magic_quotes_sybase = on
|
||||
sybct.min_server_severity = 11
|
||||
sybct.min_client_severity = 11
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
I also like to set the following:
|
||||
</para>
|
||||
<programlisting>
|
||||
register_globals = on
|
||||
include_path=.:/usr/local/lib/php
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
You have now completed the PHP installation.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
||||
<sect1 id="instapache"><title>Install Apache</title>
|
||||
<para>
|
||||
Now <command>cd</command> back into the apache unpack directory. Issue the following commmands:
|
||||
</para>
|
||||
<programlisting>
|
||||
# ./configure --activate-module=src/modules/php4/libphp4.a
|
||||
# make && make install
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
This should proceed without any problems. When its done, edit the file
|
||||
<filename>/usr/local/apache/conf/httpd.conf</filename> and uncomment the following line:
|
||||
</para>
|
||||
<programlisting>
|
||||
AddType application/x-httpd-php .php
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
This tells apache to allow PHP to process files with a <filename>.php</filename> extension. You
|
||||
may also want to add some other extensions to the end of this line, eg:
|
||||
</para>
|
||||
<programlisting>
|
||||
AddType application/x-httpd-php .php .php3 .html .htm
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
You now have all the software you need and are ready to test your system.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="testsys"><title>Test the System</title>
|
||||
<para>
|
||||
First, make sure Apache and Sybase are started:
|
||||
</para>
|
||||
<programlisting>
|
||||
# /usr/local/apache/bin/apachectl start
|
||||
# /opt/sybase/install/rc.sybase start
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Now go to the directory <filename>/usr/local/apache/htdocs</filename>.
|
||||
Create a file called <filename>test.php</filename> and insert the following contents:
|
||||
</para>
|
||||
<programlisting>
|
||||
<?php
|
||||
$con = sybase_connect("SYBASE", "sa", "");
|
||||
sybase_select_db("pubs2");
|
||||
$qry = sybase_query("select * from titles", $con);
|
||||
|
||||
echo sybase_result($qry, 1, "copy");
|
||||
|
||||
sybase_close($con);
|
||||
?>
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Save the file and then access the following URL in your browser:
|
||||
</para>
|
||||
<programlisting>
|
||||
http://localhost/test.php
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
If you see some text, then congratulations! You have a complete
|
||||
Linux/Apache/PHP/Sybase-ASE installation. If not...well, there you go.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<ulink url="mailto:tyson.lloydthwaites@ite.com.au">Email me</ulink> if
|
||||
you have any problems, corrections (please!) or additions, but please
|
||||
do not email me unless you have tried everything in this howto!
|
||||
Thanks.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
</article>
|
||||
|
||||
|
Loading…
Reference in New Issue