lamp 源码安装过程

首先在网上下载源代码包

mysql-5.5.15-linux2.6-i686.tar.gz

httpd-2.2.19.tar.bz2

php-5.3.7.tar.bz2

mysql源码安装过程--------------------------

 [root@localhost Server]# yum clean all

[root@localhost Server]# yum groupinstall "Development Tools"
[root@localhost Server]# rpm -qa |grep -E "http|php|mysql"////查询是否安装
[root@localhost Server]# yum remove httpd//////卸载软件
[root@localhost ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686 mysql ///做链接同样可以访问到
[root@localhost local]# cd mysql
-rw-r--r--  1 7161 wheel  7604 Jul 14 03:09 INSTALL-BINARY
[root@localhost mysql]# less INSTALL-BINARY /////查看内容
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server//////以上为安装步骤
[root@localhost mysql]# groupadd -r mysql /////创建系统组
[root@localhost mysql]# useradd -r -g mysql -s /sbin/nologin  -M mysql
[root@localhost mysql]# chown -R mysql:mysql . //////修改所有者和所属组
[root@localhost mysql]# scripts/mysql_install_db --user=mysql------"1980s:lamp-1"-----
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# ll /etc/init.d/   ///////存放的全都是各种启动脚本
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf//////mysql的配置脚本
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld //////mysql的启动脚本
[root@localhost mysql]# service mysqld start//////可以对mysql进行启动、关闭、
[root@localhost mysql]# netstat -tupln |grep mysql/////启动后可以查看mysql的端口号
[root@localhost mysql]# cd  /etc/ld.so.conf.d/   /////配置非标准的库文件
[root@localhost ld.so.conf.d]# vi mysql.conf//////编辑链接库文件内容如下
/usr/local/mysql/lib
[root@localhost ld.so.conf.d]# ldconfig -v |grep mysql///////重新加载库文件--查看能否加载上
/usr/local/mysql/lib:
        libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0//////说明已经加载上
[root@localhost ld.so.conf.d]# cd /usr/include/    /////头文件存放目录
[root@localhost include]# ln -s /usr/local/mysql/include mysql///////连接到mysql的头文件命名为mysql
[root@localhost include]# cd mysql //////就可进入到mysql的头文件里
[root@localhost mysql]# chkconfig --add mysql    //////添加到开机自启动里
[root@localhost mysql]# chkconfig --list |grep mysql
[root@localhost mysql]# cd /etc/rc3.d/   ////可以进入到3级别查看在3级别里的内容
 
apache源码安装过程------------------------------
额外被安装的软件一般都安装到/usr/local目录下
额外被安装的源代码一般都安装在/usr/local/src and /usr/src
[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C  /usr/src/   ////拆解安装源代码包到/usr/src/
[root@localhost ~]# cd /usr/src/    ////在这个目录下会有这个目录
drwxr-xr-x 11 yl   yl   4096 May 21 01:01 httpd-2.2.19
[root@localhost src]# cd httpd-2.2.19/     /////继续切换到这个目录下
[root@localhost httpd-2.2.19]# ls      //////查看文件
[root@localhost httpd-2.2.19]# less INSTALL /////查看配置文件说明
 $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start     /////配置步骤
[root@localhost httpd-2.2.19]# ./configure --help   //////查看帮助文档
Installation directories:
  --prefix=PREFIX //安装成功后的路径        install architecture-independent files in PREFIX
                          [/usr/local/apache2]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]
--sysconfdir=DIR ///配置脚本存放位置       read-only single-machine data [PREFIX/etc]
  --enable-so             DSO capability  ///开启DSO (动态共享对象)
--with-z=DIR  ///使用zlib库需要安装zlib          use a specific zlib library
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --with-z  --enable-ssl
[root@localhost httpd-2.2.19]# make/////编译
[root@localhost httpd-2.2.19]# make install//////安装
[root@localhost httpd-2.2.19]# cd /etc/httpd/
-rw-r--r-- 1 root root 13422 Sep  7 08:04 httpd.conf
[root@localhost httpd]# vi httpd.conf 
[root@localhost httpd]# cd extra/
-rw-r--r-- 1 root root  1491 Sep  7 08:04 httpd-vhosts.conf
[root@localhost extra]# vi httpd-vhosts.conf///////在这里可以编写虚拟主机目录
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
[root@localhost extra]# cd /usr/local/apache/  /////产生的apache目录
[root@localhost apache]# ./bin/apachectl start   ////启动apache
[root@localhost apache]# vi /etc/rc.d/rc.local /////编写开机脚本
/usr/local/apache/bin/apachectl start
[root@localhost ~]# vi /etc/profile//////为了启动方便修改环境变量
////////HOSTNAME=`/bin/hostname`
HISTSIZE=1000
 
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi
PATH=$PATH:/usr/local/apache/bin//////添加的环境变量
 
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC///////////在这里边添加环境变量
//////要想使生效注销一次在登录就生效了     不用注销的就可以生效的方法是执行下命令
[root@localhost ~]# . /etc/profile
[root@localhost ~]# echo $PATH   //////查看添加的结果
/usr/local/apache/bin
[root@localhost ~]# apachectl stop/////这是在任何位置都可以启动和停止
[root@localhost apache]# cd /usr/include/   /////进到标准头文件
[root@localhost include]# ln -s /usr/local/apache/include  apache  ////做一个链接到apache得头文件
[root@localhost include]# cd /etc/ld.so.conf.d/   ////链接库文件
[root@localhost ld.so.conf.d]# vi mysql.conf   
/usr/local/apache/lib
[root@localhost ld.so.conf.d]# ldconfig -v |grep apache  /////重新加载
/usr/local/apache/lib:
 
php源码安装过程--------------------------------
同样是源代码需要解压到/usr/src
[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/src/
[root@localhost ~]# cd /usr/src/
drwxr-xr-x 13 1000 1000 4096 Aug 17 21:32 php-5.3.7
[root@localhost src]# cd php-5.3.7/
[root@localhost php-5.3.7]# ls
INSTALL      //////同样有一个INSTALL文件有配置--安装---注意的选项
[root@localhost php-5.3.7]# vi INSTALL
1.  gunzip apache_xxx.tar.gz
2.  tar -xvf apache_xxx.tar
3.  gunzip php-xxx.tar.gz
4.  tar -xvf php-xxx.tar
5.  cd apache_xxx
6.  ./configure --prefix=/www --enable-module=so
7.  make
8.  make install
9.  cd ../php-xxx
[root@localhost php-5.3.7]# ./configure --help
 --prefix=PREFIX /////安装路径
--with-apxs2[=FILE]=指明apache调用php模块的工具的路径和名称 
 --enable-mbstring   ///////字符串支持
--with-mysql  指明mysql路径
--with-mysqli 指明mysql_confi 的路径名称
1.[root@localhost php-5.3.7]# ./configure  --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config 
2.[root@localhost php-5.3.7]# make
3.[root@localhost php-5.3.7]# make install
[root@localhost php-5.3.7]# vi /etc/httpd/httpd.conf
105 DocumentRoot "/usr/local/apache/htdocs"   /////网页主页位置
[root@localhost php-5.3.7]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ll
total 4
-rw-r--r-- 1 root root 44 Nov 21  2004 index.html
[root@localhost htdocs]# vi index.html 
<?php
phpinfo();
?>
[root@localhost htdocs]# mv index.html index.php 
[root@localhost htdocs]# vi /etc/httpd/httpd.conf  /////配置
 
 
    167     DirectoryIndex index.php index.html  //////添加index.php
 
    310     AddType application/x-httpd-php .php   /////添加
[root@localhost htdocs]# apachectl stop   
[root@localhost htdocs]# apachectl start
 [root@localhost htdocs]# vi index.php /////测试mysql能否链接
<?php
$link=mysql_connect('127.0.0.1','root','');
if($link)
echo "ok";
else 
echo "failer"
?>
测试在网页上做测试如http://192.168.101.27  ok说明可以连接上
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章