Network card NAT mode virtual machine installation ft service

Source: Internet
Author: User
Tags ftp connection ftp client oracle vm virtualbox vm virtualbox

Install the Oracle VM VirtualBox virtual machine under WINDOWS8, install the CentOS operating system in the virtual machine, build LNMP environment in CentOS, install VSFTPD server, host in Phpstorm program, upload code FTP to virtual machine, In the host browser, enter the address to access the PHP code page in the virtual machine. The virtual machine network uses the bridge to be convenient, but after the host enters the company office network, the FTP has the problem, therefore uses the network to use the NAT mode instead. NAT Virtual machine IP address 10.0.2.15.

The installation process is divided into three steps,

1 , install VSFTPD server in CentOS, configure and install FTP client, can use FTP client to access VSFTPD server;

2 to access the FTP server in the virtual machine via Web pages in the host computer;

3 , configure the FTP server in the host Phpstorm, can connect the FTP server in the virtual machine, upload the code to the FTP server in the virtual machine;

1 , in CentOS installation vsftpd server, Configured, and then installed FTP client, you can use FTP Client Access vsftpd server;

1.1 , execute the following command as Administrator (root) to install the FTP server-side

Yum Install vsftpd

1.2, Set boot vsftpd FTP service

Chkconfig vsftpd on

1.3, start the VSFTPD service

Service VSFTPD Start

1.4 , install the FTP client

Yum Install FTP

1.5 , add users to FTP

/usr/sbin/adduser-d/opt/ftp1-g ftp-s/sbin/nologin FTP1

1.6 , set the password for the FTP1 user

passwd FTP1

You can enter a new password

1.7. Test whether the VSFTP is installed successfully

FTP 10.0.2.15

User name

Password

The display succeeds, indicating that the VSFTPD installation was successful. (errors sometimes occur and need to go to vsftpd.conf disable Default user logon

Vim/etc/vsftpd/vsftpd.conf

anonymous_enable = YES modified to anonymous_enable = NO

Restart VSFTPD Services, service vsftpd restart

)。

2 to access the FTP server in the virtual machine via Web pages in the host computer;

Because the virtual machine chooses the NAT network mode, the virtual machine can access the host, the host cannot access the virtual machine, needs to configure the interface transformation in the NAT, the FTP corresponds 20, 212 interfaces, needs the NAT configuration two times, for example

127.0.0.10     2020         10.0.2.15   20127.0.0.10     2021         10.0.2.15   21

In the host browser input ftp://127.0.0.10:2021, will pop-up input user name, password window, input and display errors. At this time through the FTP understanding, know that the FTP connection is divided into two processes: the client connects to the server 21 port, authentication user is legitimate, after authentication passed; the server sends the data from the root directory to the client via 20 port. We can log in and we can't display server-side data. Description 20 There is a problem with the interface. Set the FTP mode to PASV passive mode and set the new interface.

2.1, write the passive mode interface in vsftpd.conf,

pasv_min_port=2017pasv_max_port=2020

Note there cannot be spaces around the equals sign.

2.2, under the FTP command, set the mode to PASV. Enter passive to make the Por and PASV modes switch.

2.3, adjust the interface under NAT

, LNMP and SSH are configuration pages to access the virtual machine code, and SSH connection to the virtual machine, which is not considered here.

2.4, in the host browser input ftp://127.0.0.10:2021, will pop up the input user name, password window, input and display the root directory content;

3 , configure the FTP server in the host Phpstorm, you can connect the FTP server in the virtual machine; Upload code to the FTP server in the virtual machine

3.1, in Phpstorm configuration FTP, click Advanced Options Select Passive mode;

3.2,mapping needs to be configured under

3.3, test FTP is connected, click Test FTP connection testing is connected, if the web link, here will be the basic unicom. 3.4, upload the code to the virtual machine via Phpstorm,Hint error: "[2015/9/23 1:41] Failed to transfer file ' F:\ftp1\blog\test.php ': cant open output connection for file" Ftp://www.lh Ycentos.com:2021/blog/test.php ". Reason: "553 Could not create file.", the FTP configuration file needs to be configured.

3.4.1, make sure the/OPT/FTP1 directory corresponds to FTP1 user rights is 755 or 777, if not modified;

3.4.2, use the command getsebool-a|grep FTP to see if Ftpd_disable_trans Ftp_home_dir allow_ftpd_full_access is on. If you do not need to modify.

The first modification Setsebool Ftpd_disable_trans 1, this time will be wrong, it seems to find no setsebool ftpd_disable_trans; directly modify Setsebool Ftp_home_dir 1, as long as Ftp_ Home_dir Modify success, you do not have to tube ftpd_disable_trans. The third modification Setsebool allow_ftpd_full_access 1. The host can then upload the code to the virtual machine. However, this modification is only temporary, the shutdown of the virtual machine after restarting the failure, each boot needs to be modified very cumbersome, so there is a way to directly shut down SELinux, and then restart.

(

Vi/etc/selinux/config

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

Selinux=disabled #增加

: Wq #保存, close.

Shutdown-r now #重启系统

To view the status of SELinux:

Getenforce

)

Network card NAT mode virtual machine installation ft service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.