源码包httpd-2.2.19.tar.bz2
mysql-5.5.15-linux2.6-i686.tar.gz
php-5.3.7.tar.bz2
利用上述源码搭建lamp环境
详细步骤:
上传源码[root@localhost ~]# ll总计 174784-rw------- 1 root root 1200 2012-08-21 anaconda-ks.cfgdrwxr-xr-x 2 root root 4096 08-20 21:47 Desktop-rw-r--r-- 1 root root 5322082 08-20 22:03 httpd-2.2.19.tar.bz2-rw-r--r-- 1 root root 35768 2012-08-21 install.log-rw-r--r-- 1 root root 4713 2012-08-21 install.log.syslog-rw-r--r-- 1 root root 162247449 08-20 22:04 mysql-5.5.15-linux2.6-i686.tar.gz-rw-r--r-- 1 root root 11144328 08-20 22:03 php-5.3.7.tar.bz2首先安装mysql解压缩tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686 mysql[root@localhost local]# cd mysql[root@localhost mysql]# groupadd mysql[root@localhost mysql]# useradd -r -g mysql mysql[root@localhost mysql]# cd /usr/local/[root@localhost local]# cd mysql改变文件所有者和所有组[root@localhost mysql]# ll总计 76drwxr-xr-x 2 root root 4096 08-20 22:15 bin-rw-r--r-- 1 7161 wheel 17987 2011-07-14 COPYINGdrwxr-xr-x 4 root root 4096 08-20 22:15 datadrwxr-xr-x 2 root root 4096 08-20 22:16 docsdrwxr-xr-x 3 root root 4096 08-20 22:15 include-rw-r--r-- 1 7161 wheel 7604 2011-07-14 INSTALL-BINARYdrwxr-xr-x 3 root root 4096 08-20 22:16 libdrwxr-xr-x 4 root root 4096 08-20 22:14 mandrwxr-xr-x 10 root root 4096 08-20 22:15 mysql-test-rw-r--r-- 1 7161 wheel 2552 2011-07-14 READMEdrwxr-xr-x 2 root root 4096 08-20 22:15 scriptsdrwxr-xr-x 27 root root 4096 08-20 22:15 sharedrwxr-xr-x 4 root root 4096 08-20 22:16 sql-benchdrwxr-xr-x 2 root root 4096 08-20 22:16 support-files[root@localhost mysql]# chown -R mysql .[root@localhost mysql]# chgrp -R mysql .[root@localhost mysql]# ll总计 76drwxr-xr-x 2 mysql mysql 4096 08-20 22:15 bin-rw-r--r-- 1 mysql mysql 17987 2011-07-14 COPYINGdrwxr-xr-x 4 mysql mysql 4096 08-20 22:15 datadrwxr-xr-x 2 mysql mysql 4096 08-20 22:16 docsdrwxr-xr-x 3 mysql mysql 4096 08-20 22:15 include-rw-r--r-- 1 mysql mysql 7604 2011-07-14 INSTALL-BINARYdrwxr-xr-x 3 mysql mysql 4096 08-20 22:16 libdrwxr-xr-x 4 mysql mysql 4096 08-20 22:14 mandrwxr-xr-x 10 mysql mysql 4096 08-20 22:15 mysql-test-rw-r--r-- 1 mysql mysql 2552 2011-07-14 READMEdrwxr-xr-x 2 mysql mysql 4096 08-20 22:15 scriptsdrwxr-xr-x 27 mysql mysql 4096 08-20 22:15 sharedrwxr-xr-x 4 mysql mysql 4096 08-20 22:16 sql-benchdrwxr-xr-x 2 mysql mysql 4096 08-20 22:16 support-files 进行初始化[root@localhost mysql]# scripts/mysql_install_db --user=mysqlInstalling MySQL system tables...OKFilling help tables...OK To start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password 'new-password'./bin/mysqladmin -u root -h localhost.localdomain password 'new-password' Alternatively you can run:./bin/mysql_secure_installation which will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with:cd . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.plcd ./mysql-test ; perl mysql-test-run.pl Please report any problems with the ./bin/mysqlbug script! [root@localhost mysql]# 改回所有者和所有组[root@localhost mysql]# chown -R root .[root@localhost mysql]# ll总计 76drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYINGdrwxr-xr-x 5 root mysql 4096 08-20 22:32 datadrwxr-xr-x 2 root mysql 4096 08-20 22:16 docsdrwxr-xr-x 3 root mysql 4096 08-20 22:15 include-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARYdrwxr-xr-x 3 root mysql 4096 08-20 22:16 libdrwxr-xr-x 4 root mysql 4096 08-20 22:14 mandrwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test-rw-r--r-- 1 root mysql 2552 2011-07-14 READMEdrwxr-xr-x 2 root mysql 4096 08-20 22:15 scriptsdrwxr-xr-x 27 root mysql 4096 08-20 22:15 sharedrwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-benchdrwxr-xr-x 2 root mysql 4096 08-20 22:16 support-filesdata目录除外,所有者和所有组都是mysql[root@localhost mysql]# chown -R mysql data[root@localhost mysql]# ll总计 76drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYINGdrwxr-xr-x 5 mysql mysql 4096 08-20 22:32 datadrwxr-xr-x 2 root mysql 4096 08-20 22:16 docsdrwxr-xr-x 3 root mysql 4096 08-20 22:15 include-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARYdrwxr-xr-x 3 root mysql 4096 08-20 22:16 libdrwxr-xr-x 4 root mysql 4096 08-20 22:14 mandrwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test-rw-r--r-- 1 root mysql 2552 2011-07-14 READMEdrwxr-xr-x 2 root mysql 4096 08-20 22:15 scriptsdrwxr-xr-x 27 root mysql 4096 08-20 22:15 sharedrwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-benchdrwxr-xr-x 2 root mysql 4096 08-20 22:16 support-files拷贝配置文件[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf启动mysql[root@localhost mysql]# bin/mysqld_safe --user=mysql &[1] 3782[root@localhost mysql]# 120820 22:42:26 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdoma120820 22:42:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data查看端口[root@localhost mysql]# netstat -tupln |grep mysqltcp 0 0 :::3306 :::* LISTEN 4020/mysqld 为使方便启动mysql可以用下列方式[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld[root@localhost mysql]# service mysqld stopShutting down MySQL.120820 22:48:10 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended [确定][1]+ Done bin/mysqld_safe --user=mysql[root@localhost mysql]# service mysqld startStarting MySQL.. [确定][root@localhost mysql]# netstat -tupln |grep mysqltcp 0 0 :::3306 :::* LISTEN 4359/mysqld 每次开机自动启用[root@localhost mysql]# chkconfig --add mysqld[root@localhost mysql]# chkconfig --list |grep mysqlmysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭[root@localhost mysql]# chkconfig mysqld[root@localhost mysql]# chkconfig mysqldbin/ docs/ lib/ README sql-bench/ COPYING include/ man/ scripts/ support-files/ data/ INSTALL-BINARY mysql-test/ share/ [root@localhost mysql]# chkconfig mysqld on[root@localhost mysql]#调用库文件[root@localhost mysql]# cd /etc/ld.so.conf.d/[root@localhost ld.so.conf.d]# vim mysql.conf/usr/local/mysql/lib~ 调用头文件[root@localhost ld.so.conf.d]# cd /usr/local/mysql[root@localhost mysql]# ll总计 76drwxr-xr-x 2 root mysql 4096 08-20 22:15 bin-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYINGdrwxr-xr-x 5 mysql mysql 4096 08-20 22:48 datadrwxr-xr-x 2 root mysql 4096 08-20 22:16 docsdrwxr-xr-x 3 root mysql 4096 08-20 22:15 include-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARYdrwxr-xr-x 3 root mysql 4096 08-20 23:05 libdrwxr-xr-x 4 root mysql 4096 08-20 22:14 mandrwxr-xr-x 10 root mysql 4096 08-20 22:15 mysql-test-rw-r--r-- 1 root mysql 2552 2011-07-14 READMEdrwxr-xr-x 2 root mysql 4096 08-20 22:15 scriptsdrwxr-xr-x 27 root mysql 4096 08-20 22:15 sharedrwxr-xr-x 4 root mysql 4096 08-20 22:16 sql-benchdrwxr-xr-x 2 root mysql 4096 08-20 22:16 support-files[root@localhost mysql]# cd /usr/include/[root@localhost include]# ln -s /usr/local/mysql/include/ mysql 安装apache解压缩[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/进入目录并查看[root@localhost ~]# cd /usr/local/src/[root@localhost src]# cd httpd-2.2.19/[root@localhost httpd-2.2.19]# lsABOUT_APACHE buildconf emacs-style INSTALL LICENSE os srclibacinclude.m4 CHANGES httpd.dep InstallBin.dsp Makefile.in README supportApache.dsw config.layout httpd.dsp LAYOUT Makefile.win README.platforms testbuild configure httpd.mak libhttpd.dep modules README-win32.txt VERSIONINGBuildAll.dsp configure.in httpd.spec libhttpd.dsp NOTICE ROADMAPBuildBin.dsp docs include libhttpd.mak NWGNUmakefile server [root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --with-z[root@localhost httpd-2.2.19]# make[root@localhost httpd-2.2.19]#make install[root@localhost httpd-2.2.19]# cd /usr/local/apache/[root@localhost apache]# ll总计 56drwxr-xr-x 2 root root 4096 08-20 23:45 bindrwxr-xr-x 2 root root 4096 08-20 23:46 builddrwxr-xr-x 2 root root 4096 08-20 23:45 cgi-bindrwxr-xr-x 3 root root 4096 08-20 23:45 errordrwxr-xr-x 2 root root 4096 2011-05-21 htdocsdrwxr-xr-x 3 root root 4096 08-20 23:45 iconsdrwxr-xr-x 2 root root 4096 08-20 23:45 includedrwxr-xr-x 4 root root 4096 08-20 23:45 libdrwxr-xr-x 2 root root 4096 08-20 23:45 logsdrwxr-xr-x 4 root root 4096 08-20 23:46 mandrwxr-xr-x 14 root root 12288 2011-05-21 manualdrwxr-xr-x 2 root root 4096 08-20 23:45 modules启动apache[root@localhost apache]# cd bin/[root@localhost bin]# ./apachectl start[root@localhost bin]# netstat -tulpln |grep httpdtcp 0 0 :::80 :::* LISTEN 24284/httpd 调用库文件[root@localhost ld.so.conf.d]# vim httpd.conf/usr/local/apache/lib~ 调用头文件:[root@localhost lib]# cd /etc/ld.so.conf.d/[root@localhost include]# ln -s /usr/local/apache/include/ apache安装php[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src/[root@localhost ~]# cd /usr/local/src/[root@localhost src]# cd php-5.3.7/[root@localhostphp-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[root@localhost php-5.3.7]# make[root@localhost php-5.3.7]# make install 测试:测试apache测试php
[root@localhost htdocs]# vim index.html[root@localhost htdocs]# mv index.html index.php[root@localhost htdocs]# vim /etc/httpd/httpd.confAddType application/x-httpd-php.php<IfModule dir_module> DirectoryIndex index.php index.html</IfModule>重启apache[root@localhost htdocs]# /usr/local/apache/bin/apachectl stop[root@localhost htdocs]# /usr/local/apache/bin/apachectl start
结果如下
Php调用mysql测试 [root@localhost htdocs]# vim index.php<html><body><h1>It works!</h1></body></html><?php$link=mysql_connect('127.0.0.1','root','');if ($link) echo "yes";else echo "no"?>
进入mysql
[root@localhost htdocs]# /usr/local/mysql/bin/mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.5.15-log MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
本文出自 “牛晓林的blog” 博客,请务必保留此出处http://niuxiaolin.blog.51cto.com/5627962/976088