Apache安装
Step 1 创建运行时用户和组
$ groupadd www
$ useradd -g www www -s /sbin/nologin -M
Step 2 安装工具集和依赖
$ yum install -y wget
$ wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
$ yum install -y gcc wget make libtool expat-devel pcre-devel openssl-devel libxml2-devel
Step 3 安装apr
$ cd ~
$ wget http://10.0.16.133/src/x86\_64/apr/apr-1.6.5.tar.gz
$ tar -zxvf apr-1.6.5.tar.gz
$ cd apr-1.6.5
$ sed -i s/"RM='\\$RM'"/"RM='\\$RM -f'"/ configure
$ ./configure --prefix=/usr/local/apr
$ make
$ make install
Step 4 安装apr-util
$ cd ~
$ wget http://10.0.16.133/src/x86\_64/apr/apr-util-1.6.1.tar.gz
$ tar -zxvf apr-util-1.6.1.tar.gz
$ cd apr-util-1.6.1
$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ make
$ make install
Step 5 安装httpd
$ cd ~
$ wget http://10.0.16.133/src/x86\_64/httpd/httpd-2.4.43.tar.gz
$ tar -zxvf httpd-2.4.43.tar.gz
$ cd httpd-2.4.43
$ ./configure --prefix=/usr/local/apache \\
--with-apr=/usr/local/apr \\
--with-apr-util=/usr/local/apr-util \\
--enable-so \\
--enable-ssl \\
--enable-cgi \\
--enable-rewrite \\
--with-pcre \\
--with-zlib \\
--with-mpm=event \\
--enable-modules=most \\
--enable-mpms-shared=all
$ make
$ make install
Step 6 创建日志存放目录
$ mkdir -pv /data/logs/apache
$ chown -R www:www /data/logs/apache
Step 7 创建Apache主配置文件
$ mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/http.conf.default
$ mkdir -p /usr/local/apache/conf/vhost
$ cat >/usr/local/apache/conf/httpd.conf < Listen 0.0.0.0:80 ServerRoot /usr/local/apache \# 加载模块 LoadModule authn\_file\_module modules/mod\_authn\_file.so LoadModule mpm\_prefork\_module modules/mod\_mpm\_prefork.so LoadModule authn\_core\_module modules/mod\_authn\_core.so LoadModule authz\_host\_module modules/mod\_authz\_host.so LoadModule authz\_groupfile\_module modules/mod\_authz\_groupfile.so LoadModule authz\_user\_module modules/mod\_authz\_user.so LoadModule authz\_core\_module modules/mod\_authz\_core.so LoadModule access\_compat\_module modules/mod\_access\_compat.so LoadModule auth\_basic\_module modules/mod\_auth\_basic.so LoadModule reqtimeout\_module modules/mod\_reqtimeout.so LoadModule filter\_module modules/mod\_filter.so LoadModule mime\_module modules/mod\_mime.so LoadModule log\_config\_module modules/mod\_log\_config.so LoadModule logio\_module modules/mod\_logio.so LoadModule env\_module modules/mod\_env.so LoadModule headers\_module modules/mod\_headers.so LoadModule setenvif\_module modules/mod\_setenvif.so LoadModule version\_module modules/mod\_version.so LoadModule ssl\_module modules/mod\_ssl.so LoadModule unixd\_module modules/mod\_unixd.so LoadModule status\_module modules/mod\_status.so LoadModule autoindex\_module modules/mod\_autoindex.so LoadModule cgid\_module modules/mod\_cgid.so LoadModule cgi\_module modules/mod\_cgi.so LoadModule vhost\_alias\_module modules/mod\_vhost\_alias.so LoadModule dir\_module modules/mod\_dir.so LoadModule alias\_module modules/mod\_alias.so LoadModule rewrite\_module modules/mod\_rewrite.so ServerAdmin admin@feisu.com ServerName localhost ############### \# 日志格式定义# ############### LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined LogFormat "%h %l %u %t \\"%r\\" %>s %b" common LogFormat "{\\"server\_ip\\": \\"%A\\",\\"client\_ip\\": \\"%a\\",\\"@timestamp\\": \\"%{%Y-%m-%dT%H:%M:%S%z}t\\",\\"server\_name\\": \\"%v\\",\\"mehtod\\": \\"%m\\",\\"request\\": \\"%U%q\\", \\"url\\": \\"%U\\",\\"query\\": \\"%q\\",\\"status\\": \\"%>s\\",\\"user\_agent\\": \\"%{User-agent}i\\",\\"referer\\": \\"%{Referer}i\\",\\"response\_time\\": \\"%D\\",\\"x\_forward\_for\\": \\"%{X-Forwarded-For}i\\",\\"send\_bytes\\": \\"%I\\",\\"recv\_bytes\\": \\"%O\\"}" json ErrorLog /data/logs/apache/error.log CustomLog /data/logs/apache/access.log json LogLevel warn ############### \# Mime类型加载# ############### TypesConfig conf/mime.types AddType application/x-gzip .tgz AddEncoding x-compress .Z AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddType application/x-httpd-php .php ############### \# 全局安全规则# ############### \# 禁止通过web访问.htaccess Require all denied \# 隐藏Apache版本号 ServerTokens ProductOnly ServerSignature Off \# 开启同源策略限制,只允许同域名访问 Header always append X-Frame-Options SAMEORIGIN \# 禁止.ssh访问 Order allow,deny Deny from all \# 禁止.git访问 Order allow,deny Deny from all \# 限制Apache运行时用户 User www Group www ########### \# 虚拟主机# ########### Include conf/vhost/\*.conf EOF Step 8 创建默认虚拟主机 $ mkdir -pv /data/wwwroot/default $ echo "hello world" > /data/wwwroot/default/index.html $ cat >/usr/local/apache/conf/vhost/0.conf < DocumentRoot /data/wwwroot/default ServerName localhost DirectoryIndex index.html EOF Step 9 添加系统服务 $ cat > /usr/lib/systemd/system/httpd.service << \_EOF \[Unit\] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target \[Service\] Type=forking ExecStartPre=/usr/local/apache/bin/httpd -t ExecStart=/usr/local/apache/bin/httpd -k start ExecReload=/usr/local/apache/bin/httpd -k graceful ExecStop=/usr/local/apach/bin/httpd -k stop KillSignal=SIGKILL PrivateTmp=true \[Install\] WantedBy=multi-user.target \_EOF $ systemctl daemon-reload Step 10 启动服务并添加到开机自启动 $ systemctl start httpd $ systemctl enable httpd Step 11 添加日志切割脚本 $ cat > /etc/logrotate.d/httpd << \_EOF /data/logs/apache/\*.log { daily rotate 15 compress nodelaycompress ifempty dateext missingok postrotate \[ -e /usr/local/apache/bin/httpd \] && /usr/local/apache/bin/httpd -k graceful &>/dev/null endscript } \_EOF 验证 $curl http://localhosthello world 配置文件详解 配置文件详解文件位置:/etc/httpd/conf/httpd.conf ServerRoot "/etc/httpd" //服务器的根路径,改文件中所有涉及到的路径的根都是相对它而言的。 Listen 80 //监听的端口 Include conf.modules.d/\*.conf //包含辅助配置文件目录下的所有以.conf结尾的;;;文件(/etc/httpd/conf.modules.d/\*.conf) User apache //运行web服务的用户 Group apache ServerAdmin root@localhost //管理员邮件地址 #ServerName www.example.com:80 //服务器的名字 ServerName www.uplooking.com:80 AllowOverride none Require all denied DocumentRoot "/var/www/html" //web服务文档根路径 AllowOverride None # Allow open access: Require all granted Options Indexes FollowSymLinks //Indexes:索引目录,(默认没有主页时),允许索引目录 FollowSymLinks:支持符号链接 软连接 AllowOverride None //和访问权限有关 可以进行认证 None --不使用认证 all--应用所有的认证指令 AuthConfig --允许使用与认证授权相关的指令 Require all granted //访问控制 所有人方行 DirectoryIndex index.html //网站索引页的名称 Require all denied ErrorLog "logs/error\_log" //错误日志的设定 LogLevel warn //日志级别 LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined //日志格式规定 LogFormat "%h %l %u %t \\"%r\\" %>s %b" common //日志格式规定 LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\" %I %O" combinedio //日志格式规定 CustomLog "logs/access\_log" combined //访问日志 # Alias /webpath /full/filesystem/path //给路径设置别名 意味着访问http://Server\_ip/webpath时,其页面文件来自于/full/filesystem/path中 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" //脚本路径的别名 AllowOverride None Options None Require all granted TypesConfig /etc/mime.types //支持哪些非二进制文件 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .shtml AddOutputFilter INCLUDES .shtml AddDefaultCharset UTF-8 //默认字符集 #EnableMMAP off //线程模式 EnableSendfile on //开启进程模式(默认) IncludeOptional conf.d/\*.conf //包含辅助配置文件目录下的所有以.conf结尾的文件(/etc/httpd/conf.d/\*.conf) 黑客&网络安全如何学习 今天只要你给我的文章点赞,我私藏的网安学习资料一样免费共享给你们,来看看有哪些东西。 1.学习路线图 攻击和防守要学的东西也不少,具体要学的东西我都写在了上面的路线图,如果你能学完它们,你去就业和接私活完全没有问题。 2.视频教程 网上虽然也有很多的学习资源,但基本上都残缺不全的,这是我自己录的网安视频教程,上面路线图的每一个知识点,我都有配套的视频讲解。 内容涵盖了网络安全法学习、网络安全运营等保测评、渗透测试基础、漏洞详解、计算机基础知识等,都是网络安全入门必知必会的学习内容。 (都打包成一块的了,不能一一展开,总共300多集) 因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取 CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享 3.技术文档和电子书 技术文档也是我自己整理的,包括我参加大型网安行动、CTF和挖SRC漏洞的经验和技术要点,电子书也有200多本,由于内容的敏感性,我就不一一展示了。 因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取 CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享 4.工具包、面试题和源码 “工欲善其事必先利其器”我为大家总结出了最受欢迎的几十款款黑客工具。涉及范围主要集中在 信息收集、Android黑客工具、自动化工具、网络钓鱼等,感兴趣的同学不容错过。 还有我视频里讲的案例源码和对应的工具包,需要的话也可以拿走。 因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取 CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享 最后就是我这几年整理的网安方面的面试题,如果你是要找网安方面的工作,它们绝对能帮你大忙。 这些题目都是大家在面试深信服、奇安信、腾讯或者其它大厂面试时经常遇到的,如果大家有好的题目或者好的见解欢迎分享。 参考解析:深信服官网、奇安信官网、Freebuf、csdn等 内容特点:条理清晰,含图像化表示更加易懂。 内容概要:包括 内网、操作系统、协议、渗透测试、安服、漏洞、注入、XSS、CSRF、SSRF、文件上传、文件下载、文件包含、XXE、逻辑漏洞、工具、SQLmap、NMAP、BP、MSF… 因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取 CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享