编译安装httpd,并将其配置为服务
#创建httpd安装目录 mkdir /usr/local/httpd24/conf -p #新建运行httpd的服务账户 groupadd apache useradd apache -g redis -r -s /sbin/nologin
#安装依赖
yum install apr-devel
yum install apr-util-devel
yum -y install pcre-devel
#解压httpd-2.4.53.tar.gz tar -zxf httpd-2.4.53.tar.gz cd httpd-2.4.53 #编译,安装 ./configure --prefix=/usr/local/httpd24 \ --sysconfdir=/usr/local/httpd24/conf \ #指定httpd.conf配置文件位置 --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --with-zlib \ --with-pcre \ --enable-modules=most make && make install #启停httpd进程 /etc/init.d/apachectl start #将httpd配置为服务,通过systemctl控制 cp /usr/local/httpd24/bin/apachectl /etc/init.d/httpd vi /etc/init.d/httpd #在开头添加如下3行 #!/bin/bash # chkconfig: 35 85 21 # description: Apache is a World Wide Web server chkconfig --add httpd systemctl start httpd
./apachectl start出现如下报错,处理办法:
提示报错 Invalid command 'User',在httpd.conf中添加如下:
LoadModule unixd_module modules/mod_unixd.so
提示报错 Invalid command 'Require',在httpd.conf中添加如下:
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule authz_core_module modules/mod_authz_core.so
提示报错 Invalid command 'IndexOptions',在httpd.conf中添加如下:
LoadModule autoindex_module modules/mod_autoindex.so