LAMP編譯安裝與編譯參數

mysql 編譯安裝與編譯參數
添加mysql組和mysql用戶
 
[root@centos mysql]# groupadd mysql
[root@centos mysql]# useradd -g mysql mysql
 
編譯與安裝
 
tar -zxvf mysql-5.1.35.tar.gz
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/data/mysql/data \    mysql數據目錄
--enable-assembler    \ 容許使用匯編模式(優化性能)
--with-unix-socket-path=/tmp/mysql.sock  使用unix套接字連接提升
--enable-thread-safe-client \以線程方式編譯客戶端 線程安全
--with-client-ldflags=-all-static \ 以純靜態方式編譯客戶端
--with-mysqld-ldflags=-all-static  以純靜態方式編譯服務端
--with-plugins=partition,innobase  支持引擎
--with-charset=utf8 
--with-collation=utf8_general_ci
--with-extra-charsets=all
--with-big-tables  支持大數據庫表
--without-debug   去除debug模式
make && make install
chmod +w /opt/mysql
chown -R mysql:mysql  /opt/mysql/
/opt/mysql/bin/mysql_install_db --user=mysql
/opt/mysql/bin/mysqld_safe --user=mysql &
 
 
mysql目錄權限設置
 
mkdir /usr/local/mysql/var
mkdir /var/run/mysqld
chmod +w /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /var/run/mysqld
cp /usr/local/mysql/share/mysql/my-innodb-heavy-4G.cnf /etc/my.cnf
 
 
以mysql用戶初始化數據庫表
 
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql
--datadir=/data/mysql/data  定義mysql數據存放目錄
 
注意:若是把數據目錄定義到其它目錄裏,得先修改/etc/my.cnf文件,加上如下二行
 
[mysqld]
# generic configuration options
port            = 3306
socket          = /tmp/mysql.sock
# wb config
basedir = /usr/local/mysql            字義mysql程序目錄
datadir = /data1/mysql/data         定義數據目錄
 
在對數據庫進行初始化表,否則mysql數據庫啓動會報錯.
 
啓動mysql服務
/usr/local/mysql/bin/mysqld_safe  --user=mysql --datadir=/data/mysql/data  (指定數據庫目錄)
 
/usr/local/mysql/bin/mysqld_safe --user=mysql 2>&1 > /dev/null &
 

1. -static  13%
   --with-client-ldflags=-all-static
   --with-mysqld-ldflags=-all-static
靜態連接提升13%性能
2. -pgcc  1%
   CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
     CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \
     -felide-constructors -fno-exceptions -fno-rtti"
若是是Inter處理器,使用pgcc提升1%性能
3. Unix Socket  7.5%
   --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
使用unix套接字連接提升7.5%性能,因此在windows下mysql性能確定不如unix下面
4. --enable-assembler
容許使用匯編模式(優化性能)
  
下面是整體的編譯文件

編譯代碼
 
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \ 
       -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp"  
    ./configure \  
       --prefix=/usr/local/mysql --enable-assembler \  
       --with-mysqld-ldflags=-all-static  
       --with-client-ldflags=-all-static  
       --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock  
     --with-charset=utf8  
       --with-collation=utf8_general_ci  
       --with-extra-charsets=all  

編譯MySQL的過程當中提示:
/bin/rm: cannot remove `libtoolt': No such file or directory
解決:
一、確認libtool是否已經安裝,若是沒有安裝的話,則先安裝libtool
# yum -y install libtool
二、分別執行如下三條命令:
# autoreconf --force --install
# libtoolize --automake --force
# automake --force --add-missing
 
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-unix-socket-path=/tmp/mysql.sock --with-charset=utf8 --with-collation=utf8_general_ci  --with-extra-charsets=all --with-pthread  --with-plugins=all
 
經常使用apache編譯參數說明
查看源代碼打印幫助1 prefix                 指定安裝目錄 
2 enable-rewrite         支持 URL 重寫 
3 enable-deflate         支持網頁壓縮 
4 enable-speling         糾正常見的URL拼寫錯誤 
5 enable-ssl             SSL/TLS support (mod_ssl) 
6 with-module            加載模塊
經常使用mysql編譯參數說明
查看源代碼打印幫助1 enable-assembler                     使用一些字符函數來彙編版本 
2 with-extra-charsets=complex          使用的字符集爲默認(無,複雜的,全部,或從上述設置選定的名單) 
3 enable-thread-safe-client            讓客戶端支持線程 
4 with-big-tables                      大表支持 
5 with-readline                        Use system readline instead of bundled copy
6 with-ssl                             Include SSL support 
7 with-embedded-server                 編譯成embedded MySQL library (libmysqld.a) 
8 enable-local-infile                  讓mysql支持從本地文件 導入數據庫 
9 with-plugins=innobase                存儲引擎 
10 with-charset=utf8                    設置默認字符集 
11 with-collation=utf8_general_ci       設置字符集校驗規則
經常使用PHP編譯參數說明
查看源代碼打印幫助1 with-config-file-path              指定php.ini位置 
2 with-apxs2                         整合 apache,apxs功能是使用mod_so中的LoadModule指令,加載指定模塊到 apache,要求 apache 要打開SO模塊 
3 with-mysql                         mysql安裝目錄,對mysql的支持 
4 with-mysqli                        mysqli文件目錄,優化支持 
5 with-iconv-dir                     iconv函數,對字符集間的轉換 
6 with-freetype-dir                  打開對freetype字體庫的支持 
7 with-jpeg-dir                      打開對jpeg圖片的支持 
8 with-png-dir                       打開對png圖片的支持 
9 with-zlib                          打開zlib庫的支持 
10 with-libxml-dir                    打開libxml2庫的支持 
11 enable-xml                         打開xml的支持 
12 enable-inline-optimization         優化線程 
13 with-curl                          打開curl瀏覽工具的支持 
14 with-curlwrappers                  運用curl工具打開url流 
15 enable-mbregex                     打開對mbregex的支持 
16 enable-mbstring                    多字節,字符串的支持 
17 with-mcrypt                        算法 
18 with-gd                            打開gd庫的支持 
19 enable-gd-native-ttf               支持TrueType字符串函數庫 
20 with-openssl                       openssl的支持,加密傳輸時用到的 
21 with-mhash                         算法 
22 enable-pcntl                       freeTDS須要用到的,多是連接mssql 纔用到 
23 enable-sockets                     打開 sockets 支持 
24 with-ldap                          Include LDAP support 
25 with-ldap-sasl                     LDAP: Include Cyrus SASL support 
26 with-xmlrpc                        打開xml-rpc的c語言 
27 enable-zip                         打開對zip的支持 
28 enable-soap                        Enable SOAP support 
29 with-gettext                       打開gnu 的gettext 支持,編碼庫用到 
30 ----------------------------------------------------------- 
31 enable-track-vars 

32 在php作web腳本時候有用,在GET/POST/Cookie裏追蹤php變量。 大概是因爲安全性緣由,較新版本的php已經廢棄了這個編譯選項php

相關文章
相關標籤/搜索