工作需要,为一台空白服务器安装apache,小白程序员,搞了一个下午,惭愧!
工具需要,也可以自己到apache下载
http://httpd.apache.org/download.cgi
遇到的bug
apr-1.5.1.tar.gz
apr-util.1.5.4.tar.gz
都是不是最新版本的,因为我用最新版安装,总是make install失败。所以放弃了
1.第一步 准备工作,先安装gcc C++ (百度有些文档是最后安装,我这里先安装了,这里需要root权限)
[root@localhost /]# yum install gcc-c++2. 第二步 1.下载安装包,需要下面3个安装包,把安装包用ftp拉到对应的目录下去。
[apps@app-srm-dev-1 svr]$ ll
total 11832
drwxr-xr-x 28 apps apps 4096 Feb 28 17:58 apr-1.5.1
-rw-rw-r-- 1 apps apps 1020833 Feb 28 17:52 apr-1.5.1.tar.gz
drwxr-xr-x 20 apps apps 4096 Feb 28 18:02 apr-util-1.5.4
-rw-rw-r-- 1 apps apps 874044 Feb 28 18:00 apr-util-1.5.4.tar.gz
drwxrwxr-x 4 apps apps 4096 Mar 1 15:45 gsc
drwxr-xr-x 12 apps apps 4096 Feb 28 18:13 httpd-2.4.29
-rw-rw-r-- 1 apps apps 8638793 Feb 28 18:04 httpd-2.4.29.tar.gz
drwxr-xr-x 8 apps apps 4096 Jul 5 2016 jdk1.8.0_91
drwxrwxr-x 6 apps apps 4096 Feb 28 18:09 local
drwxr-xr-x 8 apps apps 4096 Feb 28 18:11 pcre-8.20
-rw-rw-r-- 1 apps apps 1539766 Feb 28 18:09 pcre-8.20.tar.gz
drwxrwxr-x 3 apps apps 4096 Mar 1 17:04 software
[apps@app-srm-dev-1 svr]$
2.建立安装目录/apps/svr/local
3.命令安装
试安装apache
在目录下执行命令
[apps@app-srm-dev-1 apr-1.5.1]$ cd ../httpd-2.4.29
[apps@app-srm-dev-1 httpd-2.4.29]$ ^C
[apps@app-srm-dev-1 httpd-2.4.29]$
[apps@app-srm-dev-1 httpd-2.4.29]$
[apps@app-srm-dev-1 httpd-2.4.29]$
[apps@app-srm-dev-1 httpd-2.4.29]$ pwd
/apps/svr/httpd-2.4.29
[apps@app-srm-dev-1 httpd-2.4.29]$
[apps@app-srm-dev-1 httpd-2.4.29]$ ./configure --prefix=/apps/svr/local/httpd
估计会报错
checking for APR... no configure: error: APR not found. Please read the documentation.这个信息就是需要安装apr,apr-util下面是安装apr,apr-util进入刚刚解压的目录[apps@app-srm-dev-1 svr]$ cd apr-1.5.1[apps@app-srm-dev-1 apr-1.5.1]$ pwd/apps/svr/apr-1.5.1[apps@app-srm-dev-1 apr-1.5.1]$./configure --prefix=/apps/svr/local/apr//--http://blog.csdn.net/u013835877/article/details/39555345
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
//--http://blog.csdn.net/u013835877/article/details/39555345
安装完毕的时候,/apps/svr/local/apr这个目录是有bin目录的
[apps@app-srm-dev-1 apr-util-1.5.4]$
[apps@app-srm-dev-1 httpd-2.4.29]$./configure --prefix=/apps/svr/local/httpd --with-apr=/apps/svr/local/apr --with-apr-util=/apps/svr/local/apr-util
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[apps@app-srm-dev-1 httpd-2.4.29]$ ./configure --prefix=/apps/svr/local/httpd --with-pcre=/apps/svr/local/pcre --with-apr=/apps/svr/local/apr --with-apr-util=/apps/svr/local/apr-util
启动apache
在启动apache的命令之前,我们最好需要查看下配置文件,我的是在/usr/local/apache2/conf/httpd.conf,,如下:
2个地方需要改
ServerName
Listen
我们需要在这里servername做些修改,修改成你linux的ip,端口号就用默认的。
好了,真正启动Linux吧
/usr/local/apache2/bin/apachectl start
- 1
- 2
现在你就只需要在浏览器中输入ip地址即可访问。
注意:如果访问不了,可能需要关闭你的防火墙,命令如下:
service iptables stop
- 1
- 2
Ok,基本到这里就没问题了。
[apps@app-srm-dev-2 bin]$ ./apachectl stop
[apps@app-srm-dev-2 bin]$
[apps@app-srm-dev-2 bin]$
[apps@app-srm-dev-2 bin]$ ./apachectl start
[apps@app-srm-dev-2 bin]$ ps -ef|grep httpd
来源:https://www.cnblogs.com/sp219/p/8489182.html