61581229 发表于 2018-11-19 07:29:09

LAMP搭建2:Apache安装

  1.进入/usr/local/src/目录下去下载Apache的安装包httpd-2.2.29.tar.gz
  # cd /usr/local/src
  # ls
  httpd-2.2.9.tar.gz
  2.解压安装包
  # tar zxvf httpd-2.2.9.tar.gz
  3.进入安装目录
  # cd httpd-2.2.9
  # ls
  ABOUT_APACHE      CHANGES      include         modules         srclib
  acinclude.m4      config.layoutINSTALL         NOTICE            support
  Apache.dsw      configure      InstallBin.dspNWGNUmakefile   test
  apachenw.mcp.zipconfigure.in   LAYOUT          os                VERSIONING
  build             docs         libhttpd.dsp    README
  BuildAll.dsp      emacs-style    LICENSE         README.platforms
  BuildBin.dsp      httpd.dsp      Makefile.in   ROADMAP
  buildconf         httpd.spec   Makefile.win    server
  4.查看安装说明文件INSTALL可以看到安装步骤
  ……
  $ ./configure --prefix=PREFIX
  $ make
  $ make install
  $ PREFIX/bin/apachectl start
  ……
  5.使用下面的参数配置安装选项,回车即可
  # ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
  其中:
  --prefix指定安装目录
  --with-include-apr依赖包apr,支持httpd,可以跨平台运作
  --with-pcre正则相关的库
  shared表示以动态共享的方式安装
  有错改错,缺少什么库就安装:
  如checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
  yum installzlib-devel
  6.直到配置没有问题然后开始编译
  # echo $?
  0
  # make
  7.编译没问题然后开始安装
  # echo $?
  0
  # make install
  8.安装成功
  # echo $?
  0
  # ls /usr/local/apache2/
  bin    cgi-binerror   icons    lib   man   modules
  buildconf   htdocsincludelogsmanual
  9.现在还不能直接运行,需要编辑Apache主配置文件httpd.conf:
  # vim /usr/local/apache2/conf/httpd.conf
  将ServerName改为localhost:80,去掉前面的注释符#
  ……
  # ServerName gives the name and port that the server uses to identify itself.
  # This can often be determined automatically, but we recommend you specify
  # it explicitly to prevent problems during startup.
  #
  # If your host doesn't have a registered DNS name, enter its IP address here.
  #
  ServerName localhost:80
  ……
  10.将Apache加入系统环境变量:
  # vim /etc/profile.d/path.sh
  #!/bin/bash
  export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/
  # source /etc/profile.d/path.sh
  11.检查配置是否正确,正确则启动Apache
  # apachectl -t
  Syntax OK
  # apachectl start
  httpd (pid 22581) already running
  12.查看Apache的进程和端口
  # ps aux|grep httpd
  # netstat -lnp
  




页: [1]
查看完整版本: LAMP搭建2:Apache安装