linux內核:
#uname -r
2.6.32-220.el6.x86_64
2.6.32-220.el6.x86_64
更新linux軟件
#yum update
下載安裝軟件:
httpd-2.4.1.tar.gz
php-5.4.0.tar.gz
openssl-1.0.1.tar.gz
apr-1.4.6.tar.gz
apr-util-1.4.1.tar.gz
apr-util-1.4.1.tar.gz
pcre-8.01.tar.gz
libmcrypt-2.5.8.tar.bz2
如果想安裝最新請到官網下載;
開始安
安裝編譯器
#yum -y install *gcc* *make*
1.安裝openssl
#tar -zxvf openssl-1.0.1.tar.gz
#cd openssl-1.0.1
#./config --prefix=/usr/local/openssl
#make && make install
2.安裝apache
#tar -zxvf apr-1.4.6.tar.gz
#cd apr-1.4.6
#cd apr-1.4.6
#./configure --prefix=/usr/local/apr
#make && make install
#tar -zxvf apr-util-1.4.1.tar.gz
#cd apr-util-1.4.1
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make && make install
#tar -zxvf pcre-8.01.tar.gz
#cd pcre-8.01/
#./configure --prefix=/usr/local/pcre
#make && make install
#tar -zxvf httpd-2.4.1.tar.gz
#cd httpd-2.4.1
# ./configure \
--prefix=/usr/local/apache2 \
--enable-rewrite \
--enable-so \
--enable-auth-digest \
--enable-cgi \
--with-ssl=/usr/local/openssl/ssl \
--enable-suexec \
--with-suexec-caller=daemon \
--with-suexec-docroot=/usr/local/apache2/htdocs \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
#make && make install
配置apache
#pwd
/usr/local/apache2/bin
/usr/local/apache2/bin
# vim apachectl //添加一下內容
#chkconfig: 35 85 15
#description Apache server 2.4
#description Apache server 2.4
#cp apachectl /etc/init.d/apache
#chmod o+x /etc/init.d/apache
#chkconfig --add apache
#chkconfig apache on
#service apache start
出現一下提示:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using server1.gnway.net. Set the 'ServerName' directive globally to suppress this message
在apache主配置裏面添加一下內容
#vim /usr/local/apache2/conf/httpd.conf
找到:#ServerName www.example.com:80
把“#”去掉,並且把 www.example.com:80改成你要發佈的域名或者是計算機名稱,如果做測試的話可以不用改。
#pkill -9 http
#service apache start
查看apache是否安裝成功:
#ps -e | grep http
24693 ? 00:00:00 httpd
24694 ? 00:00:00 httpd
24695 ? 00:00:00 httpd
24696 ? 00:00:00 httpd
24693 ? 00:00:00 httpd
24694 ? 00:00:00 httpd
24695 ? 00:00:00 httpd
24696 ? 00:00:00 httpd
看到這個說明安裝成功,或者在本地的瀏覽器中輸入:localhost
提示:It works!說明安裝成功
3.安裝php
讓php支持相應的插件
#yum -y install *libxml-devel libxml2* cgi* libpng* libjpeg* libxml2* mcrypt *-gd-* libcurl-devel freetype-devel gettext libtool-* openssl-devel
# tar -jxvf libmcrypt-2.5.8.tar.bz2
#cd libmcrypt-2.5.8/
#./configure --prefix=/usr/local/libmcrypt
#make && make install
#tar -zxvf php-5.4.0.tar.gz
#cd php-5.4.0.tar.gz
# ./configure --prefix=/usr/local/php5.4 \
--enable-mbstring \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php5.4 \
--without-pear \
--with-openssl \
--with-mcrypt \
--enable-mbstring \
--with-freetype-dir \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir \
--with-gettext \
--with-zlib-dir \
-with-zlib \
--with-curl \
--enable-ftp \
--with-libxml-dir \
--with-openssl= \
--with-config-file-scan-dir=/usr/local/php5.4 \
--enable-embedded-mysqli \
--with-mysql --with-mysql-sock \
--with-mysqli \
--with-pdo-mysql \
--enable-mysqlnd \
#make //這一步可能會出現一下錯誤:原因是用源碼的openssl編譯就會出現這個問題,現在還沒解決。用rpm包的openssl就不會出現這個問題
.....................
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
#make install
開啓apache模塊,讓apache支持php
在apache主配置文件內添加以下內容:
#vim /usr/local/apache2/conf/httpd.conf
......................
LoadModule php5_module modules/libphp5.so //已有的
AddType application/x-httpd-php .php //後添加的
AddType application/x-httpd-php .php //後添加的
........................
<IfModule dir_module>
DirectoryIndex index.php index.html //添加php默認文件
DirectoryIndex index.php index.html //添加php默認文件
</IfModule>
........................
在/usr/local/apache2/htdocs/下創建一個測試文件,並且 重啓apache服務器。
#vim /usr/local/apache2/htdocs/test.php
<?php
phpinfo();
?>
在本地瀏覽器中輸入:localhost/test.php,顯示以下內容。
這樣php就安裝成功了。