Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Configuring a Basic LAMP Server (Linux, Apache, MySQL, PHP)


  • Please log in to reply

#1
thenotch

thenotch

    Member

  • Retired Staff
  • 668 posts
Configuring a Basic LAMP Server (Linux, Apache, MySQL, PHP) with GD, ZLIB & LIBPNG


You will obviously have a working version of Linux (any flavor will do although I will recommend Debian as it doesn't automatically install a bunch of things you won't need on a server box unless you specifically tell it to).

This guide also assumes you have a basic knowledge of the Linux command line (if you do not, learn that before jumping into a Linux server... Linux boxes perform better on the command line, not with the GUI interface).


NOTE: When you see a "/" at the end of a command line that means to continue tying the next line, for example:

./configure –with-mysql=/usr/local/mysql \
--with-xml --with-gd –with-zlib-dir=/usr/local/lib \


would actually be:

./configure –with-mysql=/usr/local/mysql --with-xml --with-gd –with-zlib-dir=/usr/local/lib

Also where yo see the word VERSION that would be where you type in the version that you are using (the version you downloaded and copied into the /installs directory which is explained below).

Lets begin:

* Change to root

shell>su
<you should be prompted for the root password unless you logged into Linux as root>

* Create a directory named installs wherever you choose, /usr/local is as good a place as any, so type in:

shell>cd /usr/local
shell>mkdir installs
shell>cd installs


* Copy the following files into the /installs directory:

httpd-<version> (http://www.apache.org)
php-<version>.tar.gz (http://www.php.net/downloads.php)
mysql-<version>.tar.gz (http://dev.mysql.com/downloads/)
gd-<version>.tar.gz (http://www.boutell.com/gd/)
libpng-<version>.tar.gz (http://www.libpng.or...png/libpng.html)
zlib-<version>.tar.gz (http://www.zlib.net/)

MySQL
shell> groupadd mysql
shell> su
shell> useradd -g mysql mysql
shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
shell> cd mysql*
shell> ./configure --prefix=/usr/local/mysql
shell> make
shell> make install
shell> scripts/mysql_install_db
shell> chown -R root /usr/local/mysql
shell> chown -R mysql /usr/local/mysql/var
shell> chgrp -R mysql /usr/local/mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
shell> /usr/local/mysql/bin/mysqladmin -u root password newpassword
shell> /usr/local/mysql/bin/mysqlshow –p

ZLIB
shell> cd ..
shell> gunzip zlib-VERSION.tar.gz | tar xvf -
shell> cd zlib*
shell> ./configure
shell> make
shell> make test
shell> make install

LIBPNG
shell> cd ..
shell> gunzip < libpng-VERSION.tar.gz | tar xvf -
shell> cd libpng*
shell> cp scripts/makefile.std makefile
shell> make test
shell> make install

GD
shell> cd ..
shell> gunzip < gd-VERSION.tar.gz | tar xvf –
shell> cd gd*
shell> ./configure
shell> make
shell> make test
shell> make install

Apache
shell> cd ..
shell> gunzip < httpd-VERSION.tar.gz | tar xvf -
shell> cd httpd-VERSION
shell> export CFLAGS=-O2

shell> ./configure --prefix=/var/www --enable-so --enable-auth-digest
shell> make
shell> make install
shell> /var/www/bin/apachectl configtest (should return Syntax OK)

* To start, stop or restart Apache you would issue one of these commands:
Start- /var/www/bin/apachectl start
Stop - /var/www/bin/apachectl stop
Restart - /var/www/bin/apachectl restart

NOTE: The httpd and mysqld services will not start automatically upon system reboot and you will need to manually start and stop them or configure your system to launch the service at boot. That is beyond the scope of this guide and is relevant to the Linux distribution you have choosen. Google is your friend here, so do a search and you will find many relevant guides on how to configure this option in relation to your Linux distro.

I have included how I configured my Apache and MySQL to start automatically under Debian and you can use these as a guide. The instructions are located HERE

PHP
shell> cd ..
shell> gunzip < php-VERSION.tar.gz | tar xvf –
shell> cd php-VERSION
shell> ./configure –with-mysql=/usr/local/mysql \
--with-xml --with-gd –with-zlib-dir=/usr/local/lib \
--with-libpng-dir=/usr/local/lib \
--with-apxs2=/var/www/bin/apxs \
--with-apache2=../httpd-VERSION \
--enable-track-vars
shell> make
shell> make install
shell> cp php.ini-dist /usr/local/lib/php.ini


After installing PHP, edit /var/www/conf/httpd.conf and make the following additions:

* Find DirectoryIndex and at the end of the line add index.php

* In the AddType area add these lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


* Uncomment the #AddHandler cgi-scripts .cgi line

* Create a file in the /var/www/htdocs directory called test.php with the following content:

<? phpinfo(); ?>

Open this file in your browser (http://localhost/test.php) and you should get your PHP information.


You should now have a functional, albeit basic LAMP webserver at this point that supports GD, ZLIB & LIBPNG.

I would recommend looking at the documentation for Apache, MySQL, Perl and PHP to find additional configuration options to tighten up your server and to add additional functionality.


Click HERE for the PDF version of this site

Created and compiled by Nick Burchett


Edited by thenotch, 26 August 2006 - 11:23 AM.

  • 0

Advertisements


#2
thenotch

thenotch

    Member

  • Topic Starter
  • Retired Staff
  • 668 posts
The above HOW-TO has been editted and modified by me as of today (26AUG06).

It should be a little more concise and clear and corrects a few errors in syntax.

I have also added a link to a page I made up for autostarting the httpd and mysqld_safe daemons if you are using Debian.

Edited by thenotch, 26 August 2006 - 11:30 AM.

  • 0

#3
lampdeveloper

lampdeveloper

    New Member

  • Member
  • Pip
  • 2 posts
very nice website for experts

http://www.localdomain.me
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP