首页 > 编程技术 > php

Linux与Windows喜结连理

发布时间:2016-11-25 15:17

作为一个新生事物,Linux吸引了不少眼球,但是它能否快捷、方便地与Windows资源共享,是一个很重要的问题。大家知道,Windows之间可以利用“网络邻居”来实现资源共享,而Linux之间可以使用NFS来实现资源共享。那么,Linux与Windows之间呢?
Linux可以通过Samba来实现和Windows主机互通有无的。Samba采用Client/Server架构,执行Samba客户端程序,就可以访问Windows主机上的共享资源;而运行Samba服务器,Windows主机就可以访问Linux上的共享资源。下面以Red Hat 8.0为例,介绍在Linux环境里如何访问Windows共享资源。
  安装Samba
  如果不能确定是否已经安装了Samba软件包,可以在终端窗口执行以下命令进行查询:
$ rpm -qa | grep samba
  如果查询结果出现如图1所示的三个软件包,则表示已经安装Samba软件包。

  图一:查询是否安装Samba软件包
  如果没有安装过Samba软件包,则可以插入Red Hat 8.0第二张安装光盘,然后按照下面的步骤进行安装(以KDE环境为例):
  1. 鼠标依次单击主选单→系统设置→“软件包”选单项,将会打开“软件包管理”对话框。
  2. 在该对话框里找到“Windows文件服务器”,确保已经勾选该选项,然后单击对话框底部的“更新”按钮,如图2所示。
  3. 安装Samba软件包。

  图三:安装Samba软件包
  整个过程非常简单,系统会自动检测软件包之间的依赖性,完全不用操心。
  用命令方式访问Windows
  安装好Samba之后,就可以让它大显身手了。这里先介绍如何用字符命令方式访问Windows共享资源。
  1. 查询Windows主机的共享资源
  查询Windows主机的共享资源可以使用smbclient -L WindowsHostName命令。例如,要查询一台名为Peter的Windows主机上的共享资源,可以在终端窗口输入:
smbclient -L Peter
  然后回车即可。该命令的具体使用方法如图3所示。该命令可以准确地检查出Windows主机的共享文件夹,并且对中文文件名的支持也很好。

  图三:查询Windows主机的共享资源
  2. 连接Windows主机的共享目录
  我们可以使用“smbclient //WindowsHostName/ShareName”命令,连接Windows主机上的某个共享文件夹。如果该共享文件夹需要用户名和密码,则可以使用“smbclient //WindowsHostName/ShareName -U UserName”命令。例如,要连接Windows主机Peter上的共享目录Share,可以在终端窗口输入:
 PHP是一种领先于ASP的技术。与ASP相比,它具有速度快、稳定性高、跨平台、易学习等优点。ASP学习者使用的OS几乎都是Windows平台,上面无疑都装有IIS。PHP所需求的服务器支持主要是由Apache提供的。事实上,IIS也可以提供这样的支持,具体步骤如下:
    1.    下载PHP。推荐网址:http://www.onlinedown.net/soft/1774.htm    下载后解压到一个文件夹里,推荐解压:C:php 里。以下都将使用这一文件夹描述。
    2.    将C:php里的dlls文件夹里的所有文件复制并粘贴到C:winnt ystem32里。再将C:php下的php4ts.dll复制到C:winnt ystem32下。
    3.    用记事本打开C:php下的php.ini-dist文件。找到如下一行:extension_dir = "./" 将其改为 extension_dir = C:php 将其保存到C:winnt ystem32下,注意:名为php.ini
    4.    首先打开控制面板-〉管理工具-〉internet服务管理器-〉展开左边的目录树-〉默认web站点-〉点击右键-〉属性-〉isapi筛选器->添加->筛选器名称:php;可执行文件:C:php apiphp4isapi.dll 然后再打开默认web站点属性面板下的主目录-〉配置-〉添加-〉可执行文件:C:php apiphp4isapi.dll;扩展名:php。
好了,大功告成了!

<Location> directive
Syntax: <Location URL> ... </Location>
Context: server config, virtual host
Status: core
Compatibility: Location is only available in Apache 1.1 and later.
The <Location> directive provides for access control by URL. It is similar to the <Directory> directive, and starts a subsection which is terminated with a </Location> directive. <Location> sections are processed in the order they appear in the configuration file, after the <Directory> sections and .htaccess files are read, and after the <Files> sections.
Note that URLs do not have to line up with the filesystem at all, it should be emphasized that <Location> operates completely outside the filesystem.
For all origin (non-proxy) requests, the URL to be matched is of the form /path/, and you should not include any http://servername prefix. For proxy requests, the URL to be matched is of the form scheme://servername/path, and you must include the prefix.
The URL may use wildcards In a wild-card string, `?' matches any single character, and `*' matches any sequences of characters.
Apache 1.2 and above: Extended regular expressions can also be used, with the addition of the ~ character. For example:
     <Location ~ "/(extra|special)/data">
