九周第五次课(9月29日)
11.14/11.15 Apache和PHP结合
11.16/11.17 Apache默认虚拟主机
11.14 Apache和PHP结合(上)
httpd主配置文件/usr/local/apache2.4/conf/httpd.conf
-vim/usr/local/apache2.4/conf/httpd.conf//修改以下4个地方ServerNameRequirealldeniedAddTypeapplication/x-httpd-php.phpDirectoryIndexindex.htmlindex.php-/usr/local/apache2.4/bin/apachectl-t//测试语法-/usr/local/apache2.4/bin/apachectlstart//启动服务-netstat-lntp-curllocalhost-vim/usr/local/apache2.4/htodcs/test.php//增加如下内容<?phpecho123;?>curllocalhost/test.php
先打开httpd的配置文件
-[root@aminglinux-001~]#vim/usr/local/apache2.4/conf/httpd.conf[root@aminglinux-001~]#vim/usr/local/apache2.4/conf/httpd.conf[1]+已停止vim/usr/local/apache2.4/conf/httpd.conf[root@aminglinux-001~]#/usr/local/apache2.4/bin/apachectlrestartAH00558:httpd:Couldnotreliablydeterminetheserver‘sfullyqualifieddomainname,usingfe80::a152:bbdf:8b2b:db9b.Setthe‘ServerName‘directivegloballytosuppressthismessagehttpdnotrunning,tryingtostart[root@aminglinux-001~]#fgvim/usr/local/apache2.4/conf/httpd.conf#ServerAdminyou@example.com##ServerNamegivesthenameandportthattheserverusestoidentifyitself.#Thiscanoftenbedeterminedautomatically,butwerecommendyouspecify#itexplicitlytopreventproblemsduringstartup.##Ifyourhostdoesn‘thavearegisteredDNSname,enteritsIPaddresshere.#ServerNamewww.example.com:80##Denyaccesstotheentiretyofyourserver‘sfilesystem.Youmust#explicitlypermitaccesstowebcontentdirectoriesinother#<Directory>blocksbelow.#<Directory/>AllowOverridenoneRequirealldenied</Directory>##Notethatfromthispointforwardyoumustspecificallyallow#particularfeaturestobeenabled-soifsomething‘snotworkingas#youmightexpect,makesurethatyouhavespecificallyenabledit#below.#--插入--[root@localhost~]#vim/usr/local/apache2.4/conf/httpd.conf[1]+已停止vim/usr/local/apache2.4/conf/httpd.conf[root@localhost~]#/usr/local/apache2.4/bin/apachectlrestartAH00558:httpd:Couldnotreliablydeterminetheserver‘sfullyqualifieddomainname,usinglocalhost.localdomain.Setthe‘ServerName‘directivegloballytosuppressthismessagehttpdnotrunning,tryingtostart/usr/local/apache2.4/bin/apachectl:行79:2258段错误$HTTPD-k$ARGV[root@localhost~]#fgvim/usr/local/apache2.4/conf/httpd.conf[root@localhost~]#fg-bash:fg:当前:无此任务[root@localhost~]#/usr/local/apache2.4/bin/apachectlrestarthttpdnotrunning,tryingtostart/usr/local/apache2.4/bin/apachectl:行79:2262段错误$HTTPD-k$ARGV[root@localhost~]#vim/usr/local/apache2.4/conf/httpd.conf[root@localhost~]#/usr/local/apache2.4/bin/apachectlrestarthttpdnotrunning,tryingtostart/usr/local/apache2.4/bin/apachectl:行79:2266段错误$HTTPD-k$ARGV[root@localhost~]#/usr/local/apache2.4/bin/apachectlstophttpd(nopidfile)notrunning[root@localhost~]#/usr/local/apache2.4/bin/apachectlstart/usr/local/apache2.4/bin/apachectl:行79:2272段错误$HTTPD-k$ARGV[root@localhost~]#!vivim/usr/local/apache2.4/conf/httpd.conf[root@localhost~]#/usr/local/apache2.4/bin/apachectlstart[root@localhost~]#
[root@localhost~]#psaux|grephttpdroot22770.00.82535808788?Ss14:300:00/usr/local/apache2.4/bin/httpd-kstartdaemon22780.01.154040811008?Sl14:300:00/usr/local/apache2.4/bin/httpd-kstartdaemon22790.01.154040811008?Sl14:300:00/usr/local/apache2.4/bin/httpd-kstartdaemon22820.01.154040811008?Sl14:300:00/usr/local/apache2.4/bin/httpd-kstartroot23640.00.0112680976pts/0S+14:320:00grep--color=autohttpd[root@localhost~]#
刚才把servername打开了 也就不再提示那个错误了 httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName‘ directive globally to suppress this message httpd not running, trying to start
这是第一处,第二处 Require all denied
用网页访问地址192.168.202.131(本机ip)带不开,再用windowsping 下,是可以ping通,试下telnet 访问下80端口 使用telnet 192.168.202.131 80
因为windows 并没有打开tenet的客户端,所以它会提示没有这个命令
打开telnet客户端方式-打开控制面板-程序-程序和功能-打开或关闭windows功能
使用telnet 192.168.202.131 80 结果是 C:\Users\Administrator.USER-20170629EN>telnet 192.168.202.131 80 正在连接192.168.202.131...无法打开到主机的连接。 在端口 80: 连接失败 80端口并不通,因为在linux服务器上并没有打开80端口
使用iptables -nvL 看下规则
[root@localhost~]#iptables-nvLChainINPUT(policyACCEPT0packets,0bytes)pktsbytestargetprotoptinoutsourcedestination66054606ACCEPTall--**0.0.0.0/00.0.0.0/0ctstateRELATED,ESTABLISHED180ACCEPTall--lo*0.0.0.0/00.0.0.0/0251798INPUT_directall--**0.0.0.0/00.0.0.0/0251798INPUT_ZONES_SOURCEall--**0.0.0.0/00.0.0.0/0251798INPUT_ZONESall--**0.0.0.0/00.0.0.0/000DROPall--**0.0.0.0/00.0.0.0/0ctstateINVALID231686REJECTall--**0.0.0.0/00.0.0.0/0reject-withicmp-host-prohibitedChainFORWARD(policyACCEPT0packets,0bytes)pktsbytestargetprotoptinoutsourcedestination00ACCEPTall--**0.0.0.0/00.0.0.0/0ctstateRELATED,ESTABLISHED00ACCEPTall--lo*0.0.0.0/00.0.0.0/000FORWARD_directall--**0.0.0.0/00.0.0.0/000FORWARD_IN_ZONES_SOURCEall--**0.0.0.0/00.0.0.0/000FORWARD_IN_ZONESall--**0.0.0.0/00.0.0.0/000FORWARD_OUT_ZONES_SOURCEall--**0.0.0.0/00.0.0.0/000FORWARD_OUT_ZONESall--**0.0.0.0/00.0.0.0/000DROPall--**0.0.0.0/00.0.0.0/0ctstateINVALID00REJECTall--**0.0.0.0/00.0.0.0/0reject-withicmp-host-prohibitedChainOUTPUT(policyACCEPT545packets,76871bytes)pktsbytestargetprotoptinoutsourcedestination54576871OUTPUT_directall--**0.0.0.0/00.0.0.0/0ChainFORWARD_IN_ZONES(1references)pktsbytestargetprotoptinoutsourcedestination00FWDI_publicall--ens33*0.0.0.0/00.0.0.0/0[goto]00FWDI_publicall--+*0.0.0.0/00.0.0.0/0[goto]ChainFORWARD_IN_ZONES_SOURCE(1references)pktsbytestargetprotoptinoutsourcedestinationChainFORWARD_OUT_ZONES(1references)pktsbytestargetprotoptinoutsourcedestination00FWDO_publicall--*ens330.0.0.0/00.0.0.0/0[goto]00FWDO_publicall--*+0.0.0.0/00.0.0.0/0[goto]ChainFORWARD_OUT_ZONES_SOURCE(1references)pktsbytestargetprotoptinoutsourcedestinationChainFORWARD_direct(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDI_public(2references)pktsbytestargetprotoptinoutsourcedestination00FWDI_public_logall--**0.0.0.0/00.0.0.0/000FWDI_public_denyall--**0.0.0.0/00.0.0.0/000FWDI_public_allowall--**0.0.0.0/00.0.0.0/000ACCEPTicmp--**0.0.0.0/00.0.0.0/0ChainFWDI_public_allow(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDI_public_deny(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDI_public_log(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDO_public(2references)pktsbytestargetprotoptinoutsourcedestination00FWDO_public_logall--**0.0.0.0/00.0.0.0/000FWDO_public_denyall--**0.0.0.0/00.0.0.0/000FWDO_public_allowall--**0.0.0.0/00.0.0.0/0ChainFWDO_public_allow(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDO_public_deny(1references)pktsbytestargetprotoptinoutsourcedestinationChainFWDO_public_log(1references)pktsbytestargetprotoptinoutsourcedestinationChainINPUT_ZONES(1references)pktsbytestargetprotoptinoutsourcedestination251798IN_publicall--ens33*0.0.0.0/00.0.0.0/0[goto]00IN_publicall--+*0.0.0.0/00.0.0.0/0[goto]ChainINPUT_ZONES_SOURCE(1references)pktsbytestargetprotoptinoutsourcedestinationChainINPUT_direct(1references)pktsbytestargetprotoptinoutsourcedestinationChainIN_public(2references)pktsbytestargetprotoptinoutsourcedestination251798IN_public_logall--**0.0.0.0/00.0.0.0/0251798IN_public_denyall--**0.0.0.0/00.0.0.0/0251798IN_public_allowall--**0.0.0.0/00.0.0.0/0160ACCEPTicmp--**0.0.0.0/00.0.0.0/0ChainIN_public_allow(1references)pktsbytestargetprotoptinoutsourcedestination152ACCEPTtcp--**0.0.0.0/00.0.0.0/0tcpdpt:22ctstateNEWChainIN_public_deny(1references)pktsbytestargetprotoptinoutsourcedestinationChainIN_public_log(1references)pktsbytestargetprotoptinoutsourcedestinationChainOUTPUT_direct(1references)pktsbytestargetprotoptinoutsourcedestination[root@localhost~]#;临时增加一条规则,允许80端口访问[root@localhost~]#iptables-IINPUT-ptcp--dport80-jACCEPT[root@localhost~]#
这个时候再来看网页 ,刷新下,显示可以了,能够访问了 It works !
再看下telenet 再试下,telnet 192.168.202.131 80 ,只要显示成这个样子说明80端口通了
650) this.width=650;" src="http://oqxf7c508.bkt.clouddn.com/blog/20171006/144747815.png?imageslim" alt="mark" style="border-style:none;background-color:rgb(255,255,255);" />
按ctrl + ] 再输quit 就退出来了
再把那条规则删掉
知识推荐
- PHP 变量类型的强制转换 & 创建空对象
- 使用cURL和用户名和密码?
- CSS3选择器:nth-child和:nth-of-type之间的差异
- django上传文件
- 竞价推广网站被攻击?如何防御?
- eclipse导入myeclipse的web项目没法识怎么办?
- Hibernate入门
- 开源数据采集组件比较: scribe、chukwa、kafka、flume
- web框架根本Socket
- CSS实例:图片导航块
- node.js总结
- Jquery(一)—— 样式篇(转)
- go https ajax
- commons.fileupload ?文件上传
- ASP.NET MVC - 路由
- css3画半圆 , 加上一点动画
- web基础
- 单例模式 net