当前位置:首页>文章>PHP

LAMP安装实例分享

LAMP指的Linux(操作系统)、Apache(HTTP 服务器),MySQL(数据库软件) 和PHP(有时也是指Perl或Python) 的缩写,一般用来建立web 服务器。

所需软件源代码包:
httpd-2.2.4.tar.gz   mysql-5.0.27.tar.gz   php-5.2.1.tar.bz2
freetype-2.3.2.tar.gz   gd-2.0.34.tar.gz   jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2   libxml2-2.6.24.tar.bz2  zlib-1.2.2.tar.gz
安装顺序:apache -> mysql -> freetype -> jpegsrc.v6b -> libpng -> libxml -> zlib -> gd -> php  ( freetype,jpegsrc.v6b,libxml,zlib,libpng 的安装顺序不限)
约定目录:/usr/local/src  软件源代码包存放位置
          /usr/local/software_name  源码包编译安装位置
安装命令:
1  apache
# cd  /usr/local/src
# t ar  xzvf  http-2.2.4.tar.gz
# cd  http-2.2.4
# ./configure /
        "--prefix=/usr/local/apache2" /
        "--enable-module=so" /
        "--enable-deflate=shared" /
        "--enable-expires=shared" /
        "--enable-rewrite=shared" /
        "--enable-static-support" /
        "--enable-static-htpasswd" /
        "--enable-static-htdigest" /
        "--enable-static-rotatelogs" /
        "--enable-static-logresolve" /
        "--enable-static-htdbm" /
        "--enable-static-ab" /
        "--enable-static-checkgid" /
        "--disable-userdir" 
# make
# make install
# /usr/local/apache2/bin/apachectl start 
出现错误的话就是因为域名的关系,直接从http.conf里面修改把域名改成本地IP
# /usr/local/apache2/bin/apachectl stop
2.  mysql
# tar xzvf mysql-5.0.27.tar.gz
# cd mysql-5.0.27
# ./configure /
        "--prefix=/usr/local/mysql" /
        "--localstatedir=/var/lib/mysql" /
        "--with-comment=Source" /
        "--with-server-suffix=-Comsenz" /
        "--with-mysqld-user=mysql" /
        "--without-debug" /
        "--with-big-tables" /
        "--with-charset=" / #这个后边需要指定你所需要的字符集参数(utf8......)
        "--with-collation= " / #字符集校正码(utf8_general_ci,......)
        "--with-extra-charsets=all" /
        "--with-pthread" /
        "--enable-static" /
        "--enable-thread-safe-client" /
        "--with-client-ldflags=-all-static" /
        "--with-mysqld-ldflags=-all-static" /
        "--enable-assembler" /
        "--without-isam" /
        "--without-innodb" /
        "--without-ndb-debug"
# make
# make install
# useradd mysql
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . (注意后面的点)
# chown -R mysql /var/lib/mysql
# cp share/mysql/my-huge.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start (启动mysql)
# bin/mysqladmin -u root password "password_for_root"  (改密码)  
3 安装库
(1)libxml
# cd /usr/local/src
# tar xjvf libxml2-2.6.24.tar.bz2
# cd libxml2-2.6.24
# ./configure --prefix=/usr/local/libxml2
# make
# make install
(2)jpeg6
建立目录
# mkdir /usr/local/jpeg6 
# mkdir /usr/local/jpeg6/bin 
# mkdir /usr/local/jpeg6/lib 
# mkdir /usr/local/jpeg6/include 
# mkdir /usr/local/jpeg6/man 
# mkdir /usr/local/jpeg6/man/man1
# cd /usr/local/src
# tar vzxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
(3)freetype
# cd /usr/local/src
# tar zvxf freetype-2.3.2.tar.gz 
# cd freetype-2.3.2
# ./configure --prefix=/usr/local/freetype 
# make
# make install
(4)zlib
# cd /usr/local/src
# tar zvxf zlib-1.2.2.tar.gz 
# cd zlib-1.2.2
# ./configure –prefix=/usr/local/zlib
# make
# make install
(5) libpng
# cd /usr/local/src
# tar zjvf libpng-1.2.8.tar.bz2
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make 
# make install
(6)gd
# cd/usr/local/src
# tar xzvf gd-2.0.34.tar.gz
# cd gd-2.0.34
#./configure --prefix=/usr/local/gd2 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6 –with-libxml=/usr/local/libxml2
# make
# make install
4  php
# cd /usr/local/src
# tar xvjf php-5.2.1.tar.bz2
# cd php-5.2.1
#./configure 
--prefix=/usr/local/php 
--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ 
--with-libxml-dir=/usr/local/libxml2 
--with-gd=/usr/local/gd2/ 
--with-jpeg-dir=/usr/local/jpeg6/ 
--with-zlib-dir=/usr/local/zlib 
--with-png-dir=/usr/local/lib
--with-freetype-dir=/usr/local/freetype 
--enable-xml 
--enable-mbstring 
--enable-sockets
# make
# make install
# cp php.ini-dist /etc/php.ini
装完php重启apache和mysql 看是否运行正常,若无报错信息。就可以开始修改配置文件了。如果出错,需要重新编译,在重新编译之前要运行make clean或make disclean清除先前的编译环境
整合apache和php
# vi /usr/local/apache2/conf/httpd.conf
在AddType application/x-gzip .gz .tgz下边添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
注意.php前有一个空格
把DirectoryIndex index.html改成
DirectoryIndex index.html index.php
修改虚拟目录
#vi /etc/php.ini
把register_globals = Off  改成register_globals = On
最后重启apache mysql 写个测试页

若看到php信息则成功。

相关阅读: