您的位置:首页 > 运维架构 > Apache

linux 服务器部署 lnamp 二apache安装

2017-08-22 09:24 513 查看
一、yum安装
yum -y 
install
 
httpd
二、编译安装官方教程:http://httpd.apache.org/docs/2.4/install.html1.下载
wget http://apache.fayea.com//httpd/httpd-2.4.27.tar.gz tar xvzf httpd-2.4.25.tar.gz
cd httpd-2.4.25
2../configure报错
checking for APR... no
configure: 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.gz tar xvzf pcre-8.40.tar.gz
cd pcre-8.40
./configure --prefix=/usr/local/pcre
make
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.gz tar xvzf 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
vim configure文件,查找30206行, $RM "$cfgfile" 这个地方,用#注释掉
继续./configure –prefix=/usr/local
make
make install

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz tar xzvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install

对应http编译配置
./configure --prefix=/lnamp/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make
make install
b.将代码拷贝至http源码目录
wget http://mirror.bit.edu.cn/apache//apr/apr-1.5.2.tar.gz tar xvzf apr-1.5.2.tar.gz
mv apr-1.5.2 apr
wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.4.tar.gz tar xzvf apr-util-1.5.4.tar.gz
mv apr-util-1.5.4 apr-util
mv 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-apr
make
make 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 1
make[3]: Leaving directory `/opt/src/httpd-2.4.27/srclib/apr-util'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/opt/src/httpd-2.4.27/srclib/apr-util'
make[1]: *** [all-recursive] Error 1
make[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 .php2.添加重写 mod_rewrite去掉注释3.http.conf最后添加 Include /www/vhosts/*.conf8.网站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.comAlias /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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: