WAMP环境配置说明--php服务器

 更新时间:2016年11月25日 16:09  点击:2029




文件下载网址
Apache 2.2.4 -- www.apache.com

PHP 5.2.0 -- www.php.net

MySQL 5.0.27 -- www.mysql.com

Zend Optimizer 3.2.0 -- www.zend.com

phpMyAdmin 2.9.2 -- www.phpmyadmin.net

Apache 2.2.4 的安装

1.站点下载 apache_2.2.4-win32-x86-no_ssl.msi 并执行。

2..按3 次Next按钮,安装程序要求输入你的Network Domain(网络域名)、Server Domain(服务器域名)和网站管理员的E-mail。

3..进入Next后,默认的安装路径是"C:Program FilesApache Software FoundationApache2.2",修改路径,改为前面所述的"D:Program FilesApache2"。

然后一路下去,直到安装结束;此时,打开D盘下的Program Files文件夹,可以看到有一个名为Apache2的文件夹。
打开IE,然后在地址栏输入:"
http://localhost" 或者 "http://127.0.0.1" 可以看到Apache安装完成的成功页面;以后网页的存在位置就在 "D:Program FilesApache2htdocs" 目录。


PHP 5.2.0 的安装

1.到其官方站点下载 php-5.2.0-Win32.zip 并解压(在此不要下载及使用它的Installer,这种方式虽然很自动化、很智能,但也存在很多方面的限制,因为不推荐。)

2.将PHP文件解压到一个目录下,目录地址为 "D:Program Filesphp"。

首先,设置系统path目录,在path目录加上D:Program Filesphp,修改了path文件需要重新启动才能生效。
然后,修改apache配置文件httpd.conf,在其中搜索到LoadModule部分,在后面增加:




如果要增加mysql功能,那么首先需要安装mysql5,然后修改php.ini:
去掉extension=php_mysql.dll前面的“;”,然后修改extension_dir = "./ext",让php能够到ext目录去找php_mysql.dll,保存后,重启apache,再看phpinfo,其中就能搜索到mysql的配置情况了。

phpMyAdmin 2.9.2 的安装

<

Jakarta Struts结构移植过来的PHP开发框架,使用面向对象的开发结构和API,模拟了一个HTTP Servlet容器和使用了PHP服务页面引擎技术。

下载地址:http://mojavelinux.com/projects/studs/

文件结构如下:

如上图,WEB-INF中的文件都是Studs框架的核心文件(尤其是lib和tld下的文件),其中:

1.messages.properties文件:



welcome.title=Studs :: Welcome
welcome.heading
=Welcome to Studs!
welcome.message
=The application has been successfully installed!

pageviews.message
=This page has been viewed <strong>{0}</strong> times.

2.struts-config.xml文件:



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"
>
<!--
     This is a basic Studs/Struts configuration file with an example
     welcome action/page and other commented sample elements.
-->
<struts-config>

    
<!-- example configuration of a database connection
    <data-sources>
        <data-source type="horizon.sql.BasicDataSource">
            <set-property
                property="description"
                value="Primary data source for localhost database"/>
            <set-property
                property="driverClassName"
                value="horizon.sql.drivers.MySQLDriver"/>
            <set-property
                property="username"
                value="user"/>
            <set-property
                property="password"
                value="secret"/>
            <set-property
                property="url"
                value="mysql://localhost/dbname"/>
        </data-source>
    </data-sources>
    
-->

    
<form-beans>
        
<!-- sample form bean descriptor for an ActionForm
        <form-bean
            name="inputForm"
            type="app.InputForm"/>
        
-->
    
</form-beans>

    
<global-exceptions>
        
<!-- sample exception handler
        <exception
            key="expired.password"
            type="app.ExpiredPasswordException"
            path="/changePassword.jsp"/>
        
-->
    
</global-exceptions>

    
<global-forwards>
        
<!-- Default forward to "welcome" action -->
        
<forward name="welcome" path="/welcome.do"/>
    
</global-forwards>

    
<action-mappings>
        
<!-- Default "welcome" action -->
        
<action path="/welcome" forward="/pages/welcome.psp"/>
        
