Linux简单安装Mysql+Apach+PHP

时间 : 14-10-30 栏目 : 网站架构 作者 : 老薛 评论 : 3 点击 : 1,392 次

Linux简单安装Red Hat Enterprise Linux Server release 5.3+Mysql+Apach+PHP

2011年08月05日 星期五 上午 09:00

网上一朋友被Red Hat Enterprise Linux Server release 5.4+Mysql+Apach+PHP部署所困扰,这为朋友很有恒心,一直苦苦钻研。今天自己写了一个简单的安装步骤,给这位恒心网友一个思路,希望对你有所帮助!

一、安装环境检测【我以5.3为例,手边没有5.4】

[root@localhost tools]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 5.3 (Tikanga)

[root@localhost tools]# uname -r

2.6.18-128.el5

[root@localhost tools]# uname -a

Linux localhost 2.6.18-128.el5 #1 SMP Wed Jan 21 08:45:05 EST 2009 x86_64 x86_64 x86_64 GNU/Linux

二、准备所需软件包

httpd-2.2.13.tar.gz

mysql-5.1.56.tar.gz

php-5.2.14.tar.gz

三、安装httpd-2.2.13.tar.gz

tar zxvf httpd-2.2.13.tar.gz

cd httpd-2.2.13

./configure --prefix=/usr/local/apache2.2.13 \

--enable-deflate \

--enable-headers \

--enable-modules=so \

--enable-so \

--with-mpm=worker \

--enable-rewrite \

--enable-cgi \

--enable-file-cache \

--enable-cache \

--enable-disk-cache \

--enable-mem-cache

make

make install

cd ../

ln -s /usr/local/apache2.2.13 /usr/local/apache

useradd apache -M -s /sbin/nologin

打开/application/apache/conf/httpd.conf

#--------------------------------------#

修改:#ServerName www.example.com:80

为 ServerName 127.0.0.1:80

#--------------------------------------#

修改166行DirectoryIndex index.html

为DirectoryIndex index.php index.html

#---------------------------------------#

修改65行User daemon

为User apache

修改66行Group daemon

为Group apache

#-------------------------------------------#

在309行下面添加如下两行

AddType application/x-httpd-php .php .php3

AddType application/x-httpd-php-source .phps

#-------------------------------------------#

添加到开机启动项

echo '/usr/local/apache/bin/apachectl start ' >> /etc/rc.local

检查httpd.conf语法

/usr/local/apache/bin/apachectl –t

启动apache服务

/usr/local/apache/bin/apachectl start

检查服务

[root@localhost tools]# ps -ef |grep -v grep |grep httpd

root    10693     1 0 02:43 ?       00:00:00 /usr/local/apache2.2.13/bin/httpd -k start

apache   10694 10693 0 02:43 ?       00:00:00 /usr/local/apache2.2.13/bin/httpd -k start

apache   10695 10693 0 02:43 ?       00:00:00 /usr/local/apache2.2.13/bin/httpd -k start

apache   10697 10693 0 02:43 ?       00:00:00 /usr/local/apache2.2.13/bin/httpd -k start

apache   10699 10693 0 02:43 ?       00:00:00 /usr/local/apache2.2.13/bin/httpd -k start

[root@localhost tools]# netstat -lnt |grep 80

tcp       0     0 :::80                       :::*                       LISTEN

打开浏览器进行测试

11

说明apache安装成功

FAQ:当你遇到如下错误

configure:3699: checking for cl.exe

configure:3729: result: no

configure:3753: error: in `/usr/local/src/tools/httpd-2.2.13/srclib/apr':

configure:3756: error: no acceptable C compiler found in $PATH

See `config.log' for more details.

解决办法:yum install gcc*

#========================================================================#

添加测试首页

echo -e "<?php \nphpinfo(); \n?>" >/usr/local/apache/htdocs/index.php

 

#============================#

#=================安装mysql-5.1.56.tar.gz ===============================#

groupadd mysql

