我在centos6.5 32位上操作
下載
[root@localhost]# cd /usr/local/src
[root@localhost src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
[root@localhost src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.28.tar.gz
apache安裝
解壓
[root@localhost src]# tar -zxvf httpd-2.2.31.tar.gz
[root@localhost src]# cd httpd-2.2.31
配置編譯參數
[root@localhost httpd-2.2.31]# ./configure \ --prefix=/usr/local/apache2 \ --with-included-apr \ --enable-so \ --enable-deflate=shared \ --enable-expires=shared \ --enable-rewrite=shared \ --with-pcre
報錯
error: mod_deflate has been requested but can not be built due to prerequisite failures
解決辦法:
#yum install -y zlib-devel
編譯
[root@localhost httpd-2.2.31]# make
注:報錯都是缺少庫文件,用yum list搜索對應的包,還有一個yum whatprovides
安裝
[root@localhost httpd-2.2.31]# make install
啓動:
#/usr/local/apache2/bin/apachectl start
啓動報錯:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
解決方法:
#vim /usr/local/apache2/conf/httpd.conf
ServerName www.example.com:80
改爲 ServerName localhost:80
重啓無報錯
#/usr/local/apache2/bin/apachectl restart
mysql安裝
解壓
# tar -zxvf /usr/local/src/mysql-5.1.73-linux-i686-glibc23 .tar.gz
挪動位置
# mv mysql-5.1.73-linux-i686-glibc23 .tar.gz /usr/local/mysql
創建mysql用戶
# useradd -s /sbin/nologin mysql
# cd /usr/local/mysql
創建datadir,數據庫文件存放位置
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql
# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
注:如果看到2個OK,表示執行正確。
配置mysql
拷貝配置文件
[root@ly-linux mysql]# cp support-files/my-large.cnf /etc/my.cnf
cp:是否覆蓋"/etc/my.cnf"? y
拷貝啓動腳本,並修改其屬性
[root@ly-linux mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@ly-linux mysql]# chmod 755 /etc/init.d/mysqld
修改啓動腳本
[root@ly-linux mysql]# vi /etc/init.d/mysqld
注:需要修改的地方
basedir=/usr/local/mysql
datadir=/data/mysql
把啓動腳本加入系統服務項,設定開機啓動
[root@ly-linux mysql]# chkconfig --add mysqld
[root@ly-linux mysql]# chkconfig mysqld on
[root@ly-linux mysql]# service mysqld start
Starting MySQL.. SUCCESS!
注:如果啓動不了,查看錯誤日誌。
php安裝
解壓,進入php目錄
[root@localhost php-5.3.27]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
報錯:
configure: error: xml2-config not found. Please check your libxml2 installation.
解決辦法:
yum install -y libxml2-devel
報錯;
configure: error: Cannot find OpenSSL's <evp.h>
解決辦法:
yum install -y openssl openssl-devel
報錯:
checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution
解決辦法:
yum install -y bzip2 bzip2-devel
報錯:
configure: error: png.h not found.
解決辦法:
yum install -y libpng libpng-devel
報錯:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
編譯make:
[root@ly-linux php-5.6.28]# make
報錯:
make: 警告:檢測到時鐘錯誤。您的創建可能是不完整的。
原因:編譯過程中時間比系統時間更靠後
解決:修改時間
安裝:
[root@ly-linux php-5.6.28]# make install
以上安裝過程完成,但是php安裝完成後,並不能直接使用,需要進行一些配置