<action path="/example" forward="/pages/example.psp"/>

        
<!-- sample input and input submit actions

        <action
            path="/Input"
            type="org.apache.struts.actions.ForwardAction"
            parameter="/pages/Input.jsp"/>

        <action
            path="/InputSubmit"
            type="app.InputAction"
            name="inputForm"
            scope="request"
            validate="true"
            input="/pages/Input.jsp"/>

            <action
                path="/edit*"
                type="app.Edit{1}Action"
                name="inputForm"
                scope="request"
                validate="true"
                input="/pages/Edit{1}.jsp"/>

            
-->
    
</action-mappings>

    
<controller locale="false" inputForward="true"/>

    
<message-resources parameter="/WEB-INF/messages.properties"/>

</struts-config>

3.web.xml文件:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

    
<display-name>Studs Basic Application</display-name>
    
<description>A bare-bones foundation for creating a web application based on the Studs MVC Framework+</description>
    
<context-param>
        
<!-- if controlAllResources is set, all files should be handled by the stratus
             container, including all non-php/html files 
-->
        
<param-name>controlAllResources</param-name>
        
<param-value>false</param-value>
    
</context-param>

    
<!-- Servlet Definitions -->
    
<servlet>
        
<servlet-name>default</servlet-name>
        
<servlet-class>stratus.servlets.DefaultServlet</servlet-class>
        
<init-param>
            
<param-name>listings</param-name>
            
<param-value>true</param-value>
        
</init-param>
        
<load-on-startup>1</load-on-startup>
    
</servlet>
    
<servlet>
        
<servlet-name>phase</servlet-name>
        
<servlet-class>phase.servlet.PhaseServlet</servlet-class>
        
<init-param>
            
<param-name>scratchdir</param-name>
            
<param-value>/WEB-INF/work</param-value>
        
</init-param>
        
<init-param>
            
<param-name>tldresourcedir</param-name>
            
<param-value>/WEB-INF/tld</param-value>
        
</init-param>
        
<init-param>
            
<param-name>ignoreEL</param-name>
            
<param-value>false</param-value>
        
</init-param>
        
<load-on-startup>2</load-on-startup>
    
</servlet>
    
<servlet>
        
<servlet-name>action</servlet-name>
        
<servlet-class>studs.action.ActionServlet</servlet-class>
        
<init-param>
            
<param-name>config</param-name>
            
<param-value>/WEB-INF/struts-config.xml</param-value>
        
</init-param>
        
<init-param>
            
<param-name>validating</param-name>
            
<param-value>true</param-value>
        
</init-param>
        
<load-on-startup>3</load-on-startup>
    
</servlet>

    
<!-- Servlet Mappings -->
    
<servlet-mapping>
        
<servlet-name>default</servlet-name>
        
<url-pattern>/</url-pattern>
    
</servlet-mapping>
    
<servlet-mapping>
        
<servlet-name>phase</servlet-name>
        
<url-pattern>*.psp</url-pattern>
    
</servlet-mapping>
    
<servlet-mapping>
        
<servlet-name>action</servlet-name>
        
<url-pattern>*.do</url-pattern>
    
</servlet-mapping>

    
<!-- Mime Type Mappings -->
    
<mime-mapping>
        
<extension>html</extension>
        
<mime-type>text/html</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>css</extension>
        
<mime-type>text/css</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>js</extension>
        
<mime-type>text/javascript</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>png</extension>
        
<mime-type>image/png</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>jpg</extension>
        
<mime-type>image/jpeg</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>jpeg</extension>
        
<mime-type>image/jpeg</mime-type>
    
</mime-mapping>
    
<mime-mapping>
        
<extension>gif</extension>
        
<mime-type>image/gif</mime-type>
    
</mime-mapping>

    
<!-- Default Welcome File List -->
    
<welcome-file-list>
        
<welcome-file>index.psp</welcome-file>
    
</welcome-file-list>

</web-app>

4.文件build.xml:



<?xml version="1.0"?>
<project name="Studs Basic" basedir="../.." default="package">
    
<property file="../../build.properties" />

    
<target name="package" depends="prepare">
        
<mkdir dir="../../${release.dir}/${project.release.version}"/>
        
<tar destfile="../../${release.dir}/${project.release.version}/studs-basic-${project.release.version}.tar.gz" compression="gzip">
            
<tarfileset dir="." prefix="studs-basic" defaultexcludes="yes">
                
<exclude name="classes/build.xml"/>
                
<exclude name="**/TODO"/>
                
