linux-lamp源码安装-054

 

运用源码安装lamp

安装源码的步骤

1.       执行源码

./configure –prefix –指明安装路径

--sysconfdir  --存放配置文件的目录

(--help) –帮助文档

2.       编译Make

3.       安装Make install

 

安装所需软件

软件下载

http://www.mysql.com

mysql community server 5.5 –s社区版

linux-Generic 2.6(x86,32-bit),compressed TAR Archive

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

http://www.apache.org

apache http server

http//www.php.net

软件包:

httpd- 2.2.19 .tar.bz2

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

php- 5.3.7 .tar.bz2

[root@localhost ~]# vim /etc/sysconfig/network

HOSTNAME=server1.example.com                                         

[root@localhost ~]# service network restart

2.编译环境

安装gcc glib 包含着开发工具中

Development Tools --开发工具

Legacy Software Development  -- 传统软件开发工具

Development Libraries –开发工具库

Java development –源代码基于java

如果是图形的软件包

Kde环境需要安装:

Kde software development

 

Gnome环境需要安装:

Gnome software development

X software development

[root@lamp Server]# mount /dev/cdrom /mnt/cdrom 

[root@lamp Server]# cd /mnt/cdrom/Server

[root@lamp Server]# yum grouplist

[root@lamp Server]# yum groupinstall " Development Tools "

[root@server1 ~]# yum groupinstall "Java Development"

删除已经安装过的包及安装产生的文件

1扩展的查询

[root@lamp Server]# rpm -qa |grep -E "http|php|mysql"     查看包是否已经安装

--源码安装需要卸载,安装全新的

[root@lamp Server]# yum remove httpd

[root@lamp Server]# yum remove mysql

[root@lamp Server]# yum remove php-common- 5.1.6 -23.el5

2删除已安装产生的配置文件

[root@lamp Server]# cd /etc/httpd

[root@lamp httpd]# rm -fr *

安装mysql

导入httpd-2.2

Mysql- 5.5.15

Php- 5.3.7

Php要安装在最后。

安装绿色版mysql

[root@lamp ~]# cd /usr/local/       --存放额外的安装包的目录

[root@lamp software]# tar -zxvf mysql- 5.5.15 -linux2.6-i686.tar.gz -C /usr/local/

--做链接

[root@lamp local]# ln -s mysql- 5.5.15 -linux2.6-i686/ mysql

--安装步骤信息

[root@lamp local]# more mysql/INSTALL-BINARY   --查看帮助文档

  To install and use a MySQL binary distribution, the basic command

   sequence looks like this:

shell> groupadd mysql         --建立用户组

shell> useradd -r -g mysql mysql            --建立(-r)系统账户(-g)属于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 .  改变所有文件属组为mysql

shell> chgrp -R mysql . –改变所有组的属组为mysql

shell> scripts/mysql_install_db --user=mysql –生成初始库

shell> chown -R root . –改回来所有者所属组

 

shell> chown -R mysql data –改变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@lamp local]# groupadd mysql

groupadd: group mysql exists

[root@lamp local]# useradd -r -g mysql –s /sbin/nologin –M mysql 没有家目录不准登陆

useradd: user mysql exists

[root@lamp local]# cd mysql 

 

[root@lamp mysql]# chown -R mysql .

[root@lamp mysql]# chgrp -R mysql .

---# chown -R mysql:mysql .

 

[root@lamp mysql]# scripts/mysql_install_db --user=mysql –生成初始的库

Installing MySQL system tables...

OK

Filling help tables...

OK

[root@lamp mysql]# chown -R root .

[root@lamp mysql]# chown -R mysql data    

[root@lamp mysql]# cp support-files/my-medium.cnf  /etc/my.cnf

--生成服务的配置脚本

[root@lamp mysql]# bin/mysqld safe --user=mysql&

[root@lamp mysql]# cp support-files/mysql.server /etc/init.d/mysqld

--生成服务的启动脚本service mysqld start

[root@lamp mysql]#

 

更改库文件

标准库文件存放目录

/lib

/usr/lib

/usr/local/lib

库文件存放三个文件里系统会自动找到

#vim /etc/ld.so.conf