would match URLs that contained the substring "/extra/data" or "/special/data". In Apache 1.3 and above, a new directive <LocationMatch> exists which behaves identical to the regex version of <Location>.
The Location functionality is especially useful when combined with the SetHandler directive. For example, to enable status requests, but allow them only from browsers at foo.com, you might use:
    <Location /status>
    SetHandler server-status
    order deny,allow
    deny from all
先安装mysql,用winzip8.0打开软件包进行完全安装,默认安装路径为:c:mysql;
    安装完成后,打开“开始”按钮中的“运行”,输入命令:C:mysqlinmysqld-nt.exe --install,并执行;
    打开“开始”按钮下的“程序”=》“管理工具”=》“服务”,找到“mysql”服务,启动它;
    至此,mysql安装完成,重启win2000adanced server。您还可以打开C:mysqlinwinmysqladmin.exe,在第一次用它时,需要建立管理员名及密码,我分别设置为root和(yourpassword)。关闭它后,程序自动在状态行下建立一个“红绿灯”的小图标。
    
    现在开始安装php4,将软件包先用winzip解压到c:php4下,再将目录下的所有dll文件拷到c;winntsystem32下,不要覆盖已有的dll文件;接着将目录下的php.exe和php.ini-dist两个文件拷到c:winnt下;
    将c:winntphp.ini-dist改名为php.ini,并打开它,找到;Windows Extensions,将extension=php_calendar.dll、extension=php_zlib.dll、extension=php_ldap.dll前的“;”去掉,关闭该文件。
    打开“开始”按钮下的“程序”=》“管理工具”=》“internet服务管理器”,选中“默认web站点”,打开它的“属性”窗口。在“web站点”页下,改变“IP地址”:“全部未分配”为“(您机子的ip地址,例如:202.195.243.131)”;“TCP端口”为“80”。
    
    接着,选中“主目录”页,单击“应用程序设置”下的“配置”按钮后,在新窗口下单击“添加”按钮;在“可执行文件”中输入“C:WINNTphp.exe     %s %s”,在“扩展名”中输入“.php”,点击“确定”。
    接着,选中“ISAPI筛选器”页,单击“添加”按钮;在“筛选器名称”中输入“php”,在“可执行文件”中输入“C:WINNTsystem32php4isapi.dll”,点击“确定”。
    接着,选中“文档”页,单击“添加”按钮;在“默认文档名”中输入“index.php”,点击“确定”,并将其提高到最高级。您还可以添加常用的php文件名,如:“default.phtml”、“index.php3”等。
    关闭所有窗口,重启系统后,可打开IE浏览器进行测试。

Win32下Apache 2.0.35 php 4.2.0安装扎记
1、安装界面比较有好,分别添入ServerAdmin、ServerName、post即可
     如果你起用了DNS,会将DNS的设置作为默认配置,这点要注意。
     当可见到默认主页时表明安装成功,一般没有问题
2、默认的主页位置在[d]:/Program Files/Apache Group/Ahache2/htdocs
     若需要修改可在httph.conf文件中修改(下同)
     DucumentRoot "你的主页位置"
     请同时修改
     <Directory "你的主页位置">
     如需要配置用户主页,可修改
     UserDir "用户主页集位置"
     访问时用http://ServerName:post/~用户目录名
3、设定默认页面名
     将
     DirectoryIndex index.html index.html.var
     改为
     DirectoryIndex index.php index.html index.html.var
4、将
     AddDefaultCharset ISO-8859-1
     改为
     AddDefaultCharset GB2312
     以使输出页面的默认字符集为 gb2312,可防止出现乱码
5、在尾部添上(注意apache2filter.dll的真实路径)
     LoadModule php4_module c:/php/experimental/apache2filter.dll
     AddOutputFilter PHP .php
     AddInputFilter PHP .php
     AddType text/html .php
6、php4.2.0的安装与低版本相同
     到此,大功告成,你可以享受Apache 2.0了

标签:[!--infotagslink--]

您可能感兴趣的文章: