Apache2.4.6、php5.4.16源码安装

################################Apache2.4.6安装#################################

1.从各个资源获取httpd-2.4.6.tar.gz源码包并解压到当前目录

tar -zxvf httpd-2.4.18.tar.gz

2.从官网http://mirror.bit.edu.cn/apache/apr/获取apr、apr-util源码包、安装这两个库( APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。)

http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz

yum install zlib-devel pcre-devel pcre expat-devel  openssl-devel   libxml2-devel

tar -zxvf apr-1.5.2.tar.gz

cd apr-1.5.2

./configure --prefix=/usr/local/apr/   

###如果报错rm: cannot remove 'libtoolT': No such file or directory

方法1:编辑 configure文件,查找 $RM "$cfgfile" 这个地方,用#注释掉

方法2:在configure里面把RM='$RM'改为RM='$RM  -f' ,这里的$RM后面一定要有一个空格。

tar -zxvf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/

make && make install

3. 对Apache进行安装配置,可以使用./configure --help 查看可以加载哪些配置

./configure --prefix=/usr/local/apache \     #配置文件目录

--with-included-apr \

--with-apr=/usr/local/apr/ \

--with-apr-util=/usr/local/apr-util/ \

--with-pcre \     #支持perl的正则表达式

--enable-so \     #启用动态模块加载

--enable-ssl \     #基于ssl加密传输

--enable-cgi \     #开启CGI脚本

--enable-rewrite \      #允许URL重写

--with-zlib \     #支持压缩

--enable-deflate \      #支持网页压缩

--enable-expires \      #支持网页缓存

--enable-headers \     #提供允许对HTTP请求头的控制

--enable-modules=most \      #支持大多数模块

--enable-mime-magic  \        # 检查文件开始的几个字节,来判定文件的MIME类型

--enable-mpms-shared=all \      #mpm工作模块(prefork、worker、event)的动态切换,编译为三种都支持,通过修改配置来更换

--with-mpm=prefork \      #默认加载使用的mpm( 多进程处理模块

#以上是生产环境中常用的一些编译参数,根据实际情况选择要加载的模块

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-mine-magic --enable-mpms-shared=all

make && make install

4.修改配置文件vim /usr/local/apache/conf/httpd.conf 找到ServerName 这一行,将前面的#去掉,名修改其值为0.0.0.0:80或者为自己主机的ip或者localhost

5.启动服务 

/usr/local/apache/bin/apachectl start

httpd (pid 92569) already running

6.将apache添加到系统服务 

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

需要修改启动脚本

在行首添加以下内容(参考/etc/init.d/network):

# chkconfig: 2345 10 90

# description: Activates/Deactivates all network interfaces configured to \

#              start at boot time.

cd /etc/init.d/

chkconfig --add httpd      #将apache添加到系统服务

chkconfig httpd on      #设置开机自启动

chkconfig --list     #查看开机自启列表

7.vim /usr/local/apache/conf/httpd.conf打开访问监控

<Location /status>

        SetHandler server-status

</Location>

ExtendedStatus On

<Location /info>

        SetHandler server-info

</Location>

8.该网页的默认目录是在/usr/local/apache/htdocs/,新建一个默认页面inde.html,去浏览器输入127.0.0.1,或者可以显示apache自带的网页It works。apache到此就安装OK了。

##################################php5.4.16源码安装####################################

1.安装依赖包

yum -y install glibc gcc perl pkgconfig curl-devel gd-devel libXpm-devel zlib-devel readline-devel libxml2-devel

2.解压php5.4.16源码包

tar -xf php5.4.16

cd php5.4.16

./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache/bin/apxs --enable-fd-setsize=65535 --enable-fpm --disable-ipv6 --without-sqlite3 --without-pdo-sqlite --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop --enable-mbstring --enable-zip --enable-bcmath --enable-ftp --enable-soap --with-mhash --with-pcre-regex --with-pcre-dir --with-readline --with-zlib --with-curl --with-openssl --with-iconv --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-xpm-dir --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

如果报错:configure: error: libXpm.(a|so) not found.  // configure一般的搜索编译路径为/usr/lib/下,且php默认就在/usr/lib/下找相关库文件

执行:ln -s /usr/lib64/libXpm.so*  /usr/lib/*

3.make && make install

4. cp /root/php-5.4.16/php.ini-development /usr/local/php/lib/php.ini  

5.apache 支持php,修改httpd.conf文件添加以下内容

<FilesMatch \.php$>

    SetHandler application/x-httpd-php

</FilesMatch>

找到    AddType application/x-compress .Z

           AddType application/x-gzip .gz .tgz

在下面添加

    AddType application/x-httpd-php .php .php5

    AddType application/x-httpd-php-source .php

6. 新建网页验证配置

cat >>/usr/local/apache/htdocs/info.php <<EOF
        <?PHP
          phpinfo();
        ?>

猜你喜欢

转载自blog.csdn.net/qq_36586867/article/details/81501748