useradd -s /sbin/nologin -g mysql -M mysql

tar zxvf mysql-5.1.56.tar.gz

cd mysql-5.1.56

./configure --prefix=/usr/local/mysql/ \

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \

--localstatedir=/usr/local/mysql/data \

--with-extra-charsets=all

make

make install

cd ../

/bin/cp support-files/my-small.cnf /etc/my.cnf

mkdir -p /usr/local/mysql/data

/usr/local/mysql/bin/mysql_install_db --user=mysql

chgrp -R mysql /usr/local/mysql

cp support-files/mysql.server /usr/local/mysql/bin/

chmod 700 /usr/local/mysql/bin/mysql.server

/usr/local/mysql/bin/mysql.server start

echo "export PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile

source /etc/profile

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

chkconfig --add mysqld

service mysqld restart

mysql -uroot -p

#-----------------------------------------------#

FAQ:

checking for tgetent in -ltinfo... no

checking for termcap functions library... configure: error: No curses/termcap library found

解决办法:

解决办法:

下载安装相应软件包

一、如果你的系统是RedHat系列:

yum list|grep ncurses

yum -y install ncurses-devel

yum install ncurses-devel

 

二、如果你的系统是Ubuntu或Debian:

apt-cache search ncurses

apt-get install libncurses5-dev

 

待安装completed!之后,再./configure,顺利通过,然后make && make install,成功安装,一切OK!~~~

 

#===============================================#

三、安装php (php-5.1.6.tar.bz2)

#######libiconv库###########################

tar -zxvf libiconv-1.10.tar.tar

cd libiconv-1.10

./configure --prefix=/usr/local/libiconv

make

make install

cd ../

###########################################

tar -zxvf php-5.2.14.tar.gz

cd php-5.2.14

./configure \

--prefix=/usr/local/php \

--with-apxs2=/application/apache/bin/apxs \

--with-mysql=/usr/local/mysql \

--with-ttf \

--with-xmlrpc \

--with-openssl \

--with-zlib \

--with-freetype-dir \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-iconv=/usr/local/libiconv \

--enable-short-tags \

--enable-sockets \

--enable-zend-multibyte \

--enable-soap \

--enable-mbstring \

--enable-static \

--enable-gd-native-ttf \

--with-curl

make

make install

cp php.ini-recommended /usr/local/php/lib/php.ini

/application/apache/bin/apachectl restart

cd ../

12

#-----------------------------------------------------------------------#

FAQ:

问题1、checking libxml2 install dir... no

checking for xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法:

yum install libxml2*

问题2、configure: error: Cannot find OpenSSL's <evp.h>

解决办法:

Yum install openssl*

问题3、configure: error: Please reinstall the libcurl distribution -

easy.h should be in <curl-dir>/include/curl/

解决办法:

yum -y install curl-devels

问题4、checking for floorf... yes

configure: error: libjpeg.(a|so) not found.

解决办法:

yum install libjpeg-devel

问题5、checking for jpeg_read_header in -ljpeg... yes

configure: error: libpng.(a|so) not found.

yum install libpng-devel

为避免以上问题的出现,在开始安装php之前,可以先对系统检查,

检查包包

rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv

zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

看以上包包是否安装,如果没有就提前安装,免的./configure时报错,耽误时间。

#=======================================================================#

至此,一份简单lamp环境安装部署完毕。

 

 

 

本文标签

除非注明,文章均为( 老薛 )原创,转载请保留链接: http://www.bdkyr.com/architecture/362.html

Linux简单安装Mysql+Apach+PHP:目前有3 条留言

  1. 板凳
    gywy05
    Post: 2017-11-28 下午4:11
  2. 沙发
    小帅
    Post: 2017-12-11 下午4:36

    昨天又对着文档来了一遍

    • admin
      admin
      Post: 2017-12-11 下午4:39

      温故而知新,贵在重复。

发表评论

5 + 0 = ?


博主微信号,很高兴为您提供帮助

随便看看

3