國慶假期時間比較充足,就本身試着以源代碼的形式把lamp環境搭建一下,
在整個過程當中出現了很多問題,花了大概差很少一天的時間吧。因爲本身
也是摸索着完成的,因此記錄下來,以便之後參考。php
系統環境:
Redhat6.5 64位
已安裝好gcc編譯器html
因爲是源代碼安裝因此大多數包的安裝過程都是這四個步驟
解壓、configure、make、make install
其中make編譯的過程最爲關鍵,只要在make過程的最後沒有出現error提示,
基本上就是編譯經過了,後面的make install就沒什麼問題了。可是若是
在make的過程當中出現錯誤,就不要執行後面的步驟了,看看錯誤提示是包的
依賴性問題或系統配置等的問題,查找資料找到解決問題的辦法。從新編譯安裝,刪除掉
原來解壓出來的目錄。python
1 安裝libxml依賴包python-devel 2 yum -y install python-devel.x86_64
1 下載libxml2,網址https://distfiles.macports.org/libxml2/ 2 解壓libxml2包 3 tar -zxvf libxml2-2.9.2.tar.gz 4 進入解壓目錄 5 ./configure --prefix=/usr/local/libxml2 6 make 7 make install 8 安裝結束後如圖下圖所示
1 下載Libmcrypt,網址https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/ 2 解壓libmcrypt包 3 tar -zxvf libmcrypt-2.5.8.tar.gz 4 進入目錄 5 ./configure --prefix=/usr/local/libmcrypt 6 make 7 make install 8 如圖libmcrypt1 9 完成後,進入該目錄中的子目錄安裝組件 10 cd libltdl執行 11 ./configure --enable-ltdl-install 12 make 13 make install 14 如圖下圖所示
1 下載mhash,網址https://sourceforge.net/projects/mhash/files/ 2 解壓 tar -zxvf mhash-0.9.9.9.tar.gz 3 進入目錄 4 默認配置就能夠,直接執行 ./configure 5 make 6 make install 7 以下圖所示
1 下載mcrypt,網址https://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/ 2 解壓tar -zxvf mcrypt-2.6.8.tar.gz 3 進入目錄執行命令 4 LD_LIBRARY_PATH=/usr/local/libmcrypt:/usr/local/lib ./configure --with-libcrypt-prefix=/usr/local/libmcrypt 5 make 6 make install 7 如圖下圖所示
1 下載zlib,網址http://zlib.net/fossils/ 2 解壓 tar -zvxf zlib-1.2.10.tar.gz 3 進入目錄執行,默認配置便可 4 CFLAGS="-O3 -fPIC" ./configure (64位安裝,32位直接./configure) 5 make 6 make install 7 安裝完成以下圖所示
1 下載libpng,網址https://sourceforge.net/projects/libpng/files/libpng15/older-releases/1.5.22/ 2 解壓 xz -d libpng-1.5.22.tar.xz 3 在解壓.tar包 tar -xvf libpng-1.5.22.tar 4 進入目錄執行 5 ./configure --prefix=/usr/local/libpng 6 make 7 make install 8 以下圖所示
1 安裝jpeg6,網址http://www.linuxfromscratch.org/blfs/view/6.3/general/libjpeg.html 2 解壓 tar -zxvf jpegsrc.v6b.tar.gz 3 先建立好jpeg6要使用的目錄 4 mkdir /usr/local/jpeg6 5 mkdir /usr/local/jpeg6/bin 6 mkdir /usr/local/jpeg6/lib 7 mkdir /usr/local/jpeg6/include 8 mkdir -p /usr/local/jpeg6/man/man1 9 進入目錄執行 10 ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static 11 make 12 make install
1 安裝freetype,網址http://ftp.twaren.net/Unix/NonGNU/freetype/ 2 解壓 tar -zxvf freetype-2.4.2.tar.gz 3 進入目錄執行 4 ./configure --prefix=/usr/local/freetype 5 make 6 make install 7 如圖下圖所示
1 安裝GD庫,網站https://sourceforge.net/projects/gd2/ 2 解壓 tar -zxvf gd-2.0.35.tar.gz 3 進入目錄,修改文件 4 vim gd_png.c 5 將16行的#include "png.h"改成#include "/usr/local/libpng/include/png.h" 6 保存退出 7 ./configure --prefix=/usr/local/gd2 --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng 8 make 9 make install 10 以下圖所示
1 安裝pcre,支持正則,網址https://sourceforge.net/projects/pcre/ 2 解壓 tar -zxvf pcre2-10.30.tar.gz 3 進入目錄,默認配置便可 4 ./configure 5 make 6 make install 7 以下圖所示
1 安裝apache接口工具apr和apr-util,網址http://apr.apache.org/download.cgi 2 分別解壓apr,apr-util,httpd 3 tar -zxvf apr-1.6.2.tar.gz 4 tar -zxvf apr-util-1.6.0.tar.gz 5 tar -zxvf httpd-2.4.27.tar.gz 6 執行命令 7 cp -r apr-1.6.2 httpd-2.4.27/srclib/apr 8 cp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util 9 進入到httpd的解壓目錄執行 10 ./configure --prefix=/usr/local/apache2/ --sysconfdir=/usr/local/apache2/etc/ 11 --with-included-apr --enable-so --enable-deflate=shared 12 --enable-expires=shared --enable-rewrite=shared 13 14 make 15 make install 16 17 安裝httpd服務器再執行make的過程當中出現報錯以下,錯誤很長,只貼一部分 18 xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’ 19 xml/apr_xml.c:438: error: ‘apr_xml_parser’ has no member named ‘xp’ 20 xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp_err’ 21 xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp’ 22 xml/apr_xml.c: In function ‘apr_xml_parser_geterror’: 23 xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’ 24 xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’ 25 make[1]: * [xml/apr_xml.lo] Error 1 26 make[1]: Leaving directory `/root/Downloads/apache_svn/apr-util-1.6.0' 27 make: * [all-recursive] Error 1 28 29 解決辦法 yum install expat-devel,以後執行make clean,再從新./configure 和make 30 31 如圖所示安裝成功
測試apache是否能正常啓動
/usr/local/apache2/bin/apachectl start
瀏覽器訪問測試如圖所示mysql
1 安裝ncurses,網址https://ftp.gnu.org/gnu/ncurses/ 2 解壓tar -zxvf ncurses-5.9.tar.gz 3 進入目錄執行 4 ./configure --with-shared --without-debug --without-ada --enable-overwrite 5 make 6 make install 7 以下圖所示
1 先使用yum安裝cmake和bison 2 yum -y install cmake bison 3 4 安裝mysql 5 先添加mysql用戶 6 groupadd mysql 7 useradd -g mysql mysql 8 下載http://mirrors.sohu.com/mysql/MySQL-5.5/ 9 解壓tar -zxvf mysql-5.5.54.tar.gz 10 進入目錄執行 11 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 12 -DEXTAR_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 13 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 14 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 15 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 16 17 make 18 make install 19 啓動mysql的過程當中遇到錯誤FATAL ERROR: Could not find ./bin/my_print_defaults 20 解決辦法是啓動mysql多加兩個選項 21 /usr/local/mysql/scripts/mysql_install_db --user=mysql 22 --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 23 24 鏈接mysql服務器如圖所示
1 安裝php,網站http://www.linuxfromscratch.org/blfs/view/svn/general/php.html 2 解壓tar -xvf php-7.1.9.tar 3 進入目錄執行 4 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ 5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ 6 --with-libxml-dir=/usr/local/libxml2/ --with-freetype-dir=/usr/local/freetype/ 7 --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config 8 --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-mysql=/usr/local/mysql/ 9 --without-pear 10 11 make 12 make install 13 如圖所示
1 將php做爲一個模塊加入到apache中,編輯httpd.conf 2 vim /usr/local/apache2/etc/httpd.conf 3 添加下面一行代碼讓apache可以找到php 4 AddHandler application/x-httpd-php .php 5 6 重啓apache 7 /usr/local/apache2/bin/apachectl restart 8 9 在apache中的htdocs中建立文件index.php,添加代碼以下所示 10 <?php 11 phpinfo(); 12 13 瀏覽器訪問測試以下圖所示