首页 > 代码库 > Linux lamp环境编译安装

Linux lamp环境编译安装

1、安装准备:
1)httpd-2.0.52.tar.gz
2)mysql-4.1.12.tar.gz
3)libxml2-2.6.27.tar
4)freetype-2.1.10.tar
5)gd-2.0.33.tar
6)jpegsrc.v6b.tar
7)libpng-1.2.16.tar
8)zlib-1.2.3.tar
9)freetds-0.64.tar.gz
10)php-4.3.9.tar.gz
11)phpMyAdmin292.tar.gz
12)ZendOptimizer-3.2.6-linux-glibc21-i386.tar
在系统中建立user:soft
  # groupadd soft
  # useradd -g soft soft
# passwd soft
将安装所需文件拷贝到/home/soft中

/////////////////////////////////////////////////////////////////////
2、安装apache
在系统中建立user:apache
  # groupadd apache
  # useradd -g apache -d /usr/local/apache apache
# passwd apache
安装:
# cd /home/soft
  # tar zxvf httpd-2.0.52.tar.gz
  # cd httpd-2.0.52
  # ./configure --prefix=/usr/local/apache --datadir=/www --enable-mods=shared=all --enable-module=so --disable-info --enable-shared=max --enable-rule=SHARED_CORE
  # make
  # make install
配置:
  # vi /usr/local/apache/conf/httpd.conf
   更改一下两行:
User nobody
Group #-1
为:
User apache
Group apache
保存退出

更改APACHE目录的所属
  # chown -R apache.apache /usr/local/apache

  # vi /usr/local/apache/bin/apachectl
在第四行后添加
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
保存退出

接下来设置apache的自启动及运行等级
  # cd /etc/rc.d/init.d
  # cp /usr/local/apache/bin/apachectl httpd
  # chmod 755 httpd

  # chkconfig --add httpd
# chkconfig --level 345 httpd on
# chkconfig --level 0126 httpd off
启动与关闭httpd服务
  # service httpd start/stop/restart

//////////////////////////////////////////////////////////////////////////////////////////
3、安装MySQL
在系统中建立user:mysql
  # groupadd mysql
  # useradd -g mysql -d /mysql mysql
# passwd mysql
在系统中建立mysql,data目录
# cd /mysql
  # mkdir tmp
  # chown -R mysql.mysql /mysql
# chown -R mysql.mysql /data
# chmod -R 777 /mysql
# chmod -R 777 /data

安装:
# cd /home/soft
  # tar zxvf mysql-5.0.22.tar.gz
  # cd mysql-5.0.22
  # ./configure --prefix=/mysql --localstatedir=/data --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-mysqld-user=mysql --enable-assembler --with-extra-charsets=all --with-unix-socket-path=/mysql/tmp/mysql.sock
  # make
  # make install
若为普通服务器则采用如下的配置
  # cp support-files/my-huge.cnf /etc/my.cnf
若为大型的服务器,则采用
# cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf
初始化数据库:
  # scripts/mysql_install_db --user=mysql
  文件权限修改
# chown -R mysql.mysql /mysql
# chown -R mysql.mysql /data
# chmod -R 777 /mysql
# chmod -R 777 /data

启动数据库
# cd /mysql 
  # share/mysql/mysql.server start &

修改数据库ROOT用户密码为ABCabc123
  # bin/mysqladmin -u root password "ABCabc123;"

  接下来设置mysql的自启动及运行等级
  # cd /etc/rc.d/init.d
  # cp /home/soft/mysql-5.0.22/support-files/mysql.server mysqld
  # chmod 755 mysqld
  # chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# chkconfig --level 0126 mysqld off
  启动与关闭MYSQLD服务
  # service mysqld start/stop/restart

/////////////////////////////////////////////////////////////////////////////////////////////
4、安装GD库

1).libxml2安装(支持xml)
# cd /home/soft
# tar -zxvf libxml2-2.6.27.tar.gz
# cd libxml2-2.6.27
# ./configure --prefix=/usr/local/libxml2
# make
# make install

2).zlib安装
# cd /home/soft
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure --prefix=/usr/local/zlib
# make
# make install

3).安装 jpeg6
建立目录:
# 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/man/man1
# cd /home/soft
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
///////////////////////////////////////////////////////////////////////////////

4).安装libpng
# cd /home/soft
# tar -zvxf libpng-1.2.16.tar.gz
# cd libpng-1.2.16
# ./configure
# make
# make install

5).安装 freetype
# cd /home/soft
# 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