<exclude name="**/NOTES"/>
            
</tarfileset>
        
</tar>
    
</target>

    
<target name="clean">
        
<!-- make sure to break symlinks -->
        
<symlink action="delete" link="${basedir}/WEB-INF/lib" failonerror="no"/>
        
<symlink action="delete" link="${basedir}/WEB-INF/tld" failonerror="no"/>

        
<delete includeemptydirs="yes" failonerror="no">
            
<fileset dir="WEB-INF/work">
                
<include name="**"/>
            
</fileset>
            
<fileset dir="WEB-INF/lib">
                
<include name="**"/>
            
</fileset>
            
<fileset dir="WEB-INF/tld">
                
<include name="**"/>
            
</fileset>
        
</delete>
    
</target>

    
<target name="prepare" depends="clean">
        
<!-- create work directory -->
        
<mkdir dir="WEB-INF/work"/>
        
<chmod dir="WEB-INF/work" perm="0777" type="dir"/>
        
<!-- create lib directory and copy framework libraries -->
        
<mkdir dir="WEB-INF/lib"/>
        
<copy todir="WEB-INF/lib">
            
<fileset dir="../../src">
                
<include name="**"/>
            
</fileset>
        
</copy>
        
<!-- create tld directory and copy known tlds -->
        
<mkdir dir="WEB-INF/tld"/>
        
<copy todir="WEB-INF/tld">
            
<fileset dir="../../conf/tld">
                
<include name="*.tld"/>
            
</fileset>
        
</copy>
        
<!-- copy over the controller and server conf file -->
        
<copy todir=".">
            
<fileset dir="../../conf">
                
<include name="index.php"/>
                
<include name=".htaccess"/>
            
</fileset>
        
</copy>
    
</target>
</project>

5.logging.properties文件:



== Setup log appenders ==
#logging.rootLogger
=DEBUG, file
#logging.appender.file
=horizon.util.logging.FileLogAppender
#logging.appender.file.file
=/tmp/studs-basic.log
== Specific logging per category ==
#logging.logger.
[partial package or classname]=DEBUG

其他文件基本上都可以在框架源代码中找到。

页面文件如下:

1.index.php:



