Linux——安装apache
2017-02-06 14:33
155 查看
1. 检查机器是否已经安装了apache(系统自带)Centos6.5
rpm -qa |grep httpd
rpm -qa |grep apache
并检查/etc/httpd/httpd.conf 配置文件是否存在
如果存在则先卸载,或者关闭centos自带的web服务,执行chkconfig httpd off
并修改httpd的服务端口80为其他端口
2. 在官网下载对应的release
http://httpd.apache.org/
选择现在当前最新版本: httpd-2.4.25.tar.gz
3.将安装包拷贝到VM上并解压
tar -zxvf httpd-2.4.25.tar.gz
4. 正常安装(另有安装一些相关插件会在后面补充)
进入httpd-2.4.25文件夹(cd httpd-2.4.25)
执行命令
5. 处理apr问题
http://apr.apache.org/download.cgi 下载对应的安装包
以 apr-1.5.2.tar.gz 为例
和上段一致拷贝到文件夹下解压
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
成功后会出现很多文件安装 done 的字样
注意如果没有安装权限要sudo make/sudo make install
6. 处理apr-util问题
继续执行命令
[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache2
出现以下报错
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
继续安装apr-util依赖包 (参照apr下载地址)
以 apr-util-1.5.4.tar.gz为例
命令和安装apr类似
tar -zxf 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
7.继续编译安装apache
如果继续按照上文
rpm -qa |grep httpd
rpm -qa |grep apache
并检查/etc/httpd/httpd.conf 配置文件是否存在
如果存在则先卸载,或者关闭centos自带的web服务,执行chkconfig httpd off
并修改httpd的服务端口80为其他端口
2. 在官网下载对应的release
http://httpd.apache.org/
选择现在当前最新版本: httpd-2.4.25.tar.gz
3.将安装包拷贝到VM上并解压
tar -zxvf httpd-2.4.25.tar.gz
4. 正常安装(另有安装一些相关插件会在后面补充)
进入httpd-2.4.25文件夹(cd httpd-2.4.25)
执行命令
./configure --prefix=/usr/local/apache2
然后报错:(找不到apr)
checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation.
5. 处理apr问题
http://apr.apache.org/download.cgi 下载对应的安装包
以 apr-1.5.2.tar.gz 为例
和上段一致拷贝到文件夹下解压
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
成功后会出现很多文件安装 done 的字样
注意如果没有安装权限要sudo make/sudo make install
6. 处理apr-util问题
继续执行命令
[root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache2
出现以下报错
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
继续安装apr-util依赖包 (参照apr下载地址)
以 apr-util-1.5.4.tar.gz为例
命令和安装apr类似
tar -zxf 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
7.继续编译安装apache
如果继续按照上文
./configure --prefix=/usr/local/apache2 可能仍然报错没安装apr-util
可是老娘刚才已经装了撒!
执行
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
即可
编译的时候没有将apr-util路径加上他不认得罢了
继续, [root@localhost httpd-2.4.25]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " configure: configure: Configuring Apache Portable Runtime Utility library... configure: checking for APR-util... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for gcc option to accept ISO C99... -std=gnu99 checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/[/code]
在 http://pcre.org/ 安装pcre包
以pcre-8.40.tar.gz为例
tar -zxf pcre-8.40.tar.gz
cd pcre-8.40./configure --prefix=/usr/local/pcre
make
make install
8.继续编译安装apache
cd httpd-2.4.25
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
9.启动apache
/usr/local/apache2/bin/apachectl start
然后报错
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
vim /usr/local/apache2/conf/httpd.conf
添加
将
#ServerName www.examda.com:80
改为
ServerName localhost:80即可
保存退出
重新启动
/usr/local/apache2/bin/apachectl restart
还是不行(此时能ping通)
最终发现,将iptables(防火墙)关闭即可
service iptables stop
在浏览器输入VM的IP地址访问,It works!
以上。
相关文章推荐
- Linux+Apache+PHP+Mysql快速安装
- Linux下安装最新Apache2.0.52+php5+gd2+MySQLl
- 新版mysql+apache+php Linux安装指南
- wxzh001,进来看关于APACHE+PHP+MYSQL+SSL的LINUX下安装配置(转自奥索)
- apache安装linux下
- mysql+apache+php Linux安装指南
- 在 Linux 上安装Apache+ApacheJServ+JSP
- 新版mysql+apache+php Linux安装指南
- linux下Mysql+php5+apache安装手记
- linux Apache 安装笔记
- mysql+apache+php Linux安装指南
- linux下apache+resin安装文档
- Linux下Apache2.0简单安装、配置、测试过程
- linux下安装apache
- 最新版 linux Fedora 下apache2.2 +mysql5.1.5 +php5.12 +GD +mod_limitipconn... 安装指南
- MySQL+PHP+APACHE在linux下的安装
- 在linux下安装Apache 2、PHP5.0.0、Sybase ASE 12.5
- Linux 下Apache和Resin的安装
- Apache-+Php-+Mysql- 在 linux 下的安装
- 在 Linux 上安装Apache+ApacheJServ+JSP