
在linux系統下,上傳php網頁到伺服器,可以透過ftp的相關指令上傳。
建立FTP連線
要開啟與遠端系統的ftp連接,請使用ftp指令後跟遠端伺服器IP位址或網域名稱:
1 、 若建立連接,將顯示確認訊息,系統將提示您輸入FTP使用者名,在此範例中,FTP使用者名稱為linuxidc:
1 2 3 4 5 6 7 8 | 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 login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (192.168.42.77:localuser): linuxidc
You may see a different confirmation message depending on the FTP service running on the remote server.
|
登入後複製
2、 輸入使用者名稱後,系統將提示您輸入密碼:
如果密碼正確,遠端伺服器將顯示確認訊息和ftp>提示。
1 2 3 4 | 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指令
1 2 3 4 5 6 7 8 9 10 11 | help或?- 列出所有可用的FTP命令。
cd - 更改远程计算机上的目录。
lcd - 更改本地计算机上的目录。
ls - 列出当前远程目录中的文件和目录的名称。
mkdir - 在当前远程目录中创建一个新目录。
pwd - 打印远程计算机上的当前工作目录。
delete - 删除当前远程目录中的文件。
rmdir - 删除当前远程目录中的目录。
get - 将一个文件从远程复制到本地计算机。
mget - 将多个文件从远程复制到本地计算机。
put - 将一个文件从本地复制到远程计算机。mput - 将一个文件从本地复制到远程计算机。
|
登入後複製
使用FTP指令上載檔案
要將檔案從本機目錄載到遠端FTP伺服器,請使用以下put指令:
輸出應該如下所示:
1 2 3 4 5 | 200 PORT command successful
150 Connecting to port 34583
226-File successfully transferred
226 0.849 seconds (measured here), 111.48 Kbytes per second
96936 bytes sent in 0.421 seconds (225 kbytes/s)
|
登入後複製
如果要上載不在目前工作目錄中的文件,請使用該文件的絕對路徑 。
要將多個檔案從本機目錄上載到遠端FTP伺服器,請使用下列mput指令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | mput image1.jpg image2.jpg
mput image1.jpg? y
200 PORT command successful
150 Connecting to port 41075
226-File successfully transferred
226 1.439 seconds (measured here), 102.89 Kbytes per second
151586 bytes sent in 1.07 seconds (138 kbytes/s)
mput image2.jpg? y
200 PORT command successful
150 Connecting to port 40759
226-File successfully transferred
226 1.727 seconds (measured here), 111.75 Kbytes per second
197565 bytes sent in 1.39 seconds (138 kbytes/s)
|
登入後複製
上傳多個檔案時,系統會提示您確認要上傳的每個文件。
完成上傳檔案到遠端FTP伺服器後,用bye或關閉連接quit。
更多PHP相關知識,請造訪PHP中文網!
以上是linux中如何上傳php網頁的詳細內容。更多資訊請關注PHP中文網其他相關文章!