Monday, May 14, 2007

LAMP (php+mysql+apache)

1.prepare to install

main install file:

httpd-2.2.0.tar.gz
mysql-max-5.0.21-linux-i686-glibc23.tar.gz
php-5.1.2.tar.gz

php install file:

libxml2-2.6.19.tar.gz
libxslt-1.1.15.tar.gz
ActivePerl-5.8.8.817-i686-linux-2.2.17-gcc-257965.rpm
curl-7.15.0.tar.gz

we can download from this web:

http://ftp.gnome.org/pub/GNOME/sour...2-2.6.19.tar.gz
http://ftp.gnome.org/pub/GNOME/sour...t-1.1.15.tar.gz
http://downloads.activestate.com/Ac...-i686-linux.rpm
http://curl.haxx.se/download/curl-7.15.0.tar.gz

http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
http://keihanna.dl.sourceforge.net/...e-2.1.10.tar.gz
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://nchc.dl.sourceforge.net/sour...ng-1.2.8.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz

2.Install Apache2

# cd /home/software/
# tar -zvxf httpd-2.2.0.tar.gz
# cd httpd-2.2.0
# mkdir -p /usr/local/apache2
# ./configure --prefix=/usr/local/apache
or
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make; make install
install apache
# vi /usr/local/apache/conf/httpd.conf
#ServerName www.example.com:80

save and exit

# /usr/local/apache/bin/apachectl -k start
start up apahce
# /usr/local/apache/bin/apachectl -k stop
shut down apache?

3.Install mySQL

# cd /home/software/
# tar -zvxf mysql-max-5.0.21-linux-i686-glibc23.tar.gz
# mkdir -p /usr/local/mysql
# cp -r mysql-max-5.0.21-linux-i686-glibc23.tar.gz /usr/local/mysql
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

add mysql user and group
# groupadd mysql
# useradd -g mysql mysql
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
# /usr/local/mysql/scripts/mysql_install_db --user=mysql&
start up mysql server
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
If we can see" Starting mysqld daemon with databases from /usr/local/mysql/data"
It show that we have started mysql server, pressCtrl + C to out
change root password
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"

4.Install GD

a.install jpeg6
create menu:
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1

# cd /home/xiutuo/software/
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install

b.install libpng
# cd /home/software/
# tar -zvxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install

c.install freetype
# cd /home/software/
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make;make install

d.:install zlib
# cd /home/xiutuo/software/
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure
# make;make install

e.install GD
# cd /home/software/
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/
--with-png=/usr/local/lib/
--with-zlib=/usr/local/lib/
--with-freetype=/usr/local/freetype/
# make; make install

f.install Curl
# cd /home/xiutuo/software/
# tar -zxf curl-7.15.0.tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make; make install

5:install php5,php5 need libxml2 to support!

a.install libxml2
# cd /home/xiutuo/software/
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install

b.install libxslt
# cd /home/software/
# tar -zxf libxslt-1.1.15.tar.gz
# mkdir -p /usr/local/libxslt
# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install

c.install php5
# cd /home/software/
# tar -zvxf php-5.1.2.tar.gz
# mkdir -p /usr/local/php
# cd php-5.05
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-curl=/usr/local/curl --enable-ftp
--with-libxml-dir=/usr/local/libxml2
--with-expat-dir=/usr/lib --enable-soap
--with-xsl=/usr/local/libxslt --enable-xslt
--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-zlib-dir=/usr/local/lib/
--with-png=/usr/local/lib/
--with-freetype-dir=/usr/local/zlib/
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini (never forget)

after "./configure"
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
This is necessary

--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png=/usr/local/lib
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
make PHP to support GD

--with-curl=/usr/local/curl support CURL
--enable-ftp

--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
make PHP to support SOAP

6.config Apache2 to make it support PHP

config httpd.conf to support PHP
# vi /usr/local/apache/conf/httpd.conf
find AddType application/x-gzip .gz .tgz and add this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

restart apache
# /usr/local/apache/bin/apachectl restart



mysql
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql.sock --without-comment --without-debug --without-bench
./bin/mysqld_safe &



$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

printf("Host information: %s\n", $mysqli->host_info);

/* close connection */
$mysqli->close();
?>