a. httpd官方网站/下载地址:
http://httpd.apache.org/download.cgi或https://github.com/dollarphper/soft/raw/master/apache/httpd-2.4.34.tar.gz
b. arp、arp-util官方网站:
http://apr.apache.org/download.cgi或https://github.com/dollarphper/soft/raw/master/apache/apr-1.6.3.tar.gzhttps://github.com/dollarphper/soft/raw/master/apache/apr-util-1.6.1.tar.gz
c. pcre官方网站:
https://www.pcre.org/或https://github.com/dollarphper/soft/raw/master/apache/pcre-8.42.tar.gz
a. 安装依赖:
yum ?-y ?install ?expat-develyum ?-y ?install ?libxml2-devel
b. 解压:
tar ?-xzf ?httpd-2.4.34.tar.gztar ?-xzf ?apr-1.6.3.tar.gztar ?-xzf ?apr-util-1.6.1.tar.gztar ?-xzf ?pcre-8.42.tar.gz
c. 移动apr、apr-util到httpd目录下并重命名:
mv ?apr-1.6.3 ?httpd-2.4.34/srclib/aprmv ?apr-util-1.6.1 ?httpd-2.4.34/srclib/apr-util
d. 安装pcre:
d-1. 创建文件夹:
mkdir ?/etc/pcre
d-2. 进入pcre目录:
cd ?pcre-8.42
d-3. 编译安装:
./configure ?--prefix=/etc/pcremake ?&& ?make ?install ?&& ?make ?clean
e. 安装apache:
e-1. 创建文件夹:
mkdir ?/etc/httpd
e-2. 进入apache目录:
cd ?httpd-2.4.34
e-3. 编译安装:
./configure ?--prefix=/etc/httpd ?-with-pcre=/etc/pcre/bin/pcre-config ?-with-included-aprmake ?&& ?make ?install ?&& ?make ?clean
a. 修改配置文件:
vim ?/etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd"ServerName leeListen 80LoadModule authn_file_module modules/mod_authn_file.soLoadModule authn_core_module modules/mod_authn_core.soLoadModule authz_host_module modules/mod_authz_host.soLoadModule authz_groupfile_module modules/mod_authz_groupfile.soLoadModule authz_user_module modules/mod_authz_user.soLoadModule authz_core_module modules/mod_authz_core.soLoadModule access_compat_module modules/mod_access_compat.soLoadModule auth_basic_module modules/mod_auth_basic.soLoadModule reqtimeout_module modules/mod_reqtimeout.soLoadModule filter_module modules/mod_filter.soLoadModule mime_module modules/mod_mime.soLoadModule log_config_module modules/mod_log_config.soLoadModule env_module modules/mod_env.soLoadModule headers_module modules/mod_headers.soLoadModule setenvif_module modules/mod_setenvif.soLoadModule version_module modules/mod_version.soLoadModule unixd_module modules/mod_unixd.soLoadModule status_module modules/mod_status.soLoadModule autoindex_module modules/mod_autoindex.soLoadModule dir_module modules/mod_dir.soLoadModule alias_module modules/mod_alias.so<IfModule unixd_module>User daemonGroup daemon</IfModule>ServerAdmin you@example.com<Directory />AllowOverride noneRequire all denied</Directory>DocumentRoot "/var/www/html"<Directory "/var/www/html">Options Indexes FollowSymLinksAllowOverride NoneRequire all granted</Directory><IfModule dir_module>DirectoryIndex index.html</IfModule><Files ".ht*">Require all denied</Files>ErrorLog "logs/error_log"LogLevel warn<IfModule log_config_module>LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module> ?LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio</IfModule>CustomLog "logs/access_log" common</IfModule><IfModule alias_module>ScriptAlias /cgi-bin/ "/etc/httpd/cgi-bin/"</IfModule><IfModule cgid_module></IfModule><Directory "/etc/httpd/cgi-bin">AllowOverride NoneOptions NoneRequire all granted</Directory><IfModule headers_module>RequestHeader unset Proxy early</IfModule><IfModule mime_module>TypesConfig conf/mime.typesAddType application/x-compress .ZAddType application/x-gzip .gz .tgz</IfModule><IfModule proxy_html_module>Include conf/extra/proxy-html.conf</IfModule><IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>
b. 新建文件夹:
mkdir ?-p ?/var/www/html
a. 启动命令:
/etc/httpd/bin/apachectl ?-k ?start
b. 停止命令:
/etc/httpd/bin/apachectl ?-k ?stop
c. 重启命令:
/etc/httpd/bin/apachectl ?-k ?restart
d. 启动apache:
e. 创建测试文件:
echo ?"hello world" ?> ?/var/www/html/index.html
f. 浏览器访问:
centos7源码安装apache
原文地址:http://blog.51cto.com/12173069/2174037