天天看点

Linux下lamp源码搭建+论坛

LAMP 指的Linux(操作系统)、 Apache(HTTP 服务器), MySQL(数据库软件) 和PHP (有时也是指Perl或 Python) 的第一个字母,一般用来建立的web 服务器。Linux 是免费开源软件,这意味着源代码可用的操作系统。Apache 是使用中最受欢迎的一个开放源码的WEB服务器软件。MySQL 是多线程、多用户的SQL数据库管理系统。PHP 是一种编程语言最初设计生产动态网站。PHP 是主要用于服务器端的应用程序软件。Perl 和 Python 类似。

源码lamp搭建过程:

1:[root@lyt ~]# mkdir /mnt/cdrom

[root@lyt ~]# mount /dev/cdrom /mnt/cdrom/

[root@lyt ~]# cd /mnt/cdrom/Server/

[root@lyt Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm         #安装ftp服务器,将源代码导入虚拟机

[root@lyt Server]# cd /var/ftp/

[root@lyt ftp]# chmod o+w pub/            #ftp匿名登录时需要将pub目录权限改为可读

[root@lyt ftp]# vim /etc/vsftpd/vsftpd.conf            #修改此配置文件,如图:

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230562k8sU.png"></a>

[root@lyt ftp]# service vsftpd start

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230570pT4h.png"></a>

2:[root@lyt pub]# vim /etc/yum.repos.d/rhel-debuginfo.repo

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_134623058722jF.png"></a>

[root@lyt pub]# yum grouplist |less            #查看源码安装时的开发库和开发工具,在编译或安装过程中都需要如下这些东西。

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230593ZjuG.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462306053uFw.png"></a>

安装mysql绿色软件

3:[root@lyt pub]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/        #mysql-5.5.15-linux2.6-i686.tar.gz 是绿色软件,拆解

到/usr/local中

[root@lyt pub]# cd /usr/local/

[root@lyt local]# cd mysql-5.5.15-linux2.6-i686/

[root@lyt mysql-5.5.15-linux2.6-i686]# cat INSTALL-BINARY  | less       #利用管道分页查看INSTALL-BINARY文件

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230626TXIp.png"></a>

[root@lyt local]# groupadd mysql           #创建一个mysql组

[root@lyt local]# useradd -r -g mysql mysql           #创建一个mysql用户,并将其加入到mysql组中

[root@lyt local]# cd /usr/local/

第四部拆包文件已经执行过,这里不再执行

[root@lyt local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql         #创建一个符号连接mysql,指向mysql-5.5.15-linux2.6-i686

[root@lyt local]# cd mysql

[root@lyt mysql]# chown -R mysql .        #将mysql下所有的文件的所属用户全都改为mysql。

[root@lyt mysql]# chgrp -R mysql .         #将mysql下所有的文件的所属组全都改为mysql。

[root@lyt mysql]# scripts/mysql_install_db --user=mysql           #使用scrpts初始化脚本,用刚才创建的mysql用户运行

[root@lyt mysql]# chown -R root  .           #将所属用户改为root用户

[root@lyt mysql]# chown -R mysql data         #将data目录的所属用户改为mysql

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

[root@lyt mysql]# bin/mysqld_safe --user=mysql &amp;         #启动mysql

[root@lyt mysql]# netstat -tupln |less       #查看端口号

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230635O3iv.png"></a>

[root@lyt mysql]# cp   support-files/mysql.server    /etc/init.d/mysqld          #将mysql.server 拷贝到/etc/init.d/下,改名为mysqld,此命令拷贝成

功后可以使用service  mysqld restart指令。

[root@lyt mysql]# chkconfig --add mysqld      #将mysql服务加入到chkconfig中,可以使用chkconfig来管理

[root@lyt ~]# vim /etc/ld.so.conf        #查看该文件

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346232886I9yS.png"></a>

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

由于mysql的库文件存在于/usr/local/mysql/lib文件中,而系统的库文件存放于/usr/lib或者/lib中,所以需要创建/etc/ld.so.conf.d/mysql.conf文件,当系统启动时调用/usr/local/mysql/lib中的库文件。

[root@lyt ld.so.conf.d]# vim mysql.conf           #创建mysql.conf文件,系统启动时可以调用/usr/local/mysql/lib下的库文件

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230641Jo0F.png"></a>

[root@lyt ld.so.conf.d]# ldconfig -v |grep mysql           #查看mysql的系统调用

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230691wvvF.png"></a>

由于mysql的头文件存在于/usr/local/mysql/include文件中,而系统的头文件存放于/usr/include中,所以需要在/usr/include中创建连接,当系统启动时调用/usr/local/mysql/include中的头文件:

[root@lyt ld.so.conf.d]# cd /usr/include/

[root@lyt include]# ln -s /usr/local/mysql/include/  mysql         #创建一个字符连接mysql,连接到/usr/local/mysql/include

安装httpd:

1:[root@lyt ~]# cd /var/ftp/pub/            #切换到http源码的存放位置

[root@lyt pub]# tar -jxvf httpd-2.2.19.tar.bz2  -C  /usr/local/src/     #拆解软件包到目录/usr/local/src/

[root@lyt pub]# cd /usr/local/src/

[root@lyt src]# cd httpd-2.2.19/

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230707Ukoy.png"></a>

[root@lyt httpd-2.2.19]# ./configure --prefix=/usr/local/apache  --sysconfdir=/etc/httpd  --enable-so --enable-ssl  --with-z        #--prefix表示安

装路径,--sysconfdir表示配置文件的路径,--enable-so表示动态连接库,--enable-ssl表示安全套接层,--with-z网页压缩

[root@lyt httpd-2.2.19]# make      #编译

[root@lyt httpd-2.2.19]# make   install

[root@lyt httpd-2.2.19]# cd /usr/local/apache/

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230725piPQ.png"></a>

[root@lyt bin]# pwd 

/usr/local/apache/bin

[root@lyt bin]# ./apachectl start         #在/usr/local/apache/bin目录中执行./apachect1  start ,启动apache

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230737ul9j.png"></a>

[root@lyt bin]# vim /etc/rc.local        #编辑开机脚本,实现apache开机自动启动,如图:

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230741WKbw.png"></a>

[root@lyt bin]# cd /etc/ld.so.conf.d/

由于apache的库文件存在于/usr/local/apache/lib文件中,而系统的库文件存放/usr/lib或者/lib中,所以需要创建/etc/ld.so.conf.d/httpd.conf文件,当系统启动时调用/usr/local/apache/lib中的库文件。

[root@lyt ld.so.conf.d]# vim httpd.conf      #创建该文件并编辑

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462307445lUG.png"></a>

[root@lyt ld.so.conf.d]# cd /usr/local/apache/lib/

[root@lyt lib]# ldconfig -pv |grep apr         #搜索和apache相关的系统调用

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_134623075064SW.png"></a>

由于apache的头文件存在于/usr/local/apache/include文件中,而系统的头文件存放于/usr/include中,所以需要在/usr/include中创建连接,当系统启动时调用/usr/local/apache/include中的头文件:

[root@lyt lib]# cd /usr/include/

[root@lyt include]# ln -s /usr/local/apache/include/ apache           #在/usr/include中创建连接文件,连接名是apache

安装php:

[root@lyt include]# cd /var/ftp/pub/        #切换到php源码的存放位置

[root@lyt pub]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src/        #拆包

[root@lyt src]# cd php-5.3.7/

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462307733TjO.png"></a>

查看INSTALL说明文件:

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230806H2ct.png"></a>

[root@lyt php-5.3.7]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs  --with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config  --enable-mbstring=all            #--prefix表示安装路径,--with-apxs2将php编译成apache的模

块,允许apache的apxx调用该模块,--with-mysql指明mysql的安装位置 ,--with-mysqli调用myql接口

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462308276qyJ.png"></a>

[root@lyt php-5.3.7]# make            #编译

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230848Pl7p.png"></a>

[root@lyt php-5.3.7]# make install

[root@lyt htdocs]# /usr/local/apache/bin/apachectl start        #启动apache

[root@lyt php-5.3.7]# cd /usr/local/apache/htdocs/          #进入apache的站点主目录

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462308594wxA.png"></a>

测试apache能否调用php:

[root@lyt htdocs]# vim index.html

[root@lyt htdocs]# mv index.html index.php       #将index.html改名为index.php

[root@lyt htdocs]# vim /etc/httpd/httpd.conf          #编辑apache的配置文件脚本,此处是源码安装,配置脚本与rpm包安装的有所区别

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230877zG2T.png"></a>

[root@lyt htdocs]# /usr/local/apache/bin/apachectl stop           #重启apache

[root@lyt htdocs]# /usr/local/apache/bin/apachectl start

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230881YiUa.png"></a>

测试php能否调用mysql:

[root@lyt htdocs]# vim index.php

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230889wuEP.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230900wZhm.png"></a>

[root@lyt htdocs]# /usr/local/mysql/bin/mysql          #登陆mysql

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230903zBYC.png"></a>

[root@lyt htdocs]# /usr/local/mysql/bin/mysqladmin -u root -p password       #创建mysql密码

[root@lyt htdocs]# /usr/local/mysql/bin/mysql -u root –p         #登陆mysql数据库

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346230909y0a4.png"></a>

创建论坛:

[root@lyt bin]# service vsftpd restart 

[root@lyt pub]# ll  /var/ftp/pub/  

[root@lyt pub]# unzip phpwind_GBK_8.3.zip      #解压文件

[root@lyt pub]# cd phpwind_GBK_8.3

[root@lyt phpwind_GBK_8.3]# cp -R upload/  /usr/local/apache/htdocs/phpwind            #将upload/目录拷贝到/usr/local/apache/htdocs

中,并重命名为phpwind

[root@lyt phpwind_GBK_8.3]# cd /usr/local/apache/htdocs/

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243459hQ0e.png"></a>

[root@lyt htdocs]# cd phpwind/

[root@lyt phpwind]# chmod -R  777  attachment/         #更改attachment极其所含文件的属性为777,-R表示递归

[root@lyt phpwind]# chmod -R  777  data/            #更改data极其所含文件的属性为777,-R表示递归

[root@lyt phpwind]# chmod -R  777  html/           #更改html极其所含文件的属性为777,-R表示递归

[root@lyt phpwind]# /usr/local/apache/bin/apachectl restart          #重启apache服务

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243463tcEG.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243467cCae.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462434716xMz.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243473wxIz.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243476buxp.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243481HcyO.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243485RjZ8.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_134624348844wf.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243494gZFj.png"></a>

[root@lyt phpwind]# rm install.php          #按照上面提示,将isntall.php删除

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462434985Dcm.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243502AFiM.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_13462435037sWx.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243505rimQ.png"></a>

<a href="http://5493845.blog.51cto.com/attachment/201208/29/5493845_1346243509JuiC.png"></a>

至此,论坛已创建成功!!!

本文转自 liuyatao666 51CTO博客,原文链接:http://blog.51cto.com/5503845/976556,如需转载请自行联系原作者