分类: LINUX
2012-07-05 17:28:37
Linux下Web服务器应用之
源码构建LAMP环境
1.构建的linux环境:
Linux www 2.6.18-128.el5 #1 SMP Wed Dec 17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux
2.准备工作:
准备一:关闭firewall和SELinux(略)
准备二:构建本地yum服务器(略)
准备三:下载以下软件(我存放在linux的/root/lamp下)
ü Apache
ü Mysql
ü Php
准备四:构建编译组环境
使用# yum grouplist all |less查看已安装的组环境(红色必选)
Legacy Software Development
Development Libraries
Development Tools
发现这里没有安装Development Tools,使用下面命令安装
[root@www ~]# yum groupinstall "Development Tools"
源码构建LAMP环境过程
1.源码安装mysql:
(说明:一般一些额外的软件安装时经常将其放到/usr/local目录下)
[root@www lamp]# tar -zxvf mysql-5.5.19-linux2.6-i686.tar.gz -C /usr/local/
[root@www local]# ln -s mysql-5.5.19-linux2.6-i686/ mysql
[root@www mysql]# useradd -r -g mysql -s /sbin/nologin -M mysql
[root@www mysql]# scripts/mysql_install_db --user=mysql
[root@www mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[root@www mysql]# cp support-files/mysql.server /etc/init.d/mysqld
Starting MySQL... [ OK ]
[root@www ld.so.conf.d]# ldconfig -v |grep mysql
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
[root@www ld.so.conf.d]# cd /usr/include/
[root@www include]# ln -s /usr/local/mysql/include/ mysql
[root@www ~]# chkconfig --list |grep mysqld
2.源码安装apache:
[root@www lamp]# tar -zxvf httpd-2.2.21.tar.gz -C /usr/local/src/
[root@www httpd-2.2.21]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --with-z --enable-ssl
[root@www httpd-2.2.21]# cd /usr/local/apache/
[root@www apache]# netstat -tupln |grep http
[root@www include]# ln -s /usr/local/apache/include/ apache
[root@www include]# cd /etc/ld.so.conf.d/
[root@www ld.so.conf.d]# vim apache.conf
[root@www ld.so.conf.d]# ldconfig -v |grep apache
[root@www ld.so.conf.d]# netstat -tupln |grep httpd
tcp 0 0 :::80 :::* LISTEN 21263/httpd
[root@www ld.so.conf.d]# netstat -tupln |grep mysqld
tcp 0 0 :::3306 :::* LISTEN 2937/mysqld
3.源码安装php:
[root@www lamp]# tar -jxvf php-5.3.8.tar.bz2 -C /usr/local/src/
[root@www php-5.3.8]# ./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
4.测试LAMP环境:
增加网页测试文件:
[root@www htdocs]# vim /etc/httpd/httpd.conf
167 DirectoryIndex index.php index.html
310 AddType application/x-httpd-php .php
#测试apache与PHP的连接:
[root@www php-5.3.8]# cd /usr/local/apache/htdocs/
[root@www htdocs]# mv index.html index.php
It works!--xjzhujunjie--2012/03/18
#测试apache与mysql的连接:
[root@www htdocs]# vim /usr/local/apache/htdocs/index.php