在linux系统下,上传php网页到服务器,可以通过ftp的相关命令上传。
建立ftp连接
要打开与远程系统的ftp连接,请使用ftp命令后跟远程服务器ip地址或域名:
ftp 192.168.42.77
1、 如果建立连接,将显示确认消息,系统将提示您输入ftp用户名,在此示例中,ftp用户名为linuxidc:
220---------- welcome to pure-ftpd [privsep] [tls] ----------220-you are user number 1 of 50 allowed.220-local time is now 21:35\. server port: 21.220-this is a private system - no anonymous login220-ipv6 connections are also welcome on this server.220 you will be disconnected after 15 minutes of inactivity.name (192.168.42.77:localuser): linuxidcyou may see a different confirmation message depending on the ftp service running on the remote server.
2、 输入用户名后,系统将提示您输入密码:
password:
如果密码正确,远程服务器将显示确认消息和ftp>提示。
230 ok. current restricted directory is /remote system type is unix.using binary mode to transfer files.ftp>
如果您访问的ftp服务器接受匿名ftp帐户,并且您想以匿名用户anonymous身份登录,请使用用户名和电子邮件地址作为密码。
常用ftp命令
许多ftp命令与您在linux shell提示符中键入的命令类似或相同。
以下是一些最常见的ftp命令
help或?- 列出所有可用的ftp命令。cd - 更改远程计算机上的目录。lcd - 更改本地计算机上的目录。ls - 列出当前远程目录中的文件和目录的名称。mkdir - 在当前远程目录中创建一个新目录。pwd - 打印远程计算机上的当前工作目录。delete - 删除当前远程目录中的文件。rmdir- 删除当前远程目录中的目录。get - 将一个文件从远程复制到本地计算机。mget - 将多个文件从远程复制到本地计算机。put - 将一个文件从本地复制到远程计算机。mput - 将一个文件从本地复制到远程计算机。
使用ftp命令上载文件
要将文件从本地目录上载到远程ftp服务器,请使用以下put命令:
put index.php
输出应该如下所示:
200 port command successful150 connecting to port 34583226-file successfully transferred226 0.849 seconds (measured here), 111.48 kbytes per second96936 bytes sent in 0.421 seconds (225 kbytes/s)
如果要上载不在当前工作目录中的文件,请使用该文件的绝对路径。
要将多个文件从本地目录上载到远程ftp服务器,请使用以下mput命令:
mput image1.jpg image2.jpgmput image1.jpg? y200 port command successful150 connecting to port 41075226-file successfully transferred226 1.439 seconds (measured here), 102.89 kbytes per second151586 bytes sent in 1.07 seconds (138 kbytes/s)mput image2.jpg? y200 port command successful150 connecting to port 40759226-file successfully transferred226 1.727 seconds (measured here), 111.75 kbytes per second197565 bytes sent in 1.39 seconds (138 kbytes/s)
上传多个文件时,系统将提示您确认要上传的每个文件。
完成上传文件到远程ftp服务器后,用bye或关闭连接quit。
更多php相关知识,请访问!
以上就是linux中如何上传php网页的详细内容。
