LAMP搭建包
首先要安装预编译环境
1.下载apr安装包:
http://labs.mop.com/apache-mirror//apr/apr-1.4.6.tar.gz
tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
2.下载apr-util安装包:
http://labs.mop.com/apache-mirror//apr/apr-util-1.4.1.tar.gz
tar zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util --with-
apr=/usr/local/apr/bin/apr-1-config
make && make install
3.下载pcre安装包:
http://cdnetworks-kr-2.dl.sourceforge.net/project/pcre/pcre/8.30/pcre-8.30.zip
unzip pcre-8.30.zip
cd pcre-8.30
./configure --prefix=/usr/local/pcre
make && make install
一、编译安装APACHE
1.rpm -qa | grep httpd \\检查系统已安装的HTTPD软件
2.rpm -e --nodepshttpd \\卸载系统默认安装的HTTPD软件包
3.mkdir /usr/local/apache \\创建HTTPD目录作为HTTPD的存储位置
4.下载HTTPD的原码包httpd-2.2.17.tar.bz2到本地目录
5.解压源码包
tar vxf httpd-2.2.17.tar.bz2
6.切换到/usr/local/httpd-2.2.17目录里
cd /usr/local/httpd-2.2.17
7.开始预编译
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=most
8.make
9.make install
10.cp /etc/init.d/httpd ./
vim httpd
修改
apachectl=/usr/local/apache/bin/apachectl
httpd=/usr/local/apache/bin/httpd
vim /etc/httpd/httpd.conf
添加
PidFile "/var/run/httpd.pid"
11.把HTTPD设置为开机自动启动
chkconfig --add httpd
chkconfig httpd on
chkconfig --list \\查看是否开机启动
12.
vim /etc/profile
添加一条
PATH=$PATH:/usr/local/apache/bin
. !$ \\重读一下文件
13.
vim /etc/man.conf
添加一条
MANPATH /usr/local/apache/man
14.将APACHE的头文件链接到/usr/include/apache下
ln -sv /usr/local/apache/include /usr/include/apache
15.APACHE的库文件
vim /etc/ld.so.conf.d/apache.conf
/usr/local/apache/lib
ldconfig -v \\重新导入库文件
二、解压缩安装MYsql并简单配置
1、下载压缩包mysql-5.5.15-linux2.6-i686.tar.gz
2、解压缩tar xf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local
3、cd /usr/local
ln -sv mysql-5.5.15-linux2.6-i686 mysql
4、创建组和用户
groupadd -r mysql \\系统组
useradd -g mysql -s /sbin/nologin -M mysql
5、cd /mysql
6、chown -R mysql:mysql .
7、创建逻辑卷
fdisk /dev/sda
n \\新建一个分区
e \\新建一个扩展分区
n \\新建一个逻辑分区
+10G \\逻辑分区大小10G
t \\转换分区类型
8e \\转换成lvm
partprobe /dev/sda 重读硬盘分区
pvcreat /dev/sda5 创建pv
vgcreat myvg /dev/sda5 创建vg并命名为myvg
lvcreate -L 3G -n mydata myvg 创建一个3G大小的lv并命名为mydata
mke2fs -j -L MYDATA -b 2048 /dev/sda5 格式化MYDATA 为ext3 块大小为2048
mkdir /mydata 在根目录下创建下个mydata目录
vim /etc/fstab
添加一条
LABEL=MYDATA /mydata ext3 defaults 0 0
mount -a 挂载
mkdir /mydata/data
chown -R mysql:mysql /mydata/data
8、开始初始化
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
9、chown -R root . \\把文件的属主改为root
10、cd support-files
11、 cp my-large.cnf /etc/my.cnf
vim /etc/my.cnf
在mysqld里编辑添加一条
datadir = /mydata/data
12、cp mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
13、vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
14、cd ..
ln -sv /usr/local/mysql/include /usr/include/mysql
15、vim /etc/ld.so.config.d/mysql.conf
/usr/local/mysql/lib
ldconfig -v重读库文件
16.vim /etc/man.config
MANPATH /usr/local/mysql/man
三、编译安装php
1、下载php-5.3.6.tar.bz2
2、解压 tar xf php-5.3.6.tar.bz2
3、cd php-5.2.3
4、./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-xml --with-png --with-jpeg --with-zlib --with-freetype --with-gd --enable-track-vars --enable-mbstring=all
5、make
6、make install
7、cp php.ini-production /usr/local/php5/lib/php.ini
8、vim /etc/httpd/httpd.conf
添加
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
9、setinforce 0 \\关闭SElinux
10.cd /usr/local/apache/htdocs/
rm index.html
vim index.php
测试是否能连上数据库
<?php
$link=mysql_connect(localhost,'root','')
if($link)
echo "success"
else
echo "failure";
?>
11、测试与数据库连接是否正常