Difference between revisions of "LAMP"

From Christoph's Personal Wiki
Jump to: navigation, search
(Installing PHP 5)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''LAMP''' usually refers to the following [[:Category:Open Source|open source]] configuration:
 
'''LAMP''' usually refers to the following [[:Category:Open Source|open source]] configuration:
* [[Linux|'''L'''inux]]
+
*[[Linux|'''L'''inux]]
* [[Apache|'''A'''pache]]
+
*[[Apache|'''A'''pache]]
* [[MySQL|'''M'''ySQL]]
+
*[[MySQL|'''M'''ySQL]]
* [[PHP|'''P'''HP]] / [[Perl]] / [[Python]]
+
*[[PHP|'''P'''HP]] / [[Perl]] / [[Python]]
  
 
In this article, I will only consider '''PHP''' for LAMP.
 
In this article, I will only consider '''PHP''' for LAMP.
  
== Setting up a LAMP Server ==
+
==Setting up a LAMP Server==
This section will ''only'' consider setting up a LAMP Server for [[SuSE]] Linux (test on version 10.1) and with a 64-bit CPU / x86_64 (tested on a Pentium D processor).
+
This section will ''only'' consider setting up a LAMP Server for [[SuSE]] Linux (tested on version 10.1) and with a 64-bit CPU / x86_64 (tested on a Pentium D processor). Most of it will be the same for a 32-bit system.
  
=== Installing SuSE Linux ===
+
see also: [[LAMP on Mandriva]]
 +
 
 +
===Installing SuSE Linux===
 
Note: Tested on version 10.1
 
Note: Tested on version 10.1
  
 
''under construction''
 
''under construction''
  
=== Installing MySQL ===
+
===Installing MySQL===
 
  see: [[MySQL]]
 
  see: [[MySQL]]
  
=== Installing Apache HTTP Server Version 2 ===
+
===Installing Apache HTTP Server Version 2===
 
Note: Tested on version 2.2.3
 
Note: Tested on version 2.2.3
  
* Step 1: Configuration
+
*Step 1: Configuration (note the "[[mod_rewrite|rewrite]]")
<pre>./configure --enable-so --enable-mods-shared=expires,ssl,headers,http,info,rewrite</pre>
+
./configure --enable-so --enable-mods-shared=expires,ssl,headers,http,info,rewrite
  
* Step 2: Fix built-in errors ''before'' running <tt>make</tt>
+
*Step 2: Fix built-in errors ''before'' running <code>make</code>
For some reason, there is a problem with Apache's default <tt>Makefile</tt>. It looks for <tt>lib64</tt> in the wrong place. It is simple to fix this error.
+
For some reason, there is a problem with Apache's default <code>Makefile</code>. It looks for <code>lib64</code> in the wrong place. It is simple to fix this error.
  
The problem is found in the following two files: <tt>srclib/apr-util/config.status</tt> and <tt>srclib/apr-util/Makefile</tt> (note: both files are created ''after'' you run <tt>./configure</tt>).
+
The problem is found in the following two files: <code>srclib/apr-util/config.status</code> and <code>srclib/apr-util/Makefile</code> (note: both files are created ''after'' you run <code>./configure</code>).
  
 
Note: If you perform the following search, you will clearly see the problem:
 
Note: If you perform the following search, you will clearly see the problem:
<pre>fgrep APRUTIL_LIBS srclib/apr-util/{config.status,config.log,Makefile}</pre>
+
fgrep APRUTIL_LIBS srclib/apr-util/{config.status,config.log,Makefile}
  
The output from <tt>config.status</tt> will have this
+
The output from <code>config.status</code> will have this
 
  ''srclib/apr-util/config.status'':s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite <font color=red>/usr/lib/libexpat.la</font> ...
 
  ''srclib/apr-util/config.status'':s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite <font color=red>/usr/lib/libexpat.la</font> ...
 
instead of this
 
instead of this
 
  ''srclib/apr-util/config.status'':s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite <font color=green>/usr/lib64/libexpat.la</font> ...
 
  ''srclib/apr-util/config.status'':s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite <font color=green>/usr/lib64/libexpat.la</font> ...
The same is true for <tt>Makefile</tt>
+
The same is true for <code>Makefile</code>.
  
* Step 3: Run <tt>make</tt>
+
*Step 3: ''After'' fixing the above errors, you should now be able to successfully run <code>make</code>
''After'' fixing the above errors, you should now be able to successfully run <tt>make</tt>
+
make
 +
make install  # as superuser/root
  
* Step 4: <tt>make install</tt> (as superuser)
+
*Step 4: Test your installation
 +
/usr/local/apache2/bin/apachectl start
 +
Point your browser (i.e., [[Firefox]]) to <code>localhost</code> and you should get an "It works!" or something similar. (Important! Make sure you stop the server ''before'' installing PHP.)
 +
/usr/local/apache2/bin/apachectl stop
  
* Step 5: Test your installation
+
===Installing PHP 5===
<pre>/usr/local/apache2/bin/apachectl start</pre>
+
Note: Tested on versions 4-5.
Point your browser (ie, FireFox) to <tt>localhost</tt> and you should get a "It works!"
+
Also note: the MySQL client library is not bundled with PHP anymore.
<pre>/usr/local/apache2/bin/apachectl stop</pre> (Important! Make sure you stop the server ''before'' installing PHP)
+
  
=== Installing PHP 5 ===
+
*Step 1: Configure and make (note: with my favourite includes)
Note: Tested on version 5.1.4
+
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
 
+
             --with-mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \
* Step 1: Configure (note: with my favourite includes)
+
<pre>
+
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
+
             --with-mysql --with-mysqli=/usr/bin/mysql_config \
+
 
             --with-zlib --with-pear --with-bz2 --enable-calendar \
 
             --with-zlib --with-pear --with-bz2 --enable-calendar \
 
             --enable-exif --with-gd --with-ldap --enable-soap \
 
             --enable-exif --with-gd --with-ldap --enable-soap \
Line 60: Line 61:
 
             --enable-headers --enable-ssl --enable-http --enable-info \
 
             --enable-headers --enable-ssl --enable-http --enable-info \
 
             --enable-dir --enable-rewrite --enable-so --enable-isapi
 
             --enable-dir --enable-rewrite --enable-so --enable-isapi
</pre>
+
make
 +
make install # as superuser/root
 +
 
 +
*Step 2: Setup your <code>php.ini</code>
 +
cp php.ini-dist /usr/local/lib/php.ini
 +
 
 +
*Step 3: Add the following three lines to your <code>httpd.conf</code> (if they are not already present):
 +
LoadModule php5_module modules/libphp5.so
 +
AddType application/x-httpd-php .php .phtml
 +
AddType application/x-httpd-php-source .phps
 +
 
 +
*Step 4: Re-start Apache
 +
/etc/init.d/httpd restart
 +
 
 +
*Step 5: Test PHP with the following (ie, <code>test.php</code> in the <code>/usr/local/apache2/htdocs</code> dir):
 +
<?php phpinfo(); ?>
  
* Step 2: <tt>make</tt>
+
==External links==
* Step 3: <tt>make install</tt>
+
*[http://www.novell.com/coolsolutions/feature/595.html Installing Apache, PHP, and MySQL on SUSE Linux Professional]
* Step 4: Setup your <tt>php.ini</tt>
+
*[http://httpd.apache.org/docs/2.0/howto/public_html.html Per-user web directories] (e.g., <code>/home/*/public_html</code>)
<pre>cp php.ini-dist /usr/local/lib/php.ini</pre>
+
*[http://www.astahost.com/info.php/apaches-userdir-very-own-cgi-bin_t3698.html Apache's Userdir With Very Own Cgi-bin - the non-virtualhost way]
* Step 5: Add the following three lines to your <tt>httpd.conf</tt> (if they are not already present):
+
*[http://apachegrep.sourceforge.net/ apachegrep]
<pre>
+
LoadModule php5_module modules/libphp5.so
+
AddType application/x-httpd-php .php .phtml
+
AddType application/x-httpd-php-source .phps
+
</pre>
+
  
 
[[Category:Technical and Specialized Skills]]
 
[[Category:Technical and Specialized Skills]]

Latest revision as of 08:27, 8 September 2007

LAMP usually refers to the following open source configuration:

In this article, I will only consider PHP for LAMP.

Setting up a LAMP Server

This section will only consider setting up a LAMP Server for SuSE Linux (tested on version 10.1) and with a 64-bit CPU / x86_64 (tested on a Pentium D processor). Most of it will be the same for a 32-bit system.

see also: LAMP on Mandriva

Installing SuSE Linux

Note: Tested on version 10.1

under construction

Installing MySQL

see: MySQL

Installing Apache HTTP Server Version 2

Note: Tested on version 2.2.3

  • Step 1: Configuration (note the "rewrite")
./configure --enable-so --enable-mods-shared=expires,ssl,headers,http,info,rewrite
  • Step 2: Fix built-in errors before running make

For some reason, there is a problem with Apache's default Makefile. It looks for lib64 in the wrong place. It is simple to fix this error.

The problem is found in the following two files: srclib/apr-util/config.status and srclib/apr-util/Makefile (note: both files are created after you run ./configure).

Note: If you perform the following search, you will clearly see the problem:

fgrep APRUTIL_LIBS srclib/apr-util/{config.status,config.log,Makefile}

The output from config.status will have this

srclib/apr-util/config.status:s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite /usr/lib/libexpat.la ...

instead of this

srclib/apr-util/config.status:s,@APRUTIL_LIBS@,-lsqlite3 -lsqlite /usr/lib64/libexpat.la ...

The same is true for Makefile.

  • Step 3: After fixing the above errors, you should now be able to successfully run make
make
make install  # as superuser/root
  • Step 4: Test your installation
/usr/local/apache2/bin/apachectl start

Point your browser (i.e., Firefox) to localhost and you should get an "It works!" or something similar. (Important! Make sure you stop the server before installing PHP.)

/usr/local/apache2/bin/apachectl stop

Installing PHP 5

Note: Tested on versions 4-5. Also note: the MySQL client library is not bundled with PHP anymore.

  • Step 1: Configure and make (note: with my favourite includes)
./configure --with-apxs2=/usr/local/apache2/bin/apxs \
           --with-mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \
           --with-zlib --with-pear --with-bz2 --enable-calendar \
           --enable-exif --with-gd --with-ldap --enable-soap \
           --with-xsl --enable-mime-magic --enable-expires \
           --enable-headers --enable-ssl --enable-http --enable-info \
           --enable-dir --enable-rewrite --enable-so --enable-isapi
make
make install # as superuser/root
  • Step 2: Setup your php.ini
cp php.ini-dist /usr/local/lib/php.ini
  • Step 3: Add the following three lines to your httpd.conf (if they are not already present):
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
  • Step 4: Re-start Apache
/etc/init.d/httpd restart
  • Step 5: Test PHP with the following (ie, test.php in the /usr/local/apache2/htdocs dir):
<?php phpinfo(); ?>

External links