編譯安裝軟件通常會遇到各種問題,尤其是在編譯lamp這樣的多種軟件協同工作時各軟件還相互影響,尤其是之前安裝的軟件會影響後邊程序的編譯安裝,出現這種問題常常是之前安裝的軟件沒有導出庫文件和頭文件,因而導致後面的軟件在安裝是需要指定前面安裝程序的路徑時常常提示找不到文件之類的錯誤,下面以mysql為例
1、安裝開發環境
yum groupinstall "Development tools"
2、解決軟件包依賴包
安裝編譯代碼需要的包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
下載MySQL 5.6.14
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz tar xvf mysql-5.6.14.tar.gz cd mysql-5.6.14
3、配置編譯並安裝
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install
4、導出庫搜索
在 /etc/ld.conf.d/mysql.conf 目錄下創建相應的conf文件
ldconfig -v | grep mysql
5、導出頭文件
ln -sv /usr/local/mysql/include /usr/include/mysql
6、導出幫助文件
vim /etc/man.config MANPATH /usr/local/mysql/man
7、導出二進制路徑
vim /etc/profile PATH=/usr/local/mysql/bin:$PATH source /etc/profile
PS:如何使用MySQL yum源來安裝更新MySQL相關軟件包
MySQL yum庫提供了一個簡單的和方便的方法來安裝和更新MySQL相關的軟件包到最新版本。
MySQL yum庫文檔說明:http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
MySQL yum庫支持的平台有:
Red Hat Enterprise Linux 7 / Oracle Linux 7
Red Hat Enterprise Linux 6 / Oracle Linux 6
Red Hat Enterprise Linux 5 / Oracle Linux 5
Fedora 18, 19, and 20
MySQL yum庫包括最新的軟件包有:
RHEL7/CentOS7/Oracle linux7:
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm # rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
RHEL5/CentOS5/Oracle linux5:
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el5-5.noarch.rpm
Fedora
# Fedora20
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc20-5.noarch.rpm
#Fedora19
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc19-5.noarch.rpm
# Fedora18
# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-fc18-5.noarch.rpm