這個系統吧比較純淨,APT包管理至關舒服比yum 還舒服!php
root@houzaicun:/home# apt-get install lrzsz #我用的XSHELL 工具 爲了方便直接扔包!html
一首先就apache吧mysql
安裝編譯\工程構建\調試工具
//*
* 說明:
* build-essential: 基本編譯環境 (gcc, g++, libc, make等)
* autoconf: 自動配置工具
* automake: make相關
* gdb: 調試工具
*//
#apt-get install build-essential
#apt-get install autoconf
#apt-get install automake
#apt-get install gdb sql
#個人包都放在了 /home 下
root@houzaicun:/home# apt-get install build-essential #只安裝他就能夠了!apache
root@houzaicun:/home# apt-get install make 安裝make 工具 爲何我說他純淨了。ubuntu
root@houzaicun:/home# tar -zxvf httpd-2.2.21.tar.gz vim
root@houzaicun:/home# cd httpd-2.2.21/app
root@houzaicun:/home/httpd-2.2.21# cd srclib/aprsocket
root@houzaicun:/home/httpd-2.2.21/srclib/apr# ./configure --prefix=/usr/local/apride
root@houzaicun:/home/httpd-2.2.21/srclib/apr# make
root@houzaicun:/home/httpd-2.2.21/srclib/apr# make install
root@houzaicun:/home/httpd-2.2.21/srclib/apr# cd ../apr-util/
root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# make
root@houzaicun:/home/httpd-2.2.21/srclib/apr-util# make install
root@houzaicun:/home/httpd-2.2.21# cd ../../
root@houzaicun:/home/httpd-2.2.21# ./configure --prefix=/usr/local/apache-2.2.21 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-rewrite
出現configure: error: APR version 1.2.0 or later is required錯誤
解決方法 添加一個參數便可:./configure --prefix=/usr/local/apache-2.2.21 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-rewrite --with-included-apr
系統默認有apr庫了!
root@houzaicun:/home/httpd-2.2.21# make
root@houzaicun:/home/httpd-2.2.21# make install
root@houzaicun:/home/httpd-2.2.21# /usr/local/apache-2.2.21/bin/apachectl start #啓動
root@houzaicun:/home/httpd-2.2.21# ps -aux |grep httpd # 查看進程
二mysql安裝
安裝cmake(mysql5.5之後是經過cmake來編譯的)
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.5.tar.gz
# cd cmake-2.8.5
#.configure
# make && make install
root@houzaicun:/home/httpd-2.2.21# cd /home/
root@houzaicun:/home# tar -zxvf mysql-5.5.15.tar.gz
root@houzaicun:/home/mysql-5.5.15# cd mysql-5.5.15/
root@houzaicun:/home/mysql-5.5.15#apt-get install libncurses5-dev
root@houzaicun:/home/mysql-5.5.15# groupadd -r mysql
root@houzaicun:/home/mysql-5.5.15#useradd -r -M -s /usr/sbin/nologin -g mysql mysql
root@houzaicun:/home/mysql-5.5.15# mkdir -p /data
root@houzaicun:/home/mysql-5.5.15# mkdir -p /usr/local/mysql
root@houzaicun:/home/mysql-5.5.15# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_DEBUG=0
root@houzaicun:/home/mysql-5.5.15# make
root@houzaicun:/home/mysql-5.5.15# make install
具體能夠參考http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
這是mysql開發者寫的一個autools轉換島對應的cmake的各類編譯參數的對比資料。
會遇到的問題:
----------------------------------------------------------
-- MySQL 5.5.15
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu , package name is libncurses5-dev,on RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:256 (MYSQL_CHECK_READLINE)
----------------------------------------------------------
如回顯所示,ubuntu下安裝libncurses5-dev;redhat下安裝ncurses-devel,並刪除當前目錄CMakeCache.txt(必須刪除,不然報錯依舊)並從新運行:
root@houzaicun:/home/mysql-5.5.15# apt-get install libncurses5-dev
root@houzaicun:/home/mysql-5.5.15# rm -rf CMakeCache.txt
從新cmake .
命令
----------------------------------------------------------
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql-5.5.15
----------------------------------------------------------
一個警告總算不爽,如回顯所見,安裝bison。
root@houzaicun:/home/mysql-5.5.15# apt-get install bison
----------------------------------------------------------
這是兩個比較多的問題。
root@houzaicun:/home/mysql-5.5.15# cp support-files/my-medium.cnf /etc/my.cnf
root@houzaicun:/home/mysql-5.5.15# cd /usr/local/mysql/scripts
root@houzaicun:/usr/local/mysql/scripts# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data --no-defaults
修改my.cnf文件
1 [mysqld]
2 basedir=/usr/local/mysql
3 datadir=/data
4 user=mysql
root@houzaicun:/usr/local/mysql/scripts# chown mysql:root -R /usr/local/mysql/
root@houzaicun:/usr/local/mysql/scripts# chown -R mysql:mysql /data/
root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysqld_safe &
root@houzaicun:/usr/local/mysql/scripts# ps -axu |grep mysql 查看啓動是否成功
root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysqladmin -u root password "youpassword"
root@houzaicun:/usr/local/mysql/scripts# /usr/local/mysql/bin/mysql -u root -pyoupassword
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
mysql> exit;
這樣mysql服務就裝完了。
3、php安裝
咱們須要裝GD 庫。
root@houzaicun:/usr/local/mysql/scripts# cd /home
root@houzaicun:/home# tar -zxvf freetype-2.4.3.tar.gz
root@houzaicun:/home# cd freetype-2.4.3/
root@houzaicun:/home/freetype-2.4.3# ./configure --prefix=/usr/local/freetype-2.4.3
root@houzaicun:/home/freetype-2.4.3# make
root@houzaicun:/home/freetype-2.4.3# make install
root@houzaicun:/home/freetype-2.4.3# cd ..
root@houzaicun:/home# tar -zxvf libpng-1.4.4.tar.gz
root@houzaicun:/home/libpng-1.4.4# apt-get install zlib1g-dev
root@houzaicun:/home/libpng-1.4.4# cd libpng-1.4.4/
root@houzaicun:/home/libpng-1.4.4# ./configure --prefix=/usr/local/libpng-1.4.4
root@houzaicun:/home/libpng-1.4.4# make
root@houzaicun:/home/libpng-1.4.4# make install
root@houzaicun:/home/libpng-1.4.4#cd ..
root@houzaicun:/home/libpng-1.4.4# tar -zxvf jpegsrc.v8b.tar.gz
root@houzaicun:/home/libpng-1.4.4# cd /jpeg-8b/
root@houzaicun:/home/libpng-1.4.4# ./configure --prefix=/usr/local/jpeg-8b
root@houzaicun:/home/libpng-1.4.4# make
root@houzaicun:/home/libpng-1.4.4# make install
root@houzaicun:/home/libpng-1.4.4#cd ..
root@houzaicun:/home/#tar -zxvf gd-2.0.33.tar.gz
root@houzaicun:/home# cd gd-2.0.33
root@houzaicun:/home# ./configure --prefix=/usr/local/gd-2.0.33 --with-jpeg=/usr/local/jpeg-8b --with-freetype=/usr/local/freetype-2.4.3 --with-png=/usr/local/libpng-1.4.4/ --with-zlib --enable-m4_pattern_allow
root@houzaicun:/home# make
root@houzaicun:/home# make install
make[2]: *** [gd_png.lo] 錯誤 1
make[2]: Leaving directory `/usr/local/src/gd-2.0.33'
make[1]: *** [all-recursive] 錯誤 1
make[1]: Leaving directory `/usr/local/src/gd-2.0.33'
make: *** [all] 錯誤 2
解決辦法
vi gd_png.c
15行找到「png.h」改爲「/usr/local/libpng-1.4.4/include/png.h」
root@houzaicun:/home/gd-2.0.33# cd ..
root@houzaicun:/home/gd-2.0.33# tar -zxvf php-5.3.8.tar.gz
root@houzaicun:/home# cd php-5.3.8/
root@houzaicun:/home/php-5.3.8# apt-get install libxml2-dev
root@houzaicun:/home/php-5.3.8# ./configure --prefix=/usr/local/php-5.3.8 --with-apxs2=/usr/local/apache-2.2.21/bin/apxs --with-zlib --with-libxml-dir --enable-gd-native-ttf --enable-mbstring --with-gd=/usr/local/gd-2.0.33/ --with-mysql=/usr/local/mysql --with-freetype-dir=/usr/local/freetype-2.4.3 --with-jpeg-dir=/usr/local/jpeg-8b/ --with-png-dir=/usr/local/libpng-1.4.4/ --enable-sockets
root@houzaicun:/home/php-5.3.8# make && make install
cp php.ini-development /usr/local/php-5.3.8/lib/php.ini
在APACHE 整合PHP
vim /usr/local/apache-2.2.21/conf/httpd.conf
53 LoadModule php5_module modules/libphp5.so
54 AddType application/x-httpd-php .php
106 DocumentRoot "/www"
133 <Directory "/www">
167 <IfModule dir_module>
168 DirectoryIndex index.html index.php
169 </IfModule>
root@houzaicun:/home/php-5.3.8#mkdir /www
root@houzaicun:/home/php-5.3.8#cat /www/info.php
<?PHP
phpinfo();
?>
重啓apche
root@houzaicun:/www# /usr/local/apache-2.2.21/bin/apachectl -t 測試配置文件是否正確
Syntax OK
root@houzaicun:/www# /usr/local/apache-2.2.21/bin/apachectl restart
優化下 apache
vim /usr/local/apache-2.2.21/conf/httpd.conf
378 Include conf/extra/httpd-mpm.conf
root@houzaicun:/www# vim /usr/local/apache-2.2.21/conf/extra/httpd-mpm.conf
ServerLimit 20000 # 鏈接數
StartServers 20 #啓動進程數值
MinSpareServers 20 # 空閒最小線程數
MaxSpareServers 50 #空閒最大線程數
MaxClients 1000 #最大線程數
MaxRequestsPerChild 10000
//每一個子進程在其生存期內容許伺服的最大請求數量,默認爲10000.到達MaxRequestsPerChild的限制後,子進程將會結束。假如MaxRequestsPerChild爲"0",子進程將永遠不會結束。
開啓啓動設置:寫到/etc/rc.local 裏面
/usr/local/apache-2.2.21/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe &
exit 0