目录
安装httpd 1
安装mysql 4
安装php服务 6
源码包安装lamp架构
在安装之前首先查看你的httpd和mysql服务有没有装,如果装了要把服务关闭.
mysql要卸载yum remove mysql-server mysql mysql-devel -y
安装httpd
1、 首先将lamp包复制到/usr/local/src/lamp/目录下
2、 接着配置yum源环境,然后安装gcc
yum install gcc* -y
3、tar fvxj apr-1.4.6.tar.bz2 解压缩包
cd apr-1.4.6 进入目录
./configure –prefix=/usr/local/apr 执行编译
编译结果为
接着执行make,结果为
make install
cd .. 然后 解压tar fvxj apr-util-1.5.1.tar.bz2
cd apr-util-1.5.1 进入apr-util-1.5.1目录
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr 编译结果
接着执行make && make install 执行结果为
cd .. 返回上一级目录
tar zxvf httpd-2.4.3.tar.gz 解压缩httpd包
cd httpd-2.4.3 进入httpd-2.4.3
yum install zlib-devel openssl-devel pcre-devel -y安装httpd的相关依赖包
接着
./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –enable-module=so–enable-deflate=shared –enable-expires=shared –enable-rewrite=shared –enable-cache –enable-file-cache –enable-mem-cache –enable-disk-cache –enable-static-support –enable-static-ab –disable-userdir –with-mpm=prefork –enable-nonportablmae-atomics –disable-ipv6 –with-sendfile 编译httpd相关的依赖关系.然后编译的结果为
接着编译make && make install 结果为
接着开启httpd服务
/usr/local/apache2/bin/apachectl -k start
浏览器中输入ip地址
显示你的httpd安装成功
安装mysql
创建groupadd mysql 创建mysql组
useradd -g mysql mysql 创建mysql用户
rpm -ivh cmake-2.6.4-7.el5.i386.rpm 安装依赖包
yum install ncurses-devel libtool –y 安装libtool工具包
mysql不会创建目录,需要手工创建mysql数据库目录
mkdir -pv /usr/local/mysql/data
tar -zxvf mysql-5.5.29.tar.gz 解压缩mysql数据库
cd mysql-5.5.29 进入mysql数据库
编译mysql
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DWITH_INNODBBASE_STORAGE_ENGINE=1 \
-DENABLE_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_EMBEDED_SERVER=0
接着编译make && make install完成后的截图
cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf 复制mysql文件到etc下
修改vim /etc/my.cnf 在其中添加
[mysqld]
port = 3306
socket = /usr/local/mysql/mysql.sock
添加skip-name-resolve = 1
cp support-files/mysql.server /etc/init.d/mysqlsource 将mysql.server文件拷贝到/etc/init.d/下修改文件名为mysqlsource
chmod 755 /etc/init.d/mysqlsource 修改权限
chown -R mysql.mysql /usr/local/mysql/ 并且修改/usr/local/mysql的所属组和所属者为mysql
sh scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/
执行结果为
ln -s /usr/local/mysql/bin/* /usr/bin/
ln -s /usr/local/mysql/lib/* /usr/lib/
ln -s /usr/local/mysql/libexec/* /usr/local/libexec
ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1
ln -s /usr/local/mysql/share/man/man8/* /usr/share/man/man8
创建mysql数据库的软链
service mysqlsource start 将mysql服务启动
安装php服务
tar fvxz libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/usr/local/ –with-apr=/usr/local/apr && make && make install
编译并安装 执行结果为
tar fvxz libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install 编译
执行ldconfig 重新加载链接库模块
[root@localhost libmcrypt-2.5.8]# cd ..
[root@localhost lamp]# cd libmcrypt-2.5.8/libltdl
./configure –enable-ltdl-install && make && make install 编译安装,结果为
cd ../../
tar fxz mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure && make && make install 编译结果为
ln -s /usr/local/lib/* /usr/lib/
ln -s /usr/local/bin/libmcrypt-config /usr/bin
创建两个软连接分别指向/usr/lib和/usr/bin
tar fvxz mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure && make && make install 编译结果为
tar fvxj php-5.4.11.tar.bzL 2
yum install libxml2-devel libpng-devel bzip2-devel curl-devel libjpeg-devel freetype-devel net-snmp-devel –y 安装相关的依赖包
cd php-5.4.11
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql/ –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql –with-iconv-dir=/usr/local/ –enable-fpm –with-fpm-user=apache –with-fpm-group=apache –with-pcre-regex –with-zlib –with-bz2 –enable-calendar –disable-phar –with-curl –enable-dba –with-libxml-dir –enable-ftp –with-gd –with-jpeg-dir –with-png-dir –with-zlib-dir –with-freetype-dir –enable-gd-native-ttf –enable-gd-jis-conv –with-mhash –enable-mbstring –with-mcrypt –enable-pcntl –enable-xml –disable-rpath –enable-shmop –enable-sockets –enable-zip –enable-bcmath –with-snmp –disable-ipv6 –disable-rpath –disable-debug –with-apxs2=/usr/local/apache2/bin/apxs 编译结果为
make ZEND_EXTRA_LIBS=’-liconv’ 编译结果为
make install
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/apache2/conf/httpd.conf
添加:AddType application/x-httpd-php .php
搜索index
DirectoryIndex index.php
cd /usr/local/apache2/htdocs/
vim /usr/local/apache2/htdocs/index.php