安装前的准备,配置yum查看开发工具:
GNOME DesktopEnvironment
GNOME SoftwareDevelopment
X SoftwareDevelopment
Legacy SoftwareDevelopment
必须具备以上的开发工具
[root@localhost ~]# mkdir -pv lamp //创建目录把需要的软件放到这个目录,便于管理
上传需要的软件:如下图
由于httpd-2.4.4 需要apr的支持所以需要安装apr
[root@localhost lamp]# tar -zxvfapr-1.4.6.tar.gz -C /usr/local/src/ //解压apr到/usr/local/src
[root@localhost lamp]# tar -zxvfapr-util-1.5.1.tar.gz -C /usr/local/src/ //解压apr工具
[root@localhost lamp]# cd/usr/local/src/apr-1.4.6 //进入apr-1.4.6目录
[root@localhost apr-1.4.6]#./configure --prefix=/usr/local/apr //配置apr
make && make install //编译安装apr
[root@localhost apr-util-1.5.1]#./configure --with-apr=/usr/local/apr/bin/apr-1-config //配置apr-util
[root@localhost apr-util-1.5.1]# make&& make install //编译安装apr-util
[root@localhost lamp]# tar -jxvfhttpd-2.4.4.tar.bz2 -C /usr/local/src/ //解压安装包
[root@localhost httpd-2.4.4]# cd/usr/local/src/httpd-2.4.4/ //进入源码目录
yum install -y pcre-devel //安装pcre的devel包 --httpd的增强工具
[root@localhost httpd-2.4.4]# ./configure --prefix=/usr/local/appche\
> --enable-so \
> --sysconfdir=/etc/httpd
[root@localhost httpd-2.4.4]#./configure --prefix=/usr/local/appche--enable-so \
[root@localhost httpd-2.4.4]#./configure \ //配置httpd
> --prefix=/usr/local/apache \
> --sysconfdir=/etc/httpd \
> --enable-so \
> --enable-ssl \
> --enable-rewrite \
>--with-apr=/usr/local/apr/bin/apr-1-config \
>--with-apr-util=/usr/local/apr/bin/apu-1-config \
> --with-pcre \
> --with-z \
> --enable-mpms-shared=all
[root@localhost httpd-2.4.4]# make&& make install //编译安装
[root@localhost apache]# vim/etc/man.config //修改man的配置文件
48 MANPATH /usr/local/apache/man //在47行下面添加这一行
[root@localhost apache]# ln -s/usr/local/apache/include/ /usr/include/apache //处理头文件,放到系统目录
[root@localhost ~]# cd /root/lamp/ //进入上传文件的目录处理脚本
[root@localhost lamp]# vim httpd //编辑脚本
如下图:
[root@localhost lamp]# cp httpd/etc/init.d/ //拷贝到启动目录
[root@localhost lamp]# chmod a+x/etc/init.d/httpd //添加执行权限
[root@localhost lamp]# chkconfig httpd on //设置开机启动
*[root@localhost lamp]# chkconfig --addhttpd //功能如上
Mysql
[root@localhost lamp]# tar -zxvfmysql-5.6.10.tar.gz -C /usr/local/src/ //拆包mysql
安装前的准备:
Mysql的预安装
# Preconfiguration setup
504shell> groupadd mysql
505shell> useradd -r -g mysql mysql
506# Beginning of source-build specific instructions
507shell> tar zxvf mysql-VERSION.tar.gz
508shell> cd mysql-VERSION
509shell> cmake .
510shell> make
511shell> make install
512# End of source-build specific instructions
513# Postinstallation setup
514shell> cd /usr/local/mysql
515shell> chown -R mysql .
516shell> chgrp -R mysql .
517shell> scripts/mysql_install_db --user=mysql
518shell> chown -R root .
519shell> chown -R mysql data
520# Next command is optional
521shell> cp support-files/my-medium.cnf /etc/my.cnf
522shell> bin/mysqld_safe --user=mysql &
523# Next command is optional
524shell> cp support-files/mysql.server /etc/init.d/mysql.server
525
526 Amore detailed version of the source-build specific instructions
527 is shown following.需要cmake的支持
工具 cmake
[root@localhost lamp]# tar -zxvfcmake-2.8.10.2.tar.gz -C /usr/local/src/ //解压cmake
用法:shell>cmake . -L # overview
540shell> cmake . -LH # overview withhelp text
541shell> cmake . -LAH # all params with help text
542shell> ccmake . # interactivedisplay
[root@localhost cmake-2.8.10.2]#cd/usr/local/src/ cmake-2.8.10.2 //进入cmake的源码目录
[root@localhost cmake-2.8.10.2]# make&& make install //编译安装cmake
[root@localhost cmake]# vim /etc/profile //编辑profile文件把cmake的bin加入环境变量
45 PATH=$PATH:/usr/local/cmake/bin //在44行后面添加这行
退出;重新登录使环境变量生效
[root@localhost ~]# cd/usr/local/src/mysql-5.6.10/ //进入mysql源码目录
[root@localhost mysql-5.6.10]# cmake . //执行cmake.
[root@localhost mysql-5.6.10]# make&& make install //编译安装
[root@localhost mysql]# groupadd mysql //添加组
[root@localhost mysql]# useradd -r -g mysqlmysql //添加帐号
[root@localhost mysql]# chown -Rmysql:mysql . //改变所属组,所属帐号
[root@localhost mysql]# scripts/mysql_install_db --user=mysql //以mysql身份对数据库初始化
[root@localhost mysql]# chown -R root . //改变所有者为root
[root@localhost mysql]# chown -R mysql data //但是 data要为mysql
[root@localhost support-files]# cpmy-default.cnf /etc/my.cnf //处理mysql的配置文件
[root@localhost support-files]# cpmysql.server /etc/init.d/mysqld //处理mysql的启动文件
[root@localhost support-files]# chmod a+x/etc/init.d/mysqld //给启动文件可执行权限
[root@localhost cmake]# vim /etc/profile //编辑profile文件把cmake的bin加入环境变量
45PATH=$PATH:/usr/local/cmake/bin:/usr/local/mysql/bin //添加 /usr/local/mysql/bin
[root@localhost ~]# mysqladmin -u root -ppassword "123" //给mysql设置密码
Enter password: //上次密码为空
[root@localhost ~]# mysql -u root �Cp //登录mysql
[root@localhost mysql]# vim/etc/ld.so.conf.d/mysql.conf //新建文件,处理mysql的库文件
1 /usr/local/mysql/lib //编辑内容
[root@localhost mysql]# ldconfig //刷新缓存
[root@localhost mysql]# ldconfig -pv | grepmysql //查看库文件
[root@localhost mysql]# ln -s/usr/local/mysql/include/ /usr/include/mysql //处理头文件
Php
[root@localhost lamp]# tar -jxvfphp-5.4.13.tar.bz2 -C /usr/local/src/ //拆解php
[root@localhost php-5.4.13]# cd/usr/local/src/php-5.4.13/ //进入到php源码目录
[root@localhost php-5.4.13]# ./configure--prefix=/usr/local/php \ //php的配置
> --sysconfdir=/etc/ \
> --with-apxs2=/usr/local/apache/bin/apxs\
> --with-zlib \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --enable-mbstring \
> --with-mysql=/usr/local/mysql/ \
>--with-mysqli=/usr/local/mysql/bin/mysql_config \
> --enable-xml \
> --with-freetype-dir
[root@localhost php-5.4.13]# make&& make install //编译安装
[root@localhost php]# vim /etc/profile //处理php的bin文件
45PATH=$PATH:/usr/local/cmake/bin:/usr/local/mysql/bin:/usr/local/php/bin //45行修改如下
退出;重新登录使环境变量生效
[root@localhost ~]# vim/etc/ld.so.conf.d/php.conf //新建文件,处理phl的库文件
/usr/local/php/lib //编辑文件
[root@localhost ~]# ldconfig //刷新缓存
[root@localhost php]# ln -s/usr/local/php/include/ /usr/include/php ////处理头文件
[root@localhost ~]# php �Cm //查看php的模块
[root@localhost php]# vim/etc/httpd/httpd.conf //编辑apache 的配置文件
149 AddType application/x-httpd-php .php.phtml //在147行下添加这一行
248 DirectoryIndex index.htmlindex.php //在248行追加 index.php
[root@localhost php]# service httpd restart //重启apache 服务
[root@localhost php]# service httpd restart/htdocs //进入站点主目录
编辑测试页:
<html>
<body><h1>It works!
<?php
$link=mysql_connect("127.0.0.1","root","123");
if ($link) echo"ok"; else echo"not";
?>
</h1>
<?php
phpinfo();
?>
</body>
</html>