December 18, 2009

Installation of LAMP

Installation of LAMP


httpd-2.0.47.tar.gz http://httpd.apache.org/download.cgi
php-4.3.3.tar.gz http://www.php.net/downloads.php
mysql-4.0.16.tar.gz http://www.mysql.com/get/Downloads/MySQL-4.0/mysql-4.0.16.tar.gz/from/pick#mirrors

The next step involves Apache installation according to the instructions listed below:


1. create a group named websrv

[root@server.net]#groupadd websrv


2. add a user with minimum privileges

[root@server.net]#adduser websrv -g websrv -s /sbin/nologin -d /usr/local/apache


3. unpack a source archive

[root@server.net]#tar -zxvf httpd-2.0.47.tar.gz


4. enter the unpacked directory

[root@server.net]#cd httpd-2.0.47


5. configure the Apache server with DSO support

[root@server.net]#./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so


6. compile the sources

[root@server.net]#make


7. install the compiled binaries and other files

[root@server.net]#make install


8. add the line "/usr/local/apache/modules" into /etc/ld.so.conf

[root@server.net]#echo "/usr/local/apache/modules" >> /etc/ld.so.conf


9. create cache & links for shared libs

[root@server.net]#ldconfig

The following operations requires your intent attention:

10. open /usr/local/apache/conf/httpd.conf using your favorite editor, find AddType directive and add after it the following lines:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Note: after the .php extension you can add as much other extensions as you wish in accordance with the syntax: AddType MIME-type extension [extension] [extension]...

11. find DirectoryIndex Directive and set the list of files to look for. The server will return the first available one. In the further example, index.php will be shown if it exists, otherwise the server will look for index.html:

DirectoryIndex index.php index.html

12. find User Directive and Group Directive. Change whatever you have there to:

User websrv
Group websrv

13. double check your changes, save the file and move forward.


14. change Apache ownership to websrv.websrv

[root@server.net]#chown -R websrv.websrv /usr/local/apache


MySQL installation:


1. create a group named mysql

[root@server.net]#groupadd mysql


2. add a user with minimum privileges

[root@server.net]#adduser mysql -g mysql -s /sbin/nologin -d /usr/local/mysql


3 unpack a source archive

[root@server.net]#tar -zxvf mysql-4.0.16.tar.gz


4. enter the unpacked directory

[root@server.net]#cd mysql-4.0.16


5. configure the MySQL server with all charsets

[root@server.net]#./configure --prefix=/usr/local/mysql --with-charset=latin1 --with-extra-charsets=all


6. compile the sources

[root@server.net]#make


7. install the compiled binaries and other files

[root@server.net]#make install


8. add the line "/usr/local/mysql/lib/mysql" into /etc/ld.so.conf

[root@server.net]#echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf


9. create cache & links for shared libs

[root@server.net]#ldconfig


10. create and install default MySQL databases

[root@server.net]#/usr/local/mysql/bin/mysql_install_db


11. make a symbolic link for mysql binary

[root@server.net]#ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql


12. make a symbolic link for mysqladmin binary

[root@server.net]#ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin


13. change MySQL ownership to mysql.mysql

[root@server.net]#chown -R mysql.mysql /usr/local/mysql



PHP installation:


1. unpack a source archive

[root@server.net]#tar -zxvf php-4.3.3.tar.gz


2. enter the unpacked directory

[root@server.net]#cd php-4.3.3


3. configure PHP as Apache module with MySQL support

[root@server.net]#./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql


4. compile the sources

[root@server.net]#make


5. install the compiled Apache module

[root@server.net]#make install


6. copy php.ini-dist to /usr/local/lib/php.ini

[root@server.net]#cp ./php.ini-dist /usr/local/lib/php.ini


7. Give Apache ownership to websrv.websrv

[root@server.net]#chown -R websrv.websrv /usr/local/apache

** On some systems, there is no ld.so.conf file, or it is not in use. You can use LD_LIBRARY_PATH environment variable to specify additional directories where shared libs can be found.

If you use tcsh compatible shell you should add the line below to the .tcshrc file in your home dir:

setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql:/usr/local/apache/modules

For bash compatible shell you should add the following lines to the .bash_profile file in your home dir:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql:/usr/local/apache/modules
export LD_LIBRARY_PATH

Then, check what you have in the library loading path:

echo $LD_LIBRARY_PATH

There is only one open question left: how to startup MySQL and Apache servers?
It's very simple:

[root@server.net]#/usr/local/apache/bin/apachectl start
[root@server.net]#/usr/local/mysql/share/mysql/mysql.server start

(For bringing these servers down, you can use the commands mentioned above replacing start with stop)

To test your installation, create in /usr/local/apache/htdocs directory the php file:

index.php


Load it in your browser: http://localhost/index.php
Then, you should see PHP Configuration settings.

No comments:

Post a Comment