LAMP

除了perl,其他用的都是源码包安装的

环境是在freebsd6.0下

装完freebsd之后,可能是我编译perl的时候不对,所以就用ports自带的perl了

perl在/usr/ports/lang下面

我装的5.8

cd /usr/ports/lang/perl5.8

make
make test
make install

装完perl就继续装mysql

下载的是mysql-5.0.24.tar.gz

安装
代码:
# tar -zxvf mysql-5.0.24.tar.gz
# cd mysql-5.0.24
# ./configure --prefix=/usr/local/mysql
# make
# make install
# make clean

创建mysql用户

代码:
# pw group add mysql
# pw user add mysql -g mysql

初始化表
代码:
# /usr/local/mysql/bin/mysql_install_db --user=mysql

设置目录访问权限
代码:
# cd /usr/local/mysql
# chown -R root . (设定root可以访问/usr/local/mysql目录)
# chown -R mysql var (设定mysql用户能访问/usr/local/mysql/var目录,该目录中存放mysql的数据库文件)
# chown -R mysql var/. (设定mysql用户能访问/usr/local/mysql/var目录下的所有文件)
# chown -R mysql var/mysql/. (设定mysql用户能访问/usr/local/mysql/var/mysql目录下的所有文件)
# chgrp -R mysql . (设定mysql组能访问/usr/local/mysql目录)

运行
代码:
使用命令 # /usr/local/mysql/bin/mysqld_safe --user=mysql & 测试安装是否成功
如果显示
[1]
# Starting mysqld daemon with database from /usr/local/mysql/var
表示安装成功

开机自动启动mysql

代码:
在/usr/local/etc/rc.d目录中编辑文件 mysql_start.sh ,内容如下
#! /bin/sh
/usr/local/mysql/bin/mysqld_safe &
设置文件权限为可执行
# chmod +x mysql_start.sh

Apache2 的安装

下载的是httpd-2.0.58.tar.gz

代码:
# tar -zxvf httpd-2.0.58.tar.gz
# cd httpd-2.0.58
# ./configure --prefix=/usr/local/apache2 --enable-shared=max --enable-module=rewrite --enable-so
# make
# make install
# make clean

开机自动加载apache服务
代码:
在/usr/local/etc/rc.d目录中编辑文件 apache_start.sh
#! /bin/sh
/usr/local/apache2/bin/httpd -k start
设置文件权限
# chmod +x apache_start.sh


PHP5 的安装
因为我要用到GD库等一堆东西,所以加载的比较多一点

libxml2安装
源代码:libxml2-2.6.22.tar.gz
安装
代码:
# tar -zxvf libxml2-2.6.22.tar.gz
# cd libxml2-2.6.22
# ./configure
# make
# make install
# make clean

zlib安装
源代码:zlib-1.2.3.tar.gz
安装
代码:
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make
# make install
# make clean
libpng安装
源代码:libpng-1.2.9.tar.gz
安装
代码:
# tar -zxvf libpng-1.2.9.tar.gz
# cd libpng-1.2.9
# cp scripts/makefile.std makefile
编辑 makefile 将 prefix 改为 prefix=/usr/local/libpng2
# make
# mkdir /usr/local/libpng2
# make install
# make clean

jpeg安装
源代码:jpegsrc.v6b.tar.gz
安装
代码:
# tar -zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6 --enable-shared
# make
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# make install-lib
# make install
# make clean

GD安装
源代码:gd-2.0.33.tar.gz
安装
代码:
# tar -zxvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-zlib --with-png=/usr/local/libpng2 --with-jpeg=/usr/local/jpeg6
编辑 Makefile 231行 将
CPPFLAGS = -I/usr/local/jpeg6/include
改为
CPPFLAGS = -I/usr/local/jpeg6/include -I/usr/local/libpng2/include
# make
# make install
# make clean

libiconv安装
源代码:libiconv-1.9.2.tar.gz
安装
代码:
# tar -zxvf libiconv-1.9.2.tar.gz
# cd libiconv-1.9.2
# ./configure --prefix=/usr/local/libiconv
# make
# make install
# make clean

将iconv.h连接到php的安装源程序中,否则会php make会出错
# cd /usr/home/ty/php-5.1.4/ext/iconv/
#这里的php-5.1.4就是下面解压缩的路径
# link /usr/local/libiconv/include/iconv.h iconv.h

开始安装PHP5
源代码:php-5.1.4.tar.gz
安装
代码:
# tar -zxvf php-5.1.4.tar.gz
# cd php-5.1.4
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-xml --with-mysql=/usr/local/mysql --with-zlib --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng2 --with-iconv=/usr/local/libiconv --with-config-file-path=/usr/local/lib --disable-debug --enable-safe-mode --enable-trans-sid --enable-memory-limit --enable-short-tags --disable-posix --enable-exif --enable-ftp --enable-sockets

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

把php加到apache里去
代码:
# vi /usr/local/apache2/conf/httpd.conf

添加
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
#红色的在我的httpd.conf里已经添加好了的

然后放个test.php文件上去 测试看看成功
vi /usr/local/apache2/htdocs/test.php
PHP 代码:
<?
phpinfo();
?>

你可能感兴趣的:(linux,职场,lamp,休闲)