Use nat to build virtual machine web (lnmp) servers + svn servers

Source: Internet
Author: User
Tags nameserver

 

Requirement: use nat in centos to build the nginx + php + mysql + phpmyadmin + svn service and access it through a local browser.

Start now:

I. Set the virtual machine to nat

2. Enable centos to connect to the Internet through nat

#1. Modify the/etc/sysconfig/network-scripts/ifcfg-eth0 configuration file

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE = eth0

IPADDR = 192.168.247.138

HWADDR = 00: 0C: 29: 9F: C7: EF

ONBOOT = yes

NETMASK = 255.255.255.0

GATEWAY = 192.168.247.2

How to set the gateway here:

Choose VMware Edit> Virtual Network Editor> VMnet8> NAT Settings, as shown below:

 

Set the gateway as above.

 

 

#2. Add DNS domain name resolution

Vi/etc/resolv. conf. My settings are as follows:

Nameserver 202.119.160.11

Nameserver 202.119.160.12

If you do not know how to set it, you can view your local DNS.

Some people may say that my IP address and DNS are automatically obtained. What should I do ???

For me (win 7), open the network and sharing center, view the active network, and click Local Connection> details to view the DNS.

Alternatively, open cmd and enter ipconfig-all to view your local connection information and you will be able to see the DNS.

 

#3: restart the network service

Service network restart

Test whether to connect to the Internet and ping www.baidu.com. If there is a response, continue. If the ping is different, check why.

 

3. Install nginx + php + mysql + phpmyadmin

Download the installation package from the http://lnmp.org, What I download is, lnmp0.7-full.tar.gz

#1. Decompress tar xzvf lnmp0.7-full.tar.gz

Go to the directory: cd lnmp0.7-full

Modify: vi centos. sh

Locate yum-y update. Add the # sign in front of this line and comment it out. (This is used for system upgrade, not required)

Run: sh centos. sh

Then wait until the installation is complete.

 

4. Access the Virtual Machine web server through the local machine.

#1: solution to linux problems:

1.1

Iptables-F

Iptables-p input accept (set the default rule)

 

1.2 set the linux Firewall

 

1.2.1 Add in/etc/sysconfig/iptables

-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT

In this way, access to port 80 is allowed.

 

1.2.2 add web services to Trusted Services in linux

System-> Management-> Security Level and firewall-> firewall option-> check www (http)

 

#2: VMware problem: whether there is a problem with port ing

 

2.1 set VMware and port ing

 

Yes. To enable Port 80, add a ing in Edit-> Virtual Network Editor-> VMnet8-> NAT Settings-> Port Forwarding of VMware.

Host port: 80, virtual machine IP address: 192.168.247.138, Port: 80

 

Open the local browser and enter 192.168.247.138. If the prompt-> congratulations, the one-click installation package of LNMP is successfully installed..., congratulations.

If not, Disable windows Firewall.

 

V. Install svn

If you have installed apache, read this blog: http://www.bkjia.com/ OS /201112/113047.html

 

If you do not want to rely on apache and want to install an independent svn server, continue.

 

 

#1. Download related software

Wget http://subversion.tigris.org/downloads/subversion-1.6.1.tar.gz

Wget http://subversion.tigris.org/downloads/subversion-deps-1.6.1.tar.gz

#2. decompress the package (note: the download must be in the same directory)

 

Tar-zxvf subversion-1.6.1.tar.gz

 

Tar-zxvf subversion-deps-1.6.1.tar.gz

 

#3. Compilation and installation:

Cd subversion-1.6.1

 

./Configure -- prefix =/usr/local/svn/(-- prefix: the installation path of svn)

 

Make & make install

 

#4. Add svn-related commands to environment variables:

 

Echo "export PATH = $ PATH:/usr/local/svn/bin/">/etc/profile

 

Source/etc/profile (the source command is usually used to re-execute the modified initialization file to make it take effect immediately without logging out and logging on again)

 

How to change the/etc/profile file to take effect immediately

Method 1:./etc/profile (Note:. and/etc/profile have spaces)

Method 2: source/etc/profile

 

#5. Create a test warehouse:

 

1. Create the SVN root directory, which is specified when svn is started:

 

Mkdir-p/opt/svn/

 

2. Create a test warehouse:

 

Mkdir-p/opt/svn/svntest/

 

Svnadmin create/opt/svn/svntest/

 

3. modify the configuration file:

 

Cd/opt/svn/svntest/conf/

There are three configuration files in conf.

 

3.1 modify the configuration file

Vi svnserve. conf (remove the # Before the following statement. Note that there is no space at the beginning of the line)

[General]

Anon-access = none

Auth-access = write

Password-db = passwd (the file storing the password is the passwd file in the current directory)

Authz-db = authz (the user's files are stored in the current directory)

Realm = svntest

 

3.2 Add User Permissions

 

Format:

Version library directory format:

 

[<Version library>:/project/directory]

 

@ <User group name >=< permission>

 

<User name >=< permission>

 

Vi authz

 

[Svntest:/]

 

Yhb = rw

 

 

Explanation:/indicates the root directory, which is specified when svnserve is started.

Permission: r, w, and null. null indicates no permission

For example, [svntest:/a]-> indicates setting permissions for directory a under svntest

 

 

3.3 Add a user and password

 

Format:

[Users]

 

<User 1 >=< password 1>

 

<User 2 >=< password 2>

 

 

Vi passwd

 

[Users]

Yhb = admin

 

 

#6. Start svn

 

Svnserve-d -- listen-port 9999-r/opt/svn/svntest

 

Where:

 

-D Indicates running in daemon mode (running in the background)

 

-- Listen-port 9999 indicates that port 9999 is used, which can be replaced with the port you need. Note that the root permission is required to use ports lower than 1024.

 

-R/opt/svn/svndata specifies that the root directory is/opt/svn/svntest

 

Check:

 

Ps-ef | grep svnserve

 

If the following information is displayed, the instance is successfully started:

 

Root 15908 1 0 21:50? 00:00:00 svnserve-d -- listen-port 9999-r/opt/svn

 

Check whether data can be imported or exported:

I will import all the content in the folder tcpip to svntest.

 


 

Prompt to add information ---

 

 

Create a new cc folder and enter the cc directory. svntest is checked out. Success !!!!

 

 

From yihaibobb's column

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.