LAMP小试牛刀
本人剛接觸運維不久,水平有限,以下博文為記錄自己LAMP的安裝編譯過程,以及出現的問題、解決方法。若有問題,還望大俠們指出,不勝感激!
系統平臺為CentOS5.6
1.所需要包
httpd-2.2.19.tar.gz?
mysql-5.1.58-linux-i686-glibc23.tar.gz?
php-5.3.6.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.12.tar.gz
freetype-2.2.1.tar.gz
gd-2.0.35.tar.gz
安裝前需要檢查是否有Gcc編譯器 ,libxml2編譯php時需要
2 安裝apache
找到軟件包/tmp/downsoft/
解壓縮 tar zxvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
開始編譯apache
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-expires --enable-cache --enable-mem-cache
--prefix是按照目錄。enable后面模塊選項。這里選擇一些常用的模塊,so是支持動態鏈接機制上加載DSO模塊。后面裝PHP時就會創建一個so的php模塊。rewrite就是常用到的重寫。expires是控制HTTP的"Expires:"和"Cache-Control:"頭內容,PHP用header控制緩存時要用到
編譯好后,開始安裝 make && make install
安裝完成后我們啟動apache
/usr/local/httpd/bin/apachectl -k start 也可以通過 stop 或者 restart 停止或重啟apache
3 安裝Mysql
這里用的是5.1.58免編譯版的
解壓Mysql??? tar zxvf mysql-5.1.58-linux-i686-glibc23.tar.gz
做鏈接 ln -s? /tmp/Softdownload/mysql-5.1.58-linux-i686-glibc23 /usr/local/mysql?? 這里是絕對路徑
創建Mysql用戶?
groupadd mysql
useradd -g mysql mysql
修改目錄權限
chown -R mysql.mysql /usr/local/mysql/
數據庫初始化:
scripts/mysql_install_db --user=mysql
將下面兩個文件復制到相應位置
cd /usr/local/mysql
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
啟動Mysql
bin/mysqld_safe &
測試 bin/mysql?
mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| mysql????????????? |
| test?????????????? |
+--------------------+
3 rows in set (0.01 sec)
正常
4 安裝PHP
1)編譯安裝jpeg6
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man
mkdir -p /usr/local/jpeg6/man1
mkdir -p /usr/local/jpeg6/man/man1
jpeg6編譯時不會創建目錄,因此需要手動添加
tar zxvf jpegsrc.v6b.tar.gz 解壓
cd jpeg-6b/ 編譯
./configure --prefix=/usr/local/jpeg --enable-shared --enable=static
編譯時出現如下問題
[root@bogon jpeg-6b]# make; make install
./libtool --mode=compile gcc -O2? -I. -c ./jcapimin.c
make: ./libtool:命令未找到
make: *** [jcapimin.lo] 錯誤 127
解決方法
首先看有沒有安裝libtool 及 libtool-ltdl-devel
rpm?? -qa | grep?? libtool
然后進入jpeg-6b的源碼目錄,然后執行以下步驟,切記!COPY到當前目錄注意后面的點(.)
cp?? /usr/share/libtool/config.sub? .
cp?? /usr/share/libtool/config.guess? .
也就是把 libtool里面的兩個配置文件拿來覆蓋掉jpeg-6b目錄下的對應文件
make clean 再重新configure
沒有權限的時候先建立對應的文件夾,再次make install就行了
又出現問題:
/usr/bin/install: cannot create regular file `/usr/local/jpeg/include/jconfig.h': No such file or directory
make: *** [install-headers] Error 1
重新創建目錄
mkdir -p /usr/local/jpeg/include? 問題解決
2)編譯安裝libpng
tar zxvf libpng-1.2.12.tar.gz
cd libpng-1.2.12
./configure
make && make install
3)編譯freetype
tar zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
./configure --prefix=/usr/local/freetype
4)編譯GD庫
tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/? --with-freetype=/usr/local/freetype/
make && make install
5)安裝編譯PHP
解壓 tar zxvf php-5.3.6.tar.gz
cd php-5.3.6
開始編譯
[root@localhost php-5.3.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs?? --with-mysql-dir=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-png --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-freetype-dir=/usr/local/freetype/
--prefix是安裝目錄。--with-config-file-path是指定php配置文檔php.ini所在的目錄。--with-mysql,安裝mysql擴展。--with-zlib安裝zlib擴展,前提是linux已經安裝了zlib,未安裝可以去掉這個選項。 安裝mbstring和xml擴展。這些都是常用的模塊。
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore.
編譯時出現這個問題,剛開始被誤導了,這樣做,沒解決問題,出現另一個錯誤
configure: error: mysql configure failed. Please check config.log for more information.
最后,找到解決方法,實際上是--with-mysql選項有誤,應該為--with-config-dir=/usr/local/mysql
OK
configure fails with:
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
configure: error: Cannot find libmysqlclient under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
解決方法:
This fixes the problem:
cd /usr/local/mysql
ln -s lib lib64
?
復制php.ini文件
cp php.ini-production /usr/local/lib
重命名 mv php.ini-production php.ini
php編譯完成
5配置apache與PHP的關聯
編輯文件:vi /var/www/html/test.php
<?php
phpinfo();
?>
在瀏覽器中打開 http://localhost/test.php 可以看到安裝的PHP的一些信息,及其他服務的相應模塊
?
轉載于:https://blog.51cto.com/joe011/661811
總結
- 上一篇: wow64简介
- 下一篇: C机顶盒开发实战常用初始化类型:数组、结