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,显示以下内容。
![](https://i-blog.csdnimg.cn/blog_migrate/debaef86784cd140af084f7f63e7d595.jpeg)
这样php就安装成功了。
转载于:https://blog.51cto.com/research/828361