lamp 搭建(apache2.2.31+mysql5.1.72+php5.3)
在服务器 192.168.37.128 上搭建 lamp(apache2.2.1+mysql5.1.72+php5.3)
1)安装 apache2.2.31(在默认站点目录 htdocs)
[root@localhost ~]# mkdir /apache
rz 上传 apache 包
[root@localhost ~]# cd /apache/
[root@localhost apache]# ls
httpd-2.2.31.tar.gz
[root@localhost apache]# yum -y install gcc gcc-c++ #安装编译工具
[root@localhost apache]# yum -y install zlib zlib-devel #安装依赖包,否则报下面错误:
checking for zlib location... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not
be built due to prerequisite failures
[root@localhost apache]#useradd apache -s /sbin/nologin -M
[root@localhost apache]# tar -zxf httpd-2.2.31.tar.gz #安装 apache
[root@localhost apache]# ls
httpd-2.2.31 httpd-2.2.31.tar.gz
[root@localhost apache]# cd httpd-2.2.31
[root@localhost httpd-2.2.31]# ls
ABOUT_APACHE BuildBin.dsp configure.in httpd.mak LAYOUT Makefile.in os server
acinclude.m4 buildconf docs httpd.spec libhttpd.dep Makefile.win README srclib
Apache.dsw CHANGES emacs-style include libhttpd.dsp modules README.platforms support
build config.layout httpd.dep INSTALL libhttpd.mak NOTICE README-win32.txt test
BuildAll.dsp configure httpd.dsp InstallBin.dsp LICENSE NWGNUmakefile ROADMAP VERSIONING
[root@localhost httpd-2.2.31]#./configure --prefix=/usr/local/apache \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
回车
[root@localhost httpd-2.2.31]# make && make install
[root@localhost httpd-2.2.31]# ls /usr/local/apache/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
[root@localhost httpd-2.2.31]# /usr/local/apache/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using
localhost.localdomain for ServerName
[root@localhost httpd-2.2.31]# cat /usr/local/apache/conf/httpd.conf
User apache #修改成 apache 用户
Group apache #修改成 apahce 组
<Directory "/usr/local/apache/htdocs">
Options -Indexes FollowSymLinks //修改,前面加-,优化措施
……
Include conf/extra/httpd-vhosts.conf //注释不要打开,如果打开,就需要在后面文件中配置虚拟主机
[root@localhost httpd-2.2.31]# chown -R apache.apache /usr/local/apache/htdocs/
[root@localhost httpd-2.2.31]# /usr/local/apache/bin/apachectl graceful
httpd: Could not reliably determine the server's fully qualified domain name, using
localhost.localdomain for ServerName
[root@localhost httpd-2.2.31]# netstat -anptu |grep httpd
tcp 0 0 :::80 :::* LISTEN 57131/httpd
2)安装 mysql5.1.72
[root@localhost httpd-2.2.31]# cd
[root@localhost ~]# mkdir /mysql
上传 mysql 包
[root@localhost ~]# cd /mysql/
[root@localhost mysql]# ls
mysql-5.1.72.tar.gz
[root@localhost mysql]# useradd mysql -M -s /sbin/nologin
[root@localhost mysql]# yum -y install ncurses-devel #安装 mysql 依赖包,否则报下面错误
checking for termcap functions library... configure: error: No curses/termcap library found
[root@localhost mysql]# tar -zxf mysql-5.1.72.tar.gz #安装 mysql
[root@localhost mysql]# ls
mysql-5.1.72 mysql-5.1.72.tar.gz
[root@localhost mysql]# cd mysql-5.1.72
[root@localhost mysql-5.1.72]# ls
aclocal.m4 config dbug INSTALL-SOURCE Makefile.am netware sql tests
BUILD config.guess depcomp INSTALL-WIN-SOURCE Makefile.in plugin sql-bench unittest
ChangeLog config.sub Docs libmysql man README sql-common vio
client configure extra libmysqld missing regex storage win
CMakeLists.txt configure.in include libmysql_r mysql-test scripts strings ylwrap
cmd-line-utils COPYING install-sh ltmain.sh mysys server-tools support-files zlib
[root@localhost mysql-5.1.72]# ./configure \
--prefix=/usr/local/mysql \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--localstatedir=/usr/local/mysql/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
//回车即可。