Linux安装httpd及php、PHP探针

安装Apahce及php

安装 yum -y install httpd php

启动httpd service httpd start

修改端口号 vi /etc/httpd/conf/httpd.conf
修改 Listen 80

iptables打开对应端口

iptables -I INPUT -p tcp --dport 端口 -j ACCEPT
service iptables save
service iptables restart

如果启动httpd时,报错Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

则需要修改httpd.conf

ServerName 127.0.0.1:976

大概在第276行.


参考:快速搭建一个网站
https://wxlzmt.github.io/pages/simple/md_trans.html?url=https://raw.githubusercontent.com/wxlzmt/wxlzmt.github.io/master/resource/script/quick-start-httpd.md


robots.txt

https://raw.githubusercontent.com/wxlzmt/wxlzmt.github.io/master/resource/script/robots.txt


生成伪装站点
wget https://raw.githubusercontent.com/wxlzmt/bigfiles/master/jdk1.8-api.zip
unzip -n jdk1.8-api.zip -d /var/www/html
下载探针
wget  http://www.yahei.net/tz/tz.zip

其实就是一个php文件,备用下载:
wget https://wxlzmt.github.io/resource/script/tz.php

放到/var/www/html/tz.php就可以了

访问http://ip:port/tz.php即可.

小内存优化

先查看apache的运行模式,查看命令:httpd -l

# httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

可以看到运行模式是prefork模式.

编辑配置文件vi /etc/httpd/conf/httpd.conf

修改为:

<IfModule prefork.c>
StartServers       1
MinSpareServers    1
MaxSpareServers    2
ServerLimit       30
MaxClients        30
MaxRequestsPerChild  100
</IfModule>

另外,其它配置项修改为:

Timeout 30
KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 5

查看当前占用内存最高的10个进程,命令:
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head

httpd目录显示,去掉最下面的服务器信息提示.

/etc/httpd/conf/httpd.conf内,设置ServerSignature Off

IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
ServerSignature Off

参考
如何实现访问apache时的目录浏览功能(apache file list view) - CSDN博客
http://blog.csdn.net/chen_gong1992/article/details/53437586


参考

Apache 占用内存并发优化设置
http://www.snschina.com/archives/493

apache占用内存高解决办法
https://my.oschina.net/vvcumt/blog/498828


来自
http://www.linuxdiyf.com/linux/27285.html


评论