<?php
error_reporting(E_ALL);
ini_set(''include_path'', ''WEB-INF/lib'' . (DIRECTORY_SEPARATOR == ''/'' ? '':'' : '';''. ''WEB-INF/classes'');
umask(0002);

require_once ''horizon/init.php'';

import(
''stratus.connector.HttpProcessor'');
import(
''stratus.config.ContextConfig'');

$config = & new ContextConfig(dirname(__FILE__));
$processor = & new HttpProcessor($config->getContext());
$processor->run();
?>

2.index.psp:



<%@ page language="php" %>
<%@ taglib uri="/WEB-INF/tld/phase-core.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/studs-html.tld" prefix="html" %>
<c:redirect context="/"><html:rewrite forward="welcome"/></c:redirect>

3.welcome.psp:



<%@ page language="php" %>
<%@ taglib uri="/WEB-INF/tld/phase-core.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/phase-fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/studs-html.tld" prefix="html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml">
    
<head>
        
<title><fmt:message key="welcome.title" /></title>
        
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    
</head>
    
<body>
        
<h3><fmt:message key="welcome.heading" /></h3>
        
<p><fmt:message key="welcome.message" /></p>
        
<p><html:link action="/example">Click here</html:link> for an example of the template tag library.</p>
        
<c:set var="welcomePageViewCount" value="${applicationScope.welcomePageViewCount + 1}" scope="application"/>
        
<style="font-size: small;"><fmt:message key="pageviews.message" arg0="${applicationScope.welcomePageViewCount}"/></p>
    
</body>
</html>

4.example.psp:



<%@ taglib uri="/WEB-INF/tld/studs-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/tld/phase-string.tld" prefix="str" %>
<%@ taglib uri="/WEB-INF/tld/phase-core.tld" prefix="c" %>
<template:insert template="/pages/tmpl/template.psp">
    
<template:put name="title" content="Studs :: Template Taglib Example" direct="true"/>
    
<template:put name="heading" direct="true">Template Taglib Example</template:put>
    
<template:put name="intro" direct="true">
This page demonstrates the use of the studs template taglib.  Content is inserted by the parent page either directly or via an include file.  Below are two examples of content insertion.
    
</template:put>
    
<template:put name="content" direct="true">
<str:replace replace="LF" with="&lt;br /&gt;">This text was specified inline using the template:put tag.

It also uses the str:replace taglib to convert endlines to BR tags.

I am also testing the conditional EL syntax.  
<strong>${2 % 2 ? ''odd'' : ''even''}</strong></str:replace>
    
</template:put>
    
<template:put name="content2" content="/pages/tmpl/content.psp" />
</template:insert>

5.template.psp:



<%@ taglib uri="/WEB-INF/tld/studs-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/studs-template.tld" prefix="template" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
<head>
        
<title><template:get name="title" /></title>
    
</head>
    
<body>
        
<h3><template:get name="heading" /></h3>
        
<p><template:get name="intro" /></p>
        
<style="border: 1px dashed #999999; background-color: #F0F0F0;">
        
<template:get name="content" />
        
</p>
        
<style="border: 1px dashed #999999; background-color: #F0F0F0;">
        
<template:get name="content2" />
        
</p>
        
<p>&laquo; <html:link forward="welcome">Back</html:link></p>
    
</body>
</html>

6.content.psp:



This text comes from an include file using the template:put tag.

这样,一个基于PHP Studs框架的示例程序就完成了。(注:上诉代码取自studs自带的例子)






对于已经熟悉Apache+PHP+MYSQL的安装配置的开发人员,或者是不想涉及开发而只是想建立PHP应用程序的人来说,使用Apache/PHP/MYSQL安装套件来配置PHP的WEB环境会方便不少,但是选择合适的套件还是需要的。个人把曾经使用过的,以及比较知名的安装套件总结如下:


WAMP
一直在用的,带有phpMyAdmin和SQLiteManager ,提供了很多Add-on插件,如PHP版本切换、ZEND OPTIMIZER 、WEBALIZER等,站长推荐!
http://www.wampserver.com/

TSW
比较完整,支持PERL,FTPServer,还提供有Tomcat和wordpress插件
http://sourceforge.net/projects/yawamp/

GREENAMP
国产的套件,无删除功能
http://chin.blogchina.com

VertrigoServ
内置了ZendOptimizer
http://vertrigo.sourceforge.net/

XAMP
很不错,提供了丰富的插件,如perl、python、tomcat和cocoon
http://www.apachefriends.org/de/xampp-windows.html

WAPM
国产的,支持Tomcat和Turck MMCahe、ZendOptimizer
http://w.yi.org/

Appserv
也整合了Zend Optimizer
http://www.appservnetwork.com/

Apache2Triad
包含了Perl , Python
http://apache2triad.sourceforge.net

EasyPHP
安装比较简单
http://www.easyphp.org/

LiteWeb 支持Perl和虚拟域名
http://www.cmfperception.com/liteweb.html

phpHome
http://phphome.sourceforge.net/

http://phpnow.org/download.html




不包括抓图片

<?
 $buffer = file("address"); //$address 网页地址
 for($i = 0;i < sizeof($buffer);$i++)
 {
  //去yahoo广告
  $buffer[$i] = str_replace(''<!----- ad start ----->'',''<noscrīpt>''  $buffer[$i]);
  $buffer[$i] = str_replace(''<!----- ad end ----->'',''</noscrīpt>''  $buffer[$i]);
 
  //最后显示
  echo($buffer);
 }
 
?>

str_replace 3个参数 ,第一个是原文件的内容,第二个是替换成的内容.最后一个是写入的地方.

$buffer能取得整个html页面的文本档,成为一个数组,每行一个元素,简单的说就是逐行寻找替换.

替换后输出.

同样的可以把烂掉的无法显示的页面 例如成为 http://localhost/images/a.jpg 这样的替换成对应网址.

替换前查看下原HTML档对比下就行.


先用document.cookie方法把js变量写入cookie中,再用PHP取出。

<scrīpt>  

   1. var name="myqq",value="10000";  
   2. document.cookie=name+"="+value+";"  

</scrīpt> 

<?php  

echo $_COOKIE["myqq"]."<br/>";  

$my="我的QQ是".$_COOKIE["myqq"];  

echo $my;  

?> 

[!--infotagslink--]

相关文章

  • 分享一段php获取linux服务器状态的代码

    简单的php获取linux服务器状态的代码,不多说-直接上函数:复制代码 代码如下:function get_used_status(){ $fp = popen('top -b -n 2 | grep -E "^(Cpu|Mem|Tasks)"',"r");//获取某一时刻系统cpu和内存使用情况 $rs =...2014-05-31
  • Springboot+TCP监听服务器搭建过程图解

    这篇文章主要介绍了Springboot+TCP监听服务器搭建过程,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-10-28
  • 服务器 UDP端口占用几千个的解决办法

    前一段时间使用NetStat命令查看服务器端口时,发现服务器udp端口开放了好多,最少在1000个以上,当时事情比较多,没有管它,今天终于有点时间,仔细检查了一下,排除了这个问题. ...2016-01-27
  • PHP连接公司内部服务器的MYSQL数据库的简单实例

    “主机,用户名,密码”得到连接、“数据库,sql,连接”得到结果,最后是结果的处理显示。当然,数据库连接是扩展库为我们完成的,我们能做的仅仅是处理结果而已。...2013-09-29
  • 解决HttpPost+json请求---服务器中文乱码及其他问题

    这篇文章主要介绍了解决HttpPost+json请求---服务器中文乱码及其他问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-01-22
  • Hyper-V尝试连接到服务器出错无效类的解决方法

    这篇文章主要介绍了Hyper-V尝试连接到服务器出错无效类的解决方法,需要的朋友可以参考下...2016-09-28
  • mac使用Shell(终端)SSH连接远程服务器的方法

    这篇文章主要介绍了mac使用Shell(终端)SSH连接远程服务器的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-07-11
  • js实现上传图片到服务器

    这篇文章主要为大家详细介绍了js实现上传图片到服务器,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-04-11
  • uploader秒传图片到服务器完整代码

    这篇文章主要为大家详细介绍了uploader秒传图片到服务器的完整代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2017-04-27
  • c# HttpWebRequest通过代理服务器抓取网页内容应用介绍

    在C#项目开发过程中可能会有些特殊的需求比如:用HttpWebRequest通过代理服务器验证后抓取网页内容,要想实现此方法并不容易,本文整理了一下,有需求的朋友可以参考下...2020-06-25
  • 使用maven的profile构建不同环境配置的方法

    这篇文章主要介绍了使用maven的profile构建不同环境配置的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-26
  • 图文详解本地Windows 7/8上IIS服务器搭建教程

    这篇文章主要以图文结合的方式详细介绍了本地Windows 78上IIS服务器搭建教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 ...2017-07-06
  • Linux环境下nginx搭建简易图片服务器

    这篇文章主要介绍了Linux环境下nginx搭建简易图片服务器,需要的朋友可以参考下...2016-01-27
  • Windows 2016 服务器安全设置

    最近公司的网站升级Windows 2016服务器,选择安装了最新版的Windows 2016,以前使用Windows服务器还是Windows 2003系统,发现变化还是挺多的,依次记录下来以备后面查阅...2020-10-05
  • 使用node-media-server搭建一个简易的流媒体服务器

    这篇文章主要介绍了使用node-media-server搭建一个简易的流媒体服务器,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-20
  • 阿里云免费套餐再次升级: 含云服务器、云数据库等35+产品

    阿里云免费套餐再次升级,提供更多产品,更久时长的使用,本次活动针对个人用户和企业用户,不过仅限新用户申请,想要了解更多,下面就来简单地了解一下活动规则 阿里云免费...2017-07-06
  • ECMall支持SSL连接邮件服务器的配置方法详解

    首先,主要是ecmall使用的phpmailer版本太低,不支持加密连接。然后,得对相应代码做一定调整。1. 覆盖phpmailer请从附件进行下载: 复制代码 代码如下:http://cywl.jb51.net:81/201405/yuanma/ecmall_phpmailer_lib(jb51.n...2014-05-31
  • golang DNS服务器的简单实现操作

    这篇文章主要介绍了golang DNS服务器的简单实现操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-05-01
  • C#如何连接服务器共享文件夹

    这篇文章主要为大家详细介绍了C#如何连接服务器共享文件夹,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-06-25
  • 服务器绝对安全简要设置策略操作指南第1/2页

    偶这里是针对的WIN平台,现在的站长大部分都用WIN2003,相信没几个站长用低版本儿的操作系统的!...2016-01-27