編譯安裝AMP:
1、編譯安裝httpd-2.4.27
1.編譯安裝aprphp
# cd apr-1.5.2 # ./configure --prefix=/usr/local/apr-152 # make -j 4 && make install 2.編譯安裝apr-util # tar xf apr-util-1.5.4.tar.gz # cd apr-util-1.5.4 # ./configure --prefix=/usr/local/apr-util-154 --with-apr=/usr/local/apr-152 # make -j 4 && make install 3.編譯安裝httpd # tar xf httpd-2.4.27.tar.gz # cd httpd-2.4.27 # ./configure --prefix=/usr/local/apache-2427 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-apr=/usr/local/apr-152 --with-apr-util=/usr/local/apr-util-154 --with-zlib --with-mpm=event --with-pcre # make -j 4 && make install 4.安裝後的收尾工做: 1) 導出二進制文件: 建立/etc/profile.d/httpd24.sh export PATH=/usr/local/apache-2427/bin:$PATH 建立此文件後,使用source命令(.)來使其內容生效; 2) 導出幫助文檔: 編輯/etc/man.config 在任意位置添加一條配置指令: MANPATH /usr/local/apache-2427/man 3) 導出頭文件: # ln -sv /usr/local/apache-2427/include/ /usr/include/httpd 5.配置工做: /etc/httpd24/httpd.conf PidFile /var/run/httpd24.pid 6.提供sysv風格的服務管理腳本:/etc/init.d/httpd
#!/bin/bash
#mysql
#linux
. /etc/rc.d/init.d/functionssql
if [ -f /etc/sysconfig/httpd24 ]; then
. /etc/sysconfig/httpd24
fi數據庫
HTTPD_LANG=${HTTPD_LANG-"C"}apache
INITLOG_ARGS=""bootstrap
apachectl=/usr/local/apache-2427/bin/apachectl
httpd=${HTTPD-/usr/local/apache-2427/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd24.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0vim
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}api
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}bash
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
上述腳本建立以後,須要完成下列操做: # chmod +x /etc/init.d/httpd # chkconfig --add httpd # chkconfig httpd on 2、使用通用二進制格式的MariaDB包安裝MariaDB: 1.解壓縮二進制程序包到指定目錄(/usr/local) # tar xf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local 2.建立用於啓動服務和管理數據的用戶和組: # groupadd -r -g 306 mysql # useradd -r -u 306 -g mysql mysql 3.建立數據目錄並修改相應文件的權限: # mkdir -pv /mydata/data # chown mysql. /mydata/data # ln -sv /usr/local/mariadb-5.5.57-linux-x86_64 /usr/local/mysql # cd /usr/local/mysql # chown -R mysql. . # cp support-files/my-large.cnf /etc/my.cnf datadir = /mydata/data innodb_file_per_table = ON skip_name_resolve = ON # cp support-files/mysql.server /etc/init.d/mysqld 4.導出二進制文件: # vim /etc/profile.d/mariadb5557.sh export PATH=/usr/local/mysql/bin:$PATH 5.導出幫助文檔: # vim /etc/man.config MANPATH=/usr/local/mysql/man 6.導出頭文件: # ln -sv /usr/local/mysql/include /usr/include/mysql 7.導出庫文件: # vim /etc/ld.so.conf.d/mariadb5557.conf /usr/local/mysql/lib # ldconfig [-v] 8.初始化數據庫: # scripts/mysql_install_db --user=mysql --datadir=/mydata/data/ 9.啓動服務並設置隨機自動啓動: # chkconfig --add mysqld # chkconfig mysqld on # service mysqld start 10.檢查服務啓動狀態: # service mysqld status # ss -tnl # netstat -ntl 3、編譯安裝php-5.6.31 想要正確的編譯php-5.6.31,可能須要解決下列依賴關係: libxml2-devel gd-devel freetype-devel libmcrypt-devel # yum install libxml2-devel freetype-devel libmcrypt-devel # yum install gd-devel-2.0.35-11.el6.x86_64.rpm 注意:gd-devel-2.0.35-11.el6.x86_64.rpm在DVD2光盤鏡像中,能夠拷貝出來,再掛載DVD1光盤鏡像,完成安裝; 編譯安裝: # tar xf php-5.6.31.tar.gz # cd php-5.6.31 # ./configure --prefix=/usr/local/php56 --enable-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl --enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-libxml-dir=/usr --with-zlib --with-apxs2=/usr/local/apache-2427/bin/apxs --with-config-file-path=/etc/php56.ini --with-config-file-scan-dir=/etc/php56.d --with-gd --with-jpeg-dir --with-png-dir --with-mcrypt # make -j 4 && make install 安裝後操做: 1.提供配置文件: # cp php.ini-production /etc/php56.ini # mkdir /etc/php56.d # cp sapi/fpm/php-fpm.conf /etc/php56.d # vim /etc/php56.d/php-fpm.conf ;;;;;;;;;;;;;;;;;;;; ; Pool Definitions ; ;;;;;;;;;;;;;;;;;;;; [www] user = nobody group = nobody listen = 127.0.0.1:9000 ;listen.backlog = 65535 ;listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 ;pm.max_requests = 500 ;pm.status_path = /fpm-status ;pid = /usr/local/php56/var/run/php-fpm.pid php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php56/session 注意:最後兩條語句須要手動添加至配置文件中;而且要建立出該目錄且受權: # mkdir -pv /var/lib/php56/session # chown nobody. /var/lib/php56/session 2.爲php-fpm服務程序提供一個sysv風格的腳本: # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm # chkconfig --add php-fpm # chkconfig php-fpm on 3.修改服務啓動腳本中的內容: 1) 添加一個變量: scan_confi_dir=/etc/php56.d 2) 修改一個變量定義: php_fpm_CONF=${prefix}/etc/php-fpm.conf 改成: php_fpm_CONF=${scan_conf_dir}/php-fpm.conf 4.啓動php-fpm服務進程 # service php-fpm start 5.檢查php-fpm進程狀態: # service php-fpm status # ss -tnl # netstat -tnl 4、編譯安裝xcache以加速php訪問: 下載xcache的源代碼: http://xcache.lighttpd.net/ 編譯安裝xcache: # tar xf xcache-3.2.0.tar.gz # cd xcache-3.2.0 # /usr/local/php56/bin/phpize //生成configure腳本文件 # ./configure --enable-xcache --with-php-config=/usr/local/php56/bin/php-config # make -j 4 && make install 此步驟結束以後,須要注意xcache.so模塊的安裝路徑; /usr/local/php56/lib/php/extensions/no-debug-zts-20131226/ 爲xcache提供配置文件: # cp xcache.ini /etc/php56.d # vim /etc/php56.d/xcache.ini extension = xcache.so 修改成: extension = /usr/local/php56/lib/php/extensions/no-debug-zts-20131226/xcache.so 重啓php-fpm服務進程: # service php-fpm restart
補充材料:編譯源代碼的方式安裝MariaDB
在RHEL/CentOS上編譯MySQL/MariaDB源端須要用到cmake項目管理工具來實現;
cmake的重要特性之一是其獨立於源碼(out-of-source)的編譯功能,即編譯工做能夠在另外一個指定的目錄中而非源碼目錄中進行,這能夠保證源碼目錄不受任何一次編譯的影響,所以在同一個源碼樹上能夠進行屢次不一樣的編譯,如針對於不一樣平臺編譯。
安裝cmake
跨平臺編譯器
CentOS 6 編譯安裝mariadb-5.5
編譯安裝mariadb-5.5.46
一、使用cmake編譯mariadb-5.5要點:
cmake指定編譯選項的方式不一樣於make,其實現方式對好比下:
./configure cmake .
./configure --help cmake . -LH or ccmake .
指定安裝文件的安裝路徑時經常使用的選項:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/data/mysql
-DSYSCONFDIR=/etc
默認編譯的存儲引擎包括:csv、myisam、myisammrg和heap。若要安裝其它存儲引擎,可使用相似以下編譯選項:
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
若要明確指定不編譯某存儲引擎,可使用相似以下的選項:
-DWITHOUT_<ENGINE>_STORAGE_ENGINE=1
好比:
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
如若要編譯進其它功能,如SSL等,則可以使用相似以下選項來實現編譯時使用某庫或不使用某庫:
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_ZLIB=system
-DWITH_LIBWRAP=0
其它經常使用的選項:
-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_DEBUG=0
-DENABLE_PROFILING=1
若是想清理此前的編譯所生成的文件,則須要使用以下命令:
make clean
rm CMakeCache.txt
二、編譯安裝
# useradd -u 306 -g mysql -r -d /mydata/data mysql # tar xf mariadb-5.5.46.tar.gz # cd mariadb-5.5.46 # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-5.5.46 -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci # make -j # # make install
安裝以後的配置:
# cd /usr/local/mysql # chown -R :mysql . # scripts/mysql_install_db --user=mysql --datadir=/data/mydata # cp support-files/my-large.cnf /etc/my.cnf 修改/etc/my.cnf,在其中添加datadir = /data/mydata (良心建議添加此行) # cp support-files/mysql.server /etc/init.d/mysql # vim /etc/profile.d/mysql.sh export PATH=$PATH:/usr/local/mysql/bin
CentOS 7編譯安裝MariaDB要點:
yum groupinstall "Development Tools" "Server Platform Development" yum install ncurses-devel openssl-devel libevent-devel jemalloc-devel cmake
systemd service unit file
#
[Unit]
Description=MariaDB database server
After=syslog.target
After=network.target
#
[Service]
Type=simple
User=mysql
Group=mysql
#
ExecStart=/usr/local/mysql/bin/mysqld_safe --basedir=/usr/local/mysql
#
TimeoutSec=300
#
PrivateTmp=false
#
[Install]
WantedBy=multi-user.target