CentOS安裝\卸載 apache、mysql、php

來源:互聯網
上載者:User

標籤:

使用命令安裝:

1.安裝apache

#yum -y install httpd

 

2.安裝mysql

#yum -y install mysql

#yum -y install mysql-server

#yum -y install mysql-devel

#chkconfig --levels 235 mysqld on // 讓mysql自啟動

 

3.安裝php

#yum -y install php

#yum -y install php-devel

 

/////////////////////////////////////

使用源碼編譯安裝:

1.編譯apache

1)下載apache源碼

http://httpd.apache.org/download.cgi#apache24

2)#./configure --prefix=/usr/local/apache --with-apr=/usr/local/arp --with-apr-util=/usr/local/apr-util

提示:

configure: error: APR not found. Please read the document.

下載apr-1.5.2.tar.bz2: 

http://apr.apache.org/download.cgi

#tar xjf apr-1.5.2.tar.bz2 // 解壓bz2格式

#cd apr-1.5.2

#./configure --prefix=/usr/local/apr

#make && make install

3)再次執行:

#./configure --prefix=/usr/local/apache --with-apr=/usr/local/arp --with-apr-util=/usr/local/apr-util

提示:apr-util未安裝

下載apr-util-1.5.4.tar.bz2:

http://apr.apache.org/download.cgi // 同上面的apr地址相同

解壓編譯:

#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

#make && make install

4)再次執行:

#./configure --prefix=/usr/local/apache --with-apr=/usr/local/arp --with-apr-util=/usr/local/apr-util

提示:

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

下載pcre:
http://sourceforge.net/projects/pcre/postdownload?source=dlp
#unzip -o pcre-8.10.zip // 如果沒有,則 yum -y install unzip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre

5)執行

#./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ 

#make && make install

安裝完畢。

6)啟動apache伺服器:

#/usr/local/apache2/bin/apachectl start

7)使用瀏覽器訪問 http://xxx.xxx.xx.xxx 會顯示頁面。

 

2.編譯php源碼

1)下載php源碼:

http://php.net/get/php-5.6.10.tar.bz2/from/a/mirror

2)

#tar xjf php-5.6.10.tar.bz2 // 解壓
#cd php-5.6.10
#執行

./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache2/bin/apxs
--with-config-file-path=/usr/local/php/etc
--with-jpeg-dir
--with-png-dir
-with-bz2
--with-freetype-dir
--with-iconv-dir
--with-zlib-dir
--enable-soap
--enable-gd-native-ttf
--enable-ftp
--enable-sockets
--enable-mbstring
--enable-exif

 

安裝PHP時候出錯:
configure: error: xml2-config not found. Please check your libxml2 installation.

yum -y install libxml2
安裝完仍然提示,xml2-config not found.原來是libxml2-devel 沒裝,可以執行以下命令:
yum -y install libxml2*
安裝libxml2-devel.x86_64 0:2.7.6-17.el6_6.1

錯誤2:
configure: error: Please reinstall the BZip2 distribution
yum -y install bzip2 bzip-devel

如提示出錯,一般為依賴庫沒找到,按提示安裝對應的依賴庫即可。

 

附: PHP編譯configure時常見錯誤:
http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html

3)#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-jpeg-dir --with-png-dir -with-bz2 --with-freetype-dir --with-iconv-dir --with-zlib-dir --enable-soap --enable-gd-native-ttf --enable-ftp --enable-sockets --enable-mbstring --enable-exif

#make && make install

安裝完畢。

 

///////////////////////////////////////

卸載:

1.卸載apache

/etc/init.d/httpd stop // 停止httpd服務

#rpm -qa | grep httpd

httpd-2.2.3-63.el5.centos.1

httpd-manual-2.2.3-63.el5.centos.1

2)卸載包

rpm -e httpd-manual-2.2.3-63.el5.centos.1

rpm -e system-config-httpd-1.3.3.3-1.el5

或:

rpm -e httpd

提示存在依賴項:

" error: Failed dependencies: httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386"

#rpm -e gnome-user-share

或者使用參數–nodeps不管各個程式包間的依賴關係

#rpm -e –nodeps httpd //這樣就不需要刪除gnome-user-share了

 

2.卸載php

1)查看機器上安裝的所有php相關的rpm包

#rpm -qa | grep php

php-cli-5.3.3-22.el6.x86_64

php-pdo-5.3.3-22.el6.x86_64

php-gd-5.3.3-22.el6.x86_64

php-fpm-5.3.3-22.el6.x86_64

php-common-5.3.3-22.el6.x86_64 

php-5.3.3-22.el6.x86_64

php-xml-5.3.3-22.el6.x86_64

php-pear-1.9.4-4.el6.noarch

2)按依賴順序進行刪除

rpm -e php-fpm-5.3.3-22.el6.x86_64

rpm-e php-pdo-5.3.3-22.el6.x86_64

rpm -e php-pear-1.9.4-4.el6.noarch

rpm-e php-cli-5.3.3-22.el6.x86_64

rpm -e php-5.3.3-22.el6.x86_64

rpm-e php-xml-5.3.3-22.el6.x86_64

rpm -e php-gd-5.3.3-22.el6.x86_64

rpm-e php-common-5.3.3-22.el6.x86_64

 

3.卸載mysql

1)查看系統中是否以rpm包安裝的msyql:

#rpm -qa | grep -i mysql

MySQL-server-5.6.17-1.el6.i686
MySQL-client-5.6.17-1.el6.i686

2)卸載mysql

#rpm -e MySQL-server-5.6.17-1.el6.i686

#rpm -e MySQL-client-5.6.17-1.el6.i686

3)刪除msyqld服務

#chkconfig --list | grep -i mysql

#chkconfig --del mysql

4)刪除分散的mysql檔案夾

#whereis mysql

#find / -name mysql

mysql: /usr/lib/mysql /usr/share/mysql

清空相關mysql的所有目錄以及檔案

#rm -rf /usr/lib/mysql

#rm -rf /usr/share/mysql

#rm -rf /usr/my.cnf

 

CentOS安裝\卸載 apache、mysql、php

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.