linux 服务器部署 lnamp 二apache安装

来源:互联网 发布:构建高性能java服务器 编辑:程序博客网 时间:2024/06/07 17:03

一、yum安装

yum -y install httpd

二、编译安装

官方教程:http://httpd.apache.org/docs/2.4/install.html


1.下载

wget http://apache.fayea.com//httpd/httpd-2.4.27.tar.gztar xvzf httpd-2.4.25.tar.gzcd httpd-2.4.25

2../configure 报错

checking for APR... noconfigure: error: APR not found.  Please read the documentation.需要安装三个依赖库:pcre,apr,apr-util
3.安装pcre  perl的正则库
wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gztar xvzf pcre-8.40.tar.gzcd pcre-8.40./configure --prefix=/usr/local/pcremake make install如果报错:configure: error: You need a C++ compiler for C++ support.还需要安装gcc –c++yum install -y gcc gcc-c++
4.安装apr/apr-util有两种方式:
a:各自编译,然后http编译时参数适用wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gztar xvzf apr-1.5.2.tar.gzcd apr-1.5.2./configure –prefix=/usr/local/apr报错:rm: cannot remove 'libtoolT': No such file or directoryvim configure文件,查找30206行, $RM "$cfgfile" 这个地方,用#注释掉继续./configure –prefix=/usr/localmakemake installwget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gztar xzvf apr-util-1.5.4.tar.gzcd apr-util-1.5.4./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-configmake make install对应http编译配置./configure --prefix=/lnamp/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcremakemake install
b.将代码拷贝至http源码目录wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.2.tar.gztar xvzf apr-1.5.2.tar.gzmv apr-1.5.2 aprwget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gztar xzvf apr-util-1.5.4.tar.gzmv apr-util-1.5.4 apr-utilmv apr apr-util /lnamp/src/httpd-2.4.25/srclib/

5.编译(使用将apr和apr-util拷至Apache内部方法,
–-with-included-apr,是指使用上面b方法
./configure –-prefix=/lnamp/apache2 –-with-pcre=/usr/local/pcre/bin/pcre-config –-with-included-aprmakemake install
报错:xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory #include <expat.h>                   ^compilation terminated.make[3]: *** [xml/apr_xml.lo] Error 1make[3]: Leaving directory `/opt/src/httpd-2.4.27/srclib/apr-util'make[2]: *** [all-recursive] Error 1make[2]: Leaving directory `/opt/src/httpd-2.4.27/srclib/apr-util'make[1]: *** [all-recursive] Error 1make[1]: Leaving directory `/opt/src/httpd-2.4.27/srclib'make: *** [all-recursive] Error 1
yum install expat-devel
6.启动apache/lnamp/apache2/bin/apachectl -f /lnamp/apache2/conf/httpd.conf可能需要修改http.conf将里面的 #ServerName localhost:80 注释去掉即可。
成功提示 httpd (pid ***) already running停止apache/lnamp/apache2/bin/apachectl –k stop

7.配置文件

1.支持php http.conf添加 AddType application/x-httpd-php .php

2.添加重写 mod_rewrite去掉注释

3.http.conf最后添加 Include /www/vhosts/*.conf

8.网站conf文件简单编写
<VirtualHost *:80>ServerName poetnote.comDocumentRoot "/var/www/poetnote/public"SetEnv APPLICATION_ENV "development"<Directory "/var/www/poetnote/public">DirectoryIndex index.phpAllowOverride AllRequire all granted</Directory></VirtualHost>
9.网站conf文件,python,django使用
<VirtualHost *:80>
    ServerName sports.poetnote.com#ServerAlias otherdomain.comServerAdmin ghoiufyia@163.com  Alias /media/ /var/www/sports/media/    Alias /static/ /var/www/sports/static/      <Directory /var/www/sports/media/>       Require all granted</Directory><Directory /var/www/sports/static/>Require all granted    </Directory>  WSGIScriptAlias / /var/www/sports/sports/wsgi.py# WSGIDaemonProcess ziqiangxuetang.com python-path=/home/tu/blog:/home/tu/.virtualenvs/blog/lib/python2.7/site-packages# WSGIProcessGroup ziqiangxuetang.com    <Directory /var/www/sports/sports/><Files wsgi.py/>Require all granted</Files>    </Directory></VirtualHost>


成功提示 httpd (pid ***) already running停止apache/lnamp/apache2/bin/apachectl –k stop