include ld.so.conf.d/*.conf

--定义不标准软件包安装的库文件存放位置

[root@server1 mysql]# cd /etc/ld.so.conf.d/

--创建新的库文件路径指向文件

[root@server1 ld.so.conf.d]# vim mysql.conf

/usr/local/mysql/lib

[root@server1 ld.so.conf.d]# ldconfig -v |grep mysql

/usr/local/mysql/lib:

        libmysqlclient.so.18 -> libmysqlclient_r.so. 18.0.0

[root@server1 ld.so.conf.d]# --从新加载库文件

 

更改头文件

-头文件存放位置

/usr/include

/usr/local/include

#cd /usr/include

#ln –s /usr/local/mysql/include mysql

--chkconfig管理mysqld服务

#chkconfig --add mysqld

#chkconfig --list |grep mysql

# vim /etc/init.d/mysqld

# chkconfig: 2345 64 36

--启动优先级序列号是 64 被杀死的号是36

#cd /etc/rc3.d

#ll |grep mysql

lrwxrwxrwx 1 root root 16 Oct 13 19:32 S64mysqld -> ../init.d/mysqld

[root@server1 rc6.d]# ll |grep mysql

lrwxrwxrwx 1 root root 16 Oct 13 19:32 K36mysqld -> ../init.d/mysqld

[root@server1 rc3.d]# service mysqld start

Starting MySQL.                                            [  OK  ]

[root@server1 rc3.d]#

 

安装Apache

源代码安装存放位置

/usr/src

/usr/local/src

#tar jxvf httpd- 2.2.19 .tar.bz2 –C /usr/src

#cd /usr/src/httpd- 2.2.19 /

--安装说明文档

#less INSTALL

     $ ./configure --prefix=PREFIX

     $ make

     $ make install

     $ PREFIX/bin/apachectl start

# ./configure --help

Configure  --prefix=安装的目录

                --sysconfigdir=配置脚本目录

                --enble-so 开启dso 动态共享对象

                --with-z 使用zlib

                --enable-ssl 启用加密

检测域编译环境

[root@server1 httpd- 2.2.19 ]# ./configure --prefix=/usr/local/apche --sysconfdir=/etc/httpd --enable-so --with-z --enable-ssl

编译

[root@server1 httpd- 2.2.19 ]# make

安装

[root@server1 httpd- 2.2.19 ]# make install

 

#cd /etc/httpd

#ll extra/

-rw-r--r-- 1 root root  1489 Oct 13 21:29 httpd-vhosts.conf

--虚拟主机配置文件

#vim extra/httpd-vhosts.conf

#cd /usr/local/apche

#./bin/apachectl start

 

开机自动启动

 #vim /etc/rc.d/rc.local

/usr/local/apche/bin/apachectl start

 

#vim /etc/profile

PATH=$PATH:/usr/local/apche/bin

修改环境变量,apache任意位置可以启动

#. /etc/profile 执行环境变量脚本

#echo $PATH

#apache stop

 

头文件

#cd /usr/include

#ln –s /usr/local/apche/include apache

#vim apache.conf

/usr/local/apche/lib

#ldconfig –v |grep apache 读取库文件显示出来

[root@server1 ld.so.conf.d]# links http://127.0.0.1

                                                              http://127.0.0.1/

                   It works!                                                   

 

Php的源码安装

php作为apache的模块被调用

# tar jxvf php- 5.3.7 .tar.bz2  -C /usr/src/

# cd /usr/src/php- 5.3.7 /

# less INSTALL

# ./configure –help

--prefix=安装路径

--with-apxs2=指明apache调用php模块的工具的路径和名称

 --enable-mbstring 字符串支持

--with-mysql=指明mysql的路径

--with-mysqli=指明mysql_config的路径名称

检测编译安装

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apche/bin/apxs --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config

# make

#make install

 

[root@server1 php- 5.3.7 ]# cd /usr/local/apche/htdocs/

[root@server1 htdocs]# vim index.html

<html><body><h1>It works!

<?php

phpinfo();

?>

 

</h1></body></html>                             

[root@server1 htdocs]# mv index.html index.php 

[root@server1 htdocs]# vim /etc/httpd/httpd.conf

166 <IfModule dir_module>

167     DirectoryIndex  index.html index.php

168 </IfModule>

169 AddType application/x-httpd-php .php

--为系统添加可以处理php脚本项

[root@server1 htdocs]# apachectl restart



54-1

[root@server1 htdocs]# vim index.php

<html><body><h1>It works!

<?php

$link=mysql_connect('127.0.0.1','root');

if($link)

echo "connect success!";

else

echo "failed!"

?>

</h1></body></html>

"index.php" 10L, 153C written                                

[root@server1 htdocs]# apachectl restart

[root@server1 htdocs]# links http://127.0.0.1

                                                              http://127.0.0.1/

                           It works! connect success!                          

                                                           

你可能感兴趣的:(linux,职场,lamp,休闲)