Linux 安裝MySQL+apache+openssl+php

平臺環境:virtual PC 2007 + CentOS 5.8(軟件只裝基本+開發)php

在剛裝好的CentOS 5.8上發現已默認安裝 http-2.2.3-63.el5.centos,openssl-0.9.8e-22.el5,以下圖,須要更新到最新版本。html

下載的新安裝包均放於/usr/local/srcmysql

 一、更新openssllinux

下載最新的包:openssl-1.0.1c.tar.gzsql

#cd /usr/local/src數據庫

#tar -xzvf openssl-1.0.1c.tar.gzapache

#mv -xzvf openssl-1.0.1c.tar.gz opensslcentos

#./config shared服務器

#make     app

#make test

#make install

【注意openssl默認安裝路徑 : /usr/local/ssl】

#mv /usr/bin/openssl /usr/bin/openssl.OFF

#mv /usr/lib/openssl /usr/lib/openssl.OFF

#ln –s /usr/local/ssl/bin/openssl /usr/bin/openssl
#ln –s /usr/local/ssl/include/openssl /usr/include/openssl 
 配置庫文件搜索路徑
#echo 「/usr/local/ssl/lib」 >> /etc/ld.so.conf
#ldconfig –v
查看openssl 版本號,驗證安裝正確性

#openssl version –a


參考:Openssh+Openssl更新步驟 http://linux.chinaunix.net/techdoc/net/2008/12/20/1053890.shtml

        源碼方式升級openssl和openssh http://init7.blog.51cto.com/860934/178782

2.卸載舊的apache

rpm -e httpd-2.2.3-63.el5.386   #卸載http時提示與 gnome-user-share-0.10-6.i386關聯,那就先卸載gnome-user-share

3.安裝MySQL

官網下載6個包:

  • MySQL-client-5.5.24-1.linux2.6.i386.rpm
  • MySQL-devel-5.5.24-1.linux2.6.i386.rpm
  • MySQL-embedded-5.5.24-1.linux2.6.i386.rpm
  • MySQL-server-5.5.24-1.linux2.6.i386.rpm
  • MySQL-shared-5.5.24-1.linux2.6.i386.rpm
  • MySQL-shared-compat-5.5.24-1.linux2.6.i386.rpm
#cd /usr/local/src    

#rpm –ivh Mysql-*.rpm

#service mysql start  #啓動MYSQL服務

#/usr/bin/mysqladmin -u root password  123456  #設置root的密碼

# /sbin/chkconfig – add mysql   #把MySQL添加到你係統的啓動服務組裏面去

【MySQL默認的目錄】

一、數據庫目錄             /var/lib/mysql/

二、配置文件目錄          /usr/share/mysql(mysql.server命令及配置文件)

三、相關命令目錄           /usr/bin(mysqladmin mysqldump等命令)

四、啓動腳本目錄           /etc/rc.d/init.d/(啓動腳本文件mysql的目錄)

【更改MYSQL數據庫目錄】

cd /home

mkdir data    #home目錄下創建data目錄

mysqladmin -u root -p shutdown   #把MySQL服務進程停掉:

 mv /var/lib/mysql /home/data/  #把MySQL的數據文件移動到了/home/data/mysql下

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf       #/etc/目錄下沒有my.cnf配置文件,請到/usr/share/mysql/下找到*.cnf文件,拷貝其中一個到/etc/並更名爲my.cnf)中

【修改my.snf】

vi /etc/my.cnf 

將client,server項均修改爲如下內容

#socket = /var/lib/mysql/mysql.sock     ##原內容,爲了更穩妥用「#」註釋此行

socket = /home/data/mysql/mysql.sock #加上此行

【修改MySQL啓動腳本,更新datadir爲實際存放路徑】

vi /etc/rc.d/init.d/mysql  

#datadir=/var/lib/mysql##註釋此行

datadir=/home/data/mysql ##

/etc/rc.d/init.d/mysql start  //從新啓動MySQL服務,若是工做正常移動就成功了,

 【修改後的MySQL目錄】

