Linux簡單安裝Mysql+Apach+PHP+phpMyAdmin

Linux簡單安裝Red Hat Enterprise Linux Server release 5.3+Mysql+Apach+PHP

20110805日 星期五 上午 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

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

修改166DirectoryIndex index.html

DirectoryIndex index.php index.html

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

修改65User daemon

User apache

修改66Group 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 

打開瀏覽器進行測試


說明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

 

二、如果你的系統是UbuntuDebian

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 ../


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

FAQ:

問題1checking libxml2 install dir... no

checking for xml2-config path...

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

解決辦法:

yum install libxml2*

問題2configure: error: Cannot find OpenSSL's <evp.h>

解決辦法:

Yum install openssl*

問題3configure: error: Please reinstall the libcurl distribution -

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

解決辦法:

yum -y install curl-devels

問題4checking for floorf... yes

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

解決辦法:

yum install libjpeg-devel

問題5checking 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環境安裝部署完畢。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章