您的位置:首页 > 博客中心 > 数据库 >

lamp环境搭建 centos5.5 +Apache2.2.9 +mysql5.1.18+php5.3.6 源码安装,【附配置环境】

时间:2022-03-14 13:45

资源包下载:https://github.com/penguinSeven/lamp/commit/8dbac0ec252a3587a387f6d386c330fba8987d9a

 

#安装zlib压缩库 压缩工具,实现软件压缩,安装过程中有性能优化的作用
#这个配置编译命令不要加目录参数
#安装zlib-1.2.5.tar.gz
cd /lamp
tar –zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure
make && make install


#安装apache
cd /lamp
tar -jxvf httpd-2.2.19.tar.bz2
cd httpd-2.2.19

./configure --prefix=/usr/local/apache2 \
--enable-modules=all \
--enable-rewrite \
--enable-mods-shared=all \
--enable-so

make && make install
#启动Apache
/usr/local/apache2/bin/apachectl start

 

#安装libxml2
cd /lamp
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2

./configure --prefix=/usr/local/libxml2
make && make install


#安装jpeg8
cd /lamp
tar -zxvf jpegsrc.v8b.tar.gz
cd jpeg-8b
./configure --prefix=/usr/local/jpeg \
--enable-shared --enable-static
make && make install


#安装libpng #和zlib一样不要带参数,让它默认安装到相应目录
#cd /lamp
tar zxvf libpng-1.4.3.tar.gz
cd libpng-1.4.3
./configure
make && make install


#安装freetype
cd /lamp
tar zxvf freetype-2.4.1.tar.gz
cd freetype-2.4.1
./configure --prefix=/usr/local/freetype
make && make install


#安装GD库
cd /lamp
tar -zvxf gd-2.0.35.tar.gz
mkdir -p /usr/local/gd
cd gd-2.0.35
./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg/ \
--with-png --with-zlib \
--with-freetype=/usr/local/freetype
make && make install


#安装 php5
cd /lamp
tar -jxvf php-5.3.6.tar.bz
cd php-5.3.6
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib --with-libxml-dir=/usr/local/libxml2 \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--enable-mbstring=all \
--enable-mbregex \
--enable-shared
make && make install
cp php.ini-development /usr/local/php/lib/php.ini


#配置Apache使其支持php
vi /usr/local/http2/conf/httpd.conf
#在httpd.conf(Apache主配置文件)中增加:
AddType application/x-httpd-php .php

#找到下面这段话:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
#在index.html 前面添加index.php

#重启Apache失败:
echo "/usr/local/lib/" >>/etc/ld.so.conf

ldconfig
#修改php.ini中timezone=PRC

 

#1)编译安装MySQL
cd /home/shuhua/tar
tar -xzvf mysql-5.1.58.tar.gz
cd mysql-5.1.58

./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=gbk,gb2312,binary

##mysql有软件依赖,从光盘中查找指定软件,重新安装
##.....挂载光盘(函数库)
mount
rpm -ivh libtermcap-devel-2.0.8-46....
make && make install

#2)配置并初始化MySQL
groupadd mysql
useradd -g mysql mysql
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
chown -R mysql.mysql .
bin/mysql_install_db --user=mysql \
--datadir=/usr/local/mysql/var
#创建mysql测试和系统的数据库
chown -R root .
#把当前目录文件的主人都改为root,避免数据库恢复为出厂设置。
chown -R mysql var
bin/mysqld_safe --user=mysql &
#启动mysql

#修改mysql密码(可不做此步,默认无密码)
UPDATE user SET password=PASSWORD(‘new_password‘) WHERE user=‘root‘;
update user set password=PASSWORD(‘root‘) where user=‘root‘;

#修改远程登录权限
update user set host=‘%‘ where user=‘root‘

#删除mysql 的无密码登陆账号
delete from user where user =‘‘;

flush privileges

#apache开机启动
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit

mysql开机启动
#赋值安装目录下的文件到init.d目录下
cp /lamp/mysql-5.1.58/support-files/mysql.server /etc/rc.d/init.d/mysqld
#修改权限
chown root.root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
#添加开机启动
chkconfig --add mysqld
#查看在那几种模式下启动
chkconfig --list mysqld
#关闭其他模式下的启动,仅在命令行的模式下启动
chkconfig --levels 245 mysqld off

 

本类排行

今日推荐

热门手游