一、數據庫目錄             /home/data/mysql

二、配置文件目錄          /etc/my.cnf  ; /usr/share/mysql(mysql.server命令及配置文件)

三、相關命令目錄           /usr/bin(mysqladmin mysqldump等命令)

四、啓動腳本目錄           /etc/rc.d/init.d/(啓動腳本文件mysql的目錄)

 參考;rpm安裝mysql http://my.oschina.net/wenic705/blog/6126


4.安裝apache

下載 httpd-2.2.22.tar.gz

#cd /usr/local/src    

#tar -zxvf httpd-2.2.22.tar.gz

#mv httpd-2.2.22 http

【apache安裝到/usr/local/apache目錄下,httpd.conf安裝到:/etc/httpd目錄下】

#./configure --prefix=/usr/local/apache  --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-mods-shared=most

 #make

#make install

# /usr/local/apache/bin/apachectl start   //啓動http服務

將apache註冊爲系統服務

首先將apachectl命令拷貝至/etc/rc.d/init.d目錄下,更名爲httpd

cp  /usr/local/apache/bin/apachectl   /etc/rc.d/init.d/httpd
使用編輯器打開httpd文件,並在第一行#!/bin/sh下增長兩行文字以下
# chkconfig: 35 70 30
# description: Apache
接着註冊該服務
chkconfig --add httpd
service httpd start
chkconfig httpd on

5.安裝php

 下載php-5.4.3.tar.gz

#cd /usr/local/src    

#tar -zxvf php-5.4.3.tar.gz

# cd php

#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc

/*  ./configure 時提示libxml2沒找到,在centos5.8光盤找到libxml2-2.6.26-2.1.12.el5_7.2.i386.rpm,libxml2-devel-2.6.26-2.1.12.el5_7.2.i386.rpm,zlib-devel-1.2.3-4.el5.i386.rpm,zlib-1.2.3-4.el5.i386.rpm全裝上先 */

#make

#make install

#cd /usr/local/src/php

#cp php.ini-development /etc

#cd /etc

#mv php.ini-development php.ini

 【修改apache的httpd.conf】

#vi /etc/httpd/httpd.conf

添加:

AddType application/x-httpd-php .php

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

注意將這兩行添加在其它AddType後面

確保文件中有下面一段,若是沒有地話就添加在全部LoadModule以後

LoadModulephp5_module        modules/libphp5.so (通常安裝php時帶--with-apxs2=XXX時會自動添加)

找到DirectoryIndex index.html index.html.var 這一行,在其後面寫上index.php 

【】

在/usr/local/apache/htdocs/下面創建php文件。

# vi /usr/local/apache/htdocs/index.php

輸入:

<?

    phpinfo();

?>

重啓apache服務器

# /usr/local/apache/bin/apachectl restart


【重啓httpd時提示:cannot restore segment prot after reloc: Permission denied

在linux上安裝有些東西時會出現 Permission denied 的狀況:如下就是解決它的辦法之一
編輯/etc/selinux/config,找到這段:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
把 SELINUX=enforcing 註釋掉:#SELINUX=enforcing ,而後新加一行爲:

SELINUX=disabled保存,關閉。
……

編輯/etc/sysconfig/selinux,找到:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing若是SELINUX已是 SELINUX=disabled,那麼就不用改了,不然就把SELINUX=enforcing 註釋掉,新加一行:

SELINUX=disabled保存,退出。

若是你碰到其餘相似提示:
cannot restore segment prot after reloc: Permission denied
哪應該是SELinux的問題,能夠考慮把它關閉。
————————————————————————————-
若是還不行,在你保證SElinux 被disable後.還執行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路徑/路徑/名字.so (這個文件視具體執行文件.)

 

參考

一、linux下apache+php+mysql安裝配置文檔 http://blog.csdn.net/irwin_chen/article/details/7359022

二、linux下apache+php+mysql升級安裝過程  http://school.21tx.com/2008/10/20/13911.html

相關文章
相關標籤/搜索