6)安装GD库
# cd /home/soft
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
# make
# make install

5.安装的freetds
安装:
# cd /home/soft
# tar zxvf freetds-0.64.tar.gz
# cd freetds-0.64
# ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld
# make
# make install

/////////////////////////////////////////////////////////////////////////////////////////////
5、安装PHP
  # cd /home/soft
# tar zxvf php-4.3.9.tar.gz
  # cd php-4.3.9
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-sockets --with-mysql=/mysql --with-mssql=/usr/local/freetds --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype --with-zlib --with-png --enable-gd-native-ttf --enable-magic-quotes --with-iconv --with-mbstring --enable-track-vars --enable-force-cgi-redirect --enable-calendar --with-gettext --with-gdbm --with-ttf --with-extra-charsets_complex --with-msdblib --enable-module=dso --with-versioning --enable-libxml --enable-so

# make
  # make install
  # cp php.ini-dist /usr/local/php/lib/php.ini


6、整合配置
更新链接库及添加PHP识别
  # vi /etc/ld.so.conf
  在最后添加 /mysql/lib /usr/local/php/modules/freetds/lib
保存退出
  # ldconfig

  APACHE支持PHP
# vi /usr/local/apache/conf/httpd.conf

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
下添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

AddDefaultCharset UTF-8
改为:
AddDefaultCharset gb2312

修改
<Files ~ "^\.ht">
Order allow,deny
deny from all
</Files>

<Files ~ "^\.ht">
Order allow,deny
allow from all
</Files>


DirectoryIndex index.html index.html.var
后加上
index.php

DirectoryIndex index.html index.html.var index.php
保存退出

修改PHP配置参数
  # vi /usr/local/php/lib/php.ini
修改 register_globals = On;
magic_quotes_gpc = Off;
进行php.ini文件的配置工作
(1)查找safe_mode = Off,更改为safe_mode=On
(2)查找max_execution_time = 30,更改为max_execution_time = 600
(3)查找max_input_time = 60,更改为max_input_time = 600
(4)查找memory_limit = 8M ,更改为memory_limit = 20M
(5)查找display_errors = On,更改为display_errors = Off
(6)查找post_max_size = 8M,更改为post_max_size = 20M
(7)查找upload_max_filesize = 2M,更改为upload_max_filesize = 20M
(8)查找session.auto_start = 0,更改为session.auto_start = 1
保存后退出,从而完成了php.ini文件的配置工作。

7、安装ZendOptimizer
  # cd /home/soft
# tar xvf ZendOptimizer-3.2.6-linux-glibc21-i386.tar
  # cd ZendOptimizer-3.2.6-linux-glibc21-i386
# ./install.sh
(请注意apachectl 和 php.ini文件的目录)


lqqqqqqqqq Zend Optimizer 3.2.6 qqqqqqqqqqk
x x
x Enter the location of your php.ini file x
x x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x/usr/local/php/lib x x
x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
x < OK > <Cancel> x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj


8、安装phpmyadmin
# cd /home/soft
# tar -zxvf phpMyAdmin-2.9.2.tar.gz
# cp -R phpMyAdmin-2.9.2/ /www
修改配置文件phpMyAdmin-2.8.1/libraries/config.default.php。将:
$cfg[‘Servers‘][$i][‘auth_type‘] = ‘config‘; (71行)
cfg[‘DefaultConnectionCollation‘] = ‘utf8_unicode_ci‘; (395行)
// $cfg[‘Lang‘] = ‘en-iso-8859-1‘; (399行)
改为:
$cfg[‘Servers‘][$i][‘auth_type‘] = ‘http‘;
//cfg[‘DefaultConnectionCollation‘] = ‘utf8_unicode_ci‘;
$cfg[‘Lang‘] = ‘zh-gb2312‘;
修改配置文件phpMyAdmin-2.8.1/ libraries/select_lang.lib.php。将:
$mysql_charset_map = array( (362行)
‘big5‘ => ‘big5‘,
‘cp-866‘ => ‘cp866‘,
‘euc-jp‘ => ‘ujis‘,vi
‘euc-kr‘ => ‘euckr‘,
‘gb2312‘ => ‘gb2312‘
改为:
$mysql_charset_map = array(
‘big5‘ => ‘big5‘,
‘cp-866‘ => ‘cp866‘,
‘euc-jp‘ => ‘ujis‘,
‘euc-kr‘ => ‘euckr‘,
‘gb2312‘ => ‘latin1‘