Linux下安装Apache 2.4

来源:互联网 发布:知乎 zun的地位 编辑:程序博客网 时间:2024/06/05 04:27

本文原创,欢迎转载。转载请在文章明显可见处张贴如下内容:(注意:请保留超链接格式)

本文为Rainisic原创,欢迎转载,转载请在文章明显可见处张贴原帖信息:

http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html

下载Apache 2.4及依赖包

Apache官网下载:http://httpd.apache.org/download.cgi

由于Apache依赖于APR、APR-Util和PCRE,所以需要下载:

APR + APR-Util:http://apr.apache.org/download.cgi

PCRE:http://sourceforge.net/projects/pcre/files/pcre/

在此,笔者使用均为目前最新版本,Apache 1.4.6,APR 1.4.1,APR-Util 2.4.1,Perl 5.14.2,PCRE 8.30

安装依赖

APR及APR-Util安装

解压缩APR及APR-Util

shell> sudo tar zxvf apr-1.4.6.tar.gz -C /opt/sourcesshell> sudo tar zxvf apr-util-1.4.1.tar.gz -C /opt/sources

创建安装目录并创建软链接

shell> sudo mkdir /opt/software/develop/apr-1.4.6shell> sudo mkdir /opt/software/develop/apr-util-1.4.1shell> sudo ln -s /opt/software/develop/apr-1.4.6 /usr/local/aprshell> sudo ln -s /opt/software/develop/apr-util-1.4.1 /usr/local/apr-util

安装APR及APR-Util

复制代码
shell> cd /opt/sources/apr-1.4.6shell> sudo ./configure --prefix=/usr/local/aprshell> sudo makeshell> sudo make installshell> cd /opt/sources/apr-util-1.4.1shell> sudo ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprshell> sudo makeshell> sudo make install
复制代码

安装PCRE

首先请确定系统安装了Perl,Perl在此不再赘述,如有需要请去官网查看安装细则:http://www.cpan.org/src/README.html

解压缩PCRE

shell> sudo tar zxvf pcre-8.30.tar.gz -C /opt/sources

创建PCRE安装目录及软链接

shell> sudo mkdir /opt/software/develop/pcre-8.30shell> sudo ln -s /opt/software/develop/pcre-8.30 /usr/local/pcre

安装PCRE

shell> cd /opt/sources/pcre-8.30shell> sudo ./configure --prefix=/usr/local/pcreshell> sudo makeshell> sudo make install

安装Apache 2.4

解压缩Apache 2.4

shell> sudo tar zxvf httpd-2.4.2.tar.gz -C /opt/sources

创建Apache安装目录及软链接

shell> sudo mkdir /opt/software/develop/httpd-2.4.2shell> sudo ln -s /opt/software/develop/httpd-2.4.2 /usr/local/apache2

安装Apache

复制代码
shell> cd /opt/sources/httpd-2.4.2# 此处请根据自己要搭建的环境进行配置,我这里是为了配置PHP环境shell> sudo ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite=shared --with-mpm=prefork --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcreshell> sudo makeshell> sudo make install
复制代码

启动Apache

通过apachectl启动Apach

shell> sudo /usr/local/apache2/bin/apachectl start

检查是否有Apache进程

shell> ps aux | grep httpd

如果有Apache的进程,则证明启动成功,浏览器地址栏输入 http://localhost 试试吧~

启动成功之后,可以将apachectl拷贝到/etc/init.d下,作为service启动。

shell> sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/httpdshell> sudo service httpd start

扩展阅读

  • Apache官方安装文档:http://httpd.apache.org/docs/2.4/install.html
  • Apache 2.4下 PHP 5.4.3 的安装:尚未写完~稍等下
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 手机电路板坏了怎么办 iqos主板坏了怎么办 电脑开关没反应怎么办 电子邮件密码忘了怎么办 微信被限制进群怎么办 电子邮箱密码忘了怎么办 qq邮件收不到怎么办 电子邮件密码忘记了怎么办 孩子一烧就39度怎么办 qq邮箱找不到了怎么办 忘记网易邮箱账号怎么办 企业微信用不了怎么办 qq邮箱密码被盗怎么办 企业邮箱密码忘了怎么办 icloud登入不了怎么办 qq邮件加载失败怎么办 收货数量少了怎么办 邮箱附件过期了怎么办 邮箱附件已过期怎么办 163邮箱附件过大怎么办 126邮箱内容过期怎么办 授权码忘记了怎么办 163邮箱忘记账号怎么办 126邮箱忘记账号怎么办 忘记qq登录密码怎么办 崩坏3死邮怎么办 崩坏3死邮箱怎么办 手机邮箱文件打不开怎么办 户口注销后房产怎么办 公司注销后车辆怎么办 注销后的手机号怎么办 网易邮箱修复失败怎么办 网易邮箱忘记密码怎么办 苹果忘记安全问题答案怎么办 手机被黑客盯上怎么办 qq邮箱被占用怎么办 淘宝邮箱被占用怎么办 LOL出现上载错误怎么办 本科论文格式有些错误怎么办 下载的压缩包打不开怎么办 下载好qq该怎么办