LAMP + Proftpd + data migration, lampproftpd

Source: Internet
Author: User

LAMP + Proftpd + data migration, lampproftpd

 
On Centos 6.5 64bit minimal

Install mysql

[Root @ ftp ~] # Yum install-y mysql-server mysql-devel -- Installation
[Root @ ftp ~] #/Etc/init. d/mysqld start -- start
[Root @ ftp ~] #/Usr/bin/mysql_secure_installation -- Initialization
[Root @ ftp ~] # Chkconfig -- levels 235 mysqld on -- 235level startup
[Root @ ftp ~] # Chkconfig -- list | grep mysqld -- look
Mysqld 0: off 1: off 2: on 3: on 4: off 5: on 6: off

Install apache
[Root @ ftp ~] # Yum install-y httpd -- install
[Root @ ftp ~] #/Etc/init. d/httpd start -- start
Starting httpd: cocould not reliably determine the server's fully qualified domain name ...... -- in/etc/httpd/conf/httpd. add "ServerName localhost: 80" to the conf file or resolve the local domain name.
[Root @ ftp ~] # Chkconfig -- levels 235 httpd on -- start
[Root @ ftp ~] # Chkconfig -- list | grep httpd -- look
Httpd 0: off 1: off 2: on 3: on 4: off 5: on 6: off
[Root @ ftp html] # pwd
/Var/www/html -- this is the www root directory

Install PHP
[Root @ ftp ~] # Yum install-y php -- install
[Root @ ftp ~] # Yum install-y php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc -- mysql Association
[Root @ ftp ~] # Service httpd restart -- restart the httpd service to make php take effect and verify that php is correctly installed. http: // localhost/info. php (the info. php file needs to be created)
[Root @ ftp ~] # Vi/var/www/html/info. php # create the php file as follows:
<?
Phpphpinfo ();
?>

Install third-party source
Http://pkgs.repoforge.org/rpmforge-release/ -- Ctrl + F find the rpm package for Centos6
[Root @ ftp tmp] # wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.x86_64.rpm -- download it
[Root @ ftp tmp] # wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt -- Download verification (you can understand GPG)
[Root @ ftp tmp] # rpm -- import RPM-GPG-KEY.dag.txt -- import verification file
[Root @ ftp tmp] # rpm-ivh rpmforge-release-0.5.2-1.el6.rf.x86_64.rpm -- install it

Install proftpd (Be sure to compile and install it, and install mysql Support)
[Root @ ftp ~] # Yum install-y gcc make -- install the tool required for compilation
[Root @ ftp ~] # Whereis mysql
Mysql:/usr/bin/mysql/usr/lib64/mysql/usr/include/mysql/usr/share/man/man1/mysql.1.gz
[Root @ ftp ~] # Which mysql
/Usr/bin/mysql
[Root @ ftp home] # gunzip-c proftpd-1.3.5.tar.gz | tar xf-
[Root @ ftp home] # cd proftpd-1.3.5
[Root @ ftp proftpd-1.3.5] #./configure -- with-modules = mod_ SQL: mod_ SQL _mysql: mod_quotatab: mod_quotatab_ SQL \
> -- Enable-nls \
> -- With-nodes des =/usr/include/mysql \
> -- With-libraries =/usr/bin/mysql \
> -- Prefix =/usr/local/proftpd

The [root @ ftp proftpd-1.3.5] # make
[Root @ ftp proftpd-1.3.5] # make install

[Root @ ftp ~] # Vim/usr/local/proftpd/etc/proftpd. conf -- Configuration

1 # This is a basic ProFTPD configuration file (rename it
2 # 'proftpd. conf' for actual use. It establishes a single server
3 # and a single anonymous login. It assumes that you have a user/group
4 # "nobody" and "ftp" for normal operation and anon.
5
6 ServerName "ProFTPD Default Installation"
7 ServerType standalone
8 DefaultServer on
9
10 # Port 21 is the standard FTP port.
11 Port 21
12
13 # Don't use IPv6 support by default.
14 UseIPv6 off
15
16 # Umask 022 is a good standard umask to prevent new dirs and files
17 # from being group and world writable.
18 Umask 002
19
20 # To prevent DoS attacks, set the maximum number of child processes
21 # to 30. If you need to allow more than 30 concurrent connections
22 # at once, simply increase this value. Note that this ONLY works
23 # in standalone mode, in inetd mode you shoshould use an inetd server
24 # that allows you to limit maximum number of processes per service
25 # (such as xinetd ).
26 MaxInstances 30
27
28 # Set the user and group under which the server will run.
29 User nobody
30 Group nobody
31
32 # To cause every FTP user to be "jailed" (chrooted) into their home
33 # directory, uncomment this line.
34 DefaultRoot ~
35
36 # Normally, we want files to be overwriteable.
37 AllowOverwrite on
38
39 # Bar use of site chmod by default
40 <Limit SITE_CHMOD>
41 DenyAll
42 </Limit>
43
44 # A basic anonymous configuration, no upload directories. If you do not
45 # want anonymous users, simply delete this entire <Anonymous> section.
46 # <Anonymous ~ Ftp>
47 # User ftp
48 # Group ftp
49
50 # We want clients to be able to login with "anonymous" as well as "ftp"
51 # UserAlias anonymous ftp
52
53 # Limit the maximum number of anonymous logins
54 # MaxClients 10
55
56 # We want 'Welcome. msg 'displayed at login, and'. message' displayed
57 # in each newly chdired directory.
58 # DisplayLogin welcome. msg
59 # DisplayChdir. message
60
61 # Limit WRITE everywhere in the anonymous chroot
62 # <Limit WRITE>
63 # DenyAll
64 # </Limit>
65 # </Anonymous>
66
67
68 # Database Connection
69 SQLBackend mysql
70 # The passwords in MySQL are encrypted using CRYPT
71 SQLAuthTypes Plaintext Crypt
72 SQLAuthenticate users groups
73
74 # used to connect to the database
75 # databasename @ host database_user user_password
76 SQLConnectInfo ftp @ localhost proftpd your_password
77
78 # Here we tell ProFTPd the names of the database columns in the "usertable"
79 # we want it to interact with. Match the names with those in the db
80 SQLUserInfo ftpuser userid passwd uid gid homedir shell
81
82 # Here we tell ProFTPd the names of the database columns in the "grouptable"
83 # we want it to interact with. Again the names match with those in the db
84 SQLGroupInfo ftpgroup groupname gid members
85
86
87 # set min UID and GID-otherwise these are 999 each
88 SQLMinID 500
89
90 # create a user's home directory on demand if it doesn't exist
91 CreateHome on
92
93 # Update count every time user logs in
94 SQLLog PASS updatecount
95 SQLNamedQuery updatecount UPDATE "count = count + 1, accessed = now () WHERE userid = '% U'" ftpuser
96
97 # Update modified everytime user uploads or deletes a file
98 SQLLog STOR, DELE modified
99 SQLNamedQuery modified UPDATE "modified = now () WHERE userid = '% U'" ftpuser
100
101 RootLogin off
102 RequireValidShell off
103 # UseEncoding UTF-8 CP936
104 # files cannot be deleted. empty folders can be deleted.
105 <Directory/home/ftp/*>
106 <Limit DELE>
107 DenyUser rdd1, rdd2, rdd3, amd, fd, wsd, csd, std, asd, ftp
108 </Limit>
109 </Directory>

Database (ftp) Table Structure
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Ftp |
+ -------------------- +
2 rows in set (0.00 sec)

Mysql> use ftp;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-

Database changed
Mysql> show tables;
+ --------------- +
| Tables_in_ftp |
+ --------------- +
| Ftpgroup |
| Ftpuser |
+ --------------- +
2 rows in set (0.00 sec)

Mysql> desc ftpgroup;
+ ----------- + ------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ----------- + ------------- + ------ + ----- + --------- + ------- +
| Groupname | varchar (16) | NO | MUL |
| Gid | smallint (6) | NO | 5500 |
| Members | varchar (16) | NO |
+ ----------- + ------------- + ------ + ----- + --------- + ------- +
3 rows in set (0.00 sec)

Mysql> desc ftpuser;
+ ---------- + ------------------ + ------ + ----- + ----------------------- + ---------------- +
| Field | Type | Null | Key | Default | Extra |
+ ---------- + ------------------ + ------ + ----- + ----------------------- + ---------------- +
| Id | int (10) unsigned | NO | PRI | NULL | auto_increment |
| Userid | varchar (32) | NO | UNI |
| Passwd | varchar (32) | NO |
| Uid | smallint (6) | NO | 5500 |
| Gid | smallint (6) | NO | 2001 |
| Homedir | varchar (255) | NO |
| Shell | varchar (16) | NO |/sbin/nologin |
| Count | int (11) | NO | 0 |
| Accessed | datetime | NO | 0000-00-00 00:00:00 |
| Modified | datetime | NO | 0000-00-00 00:00:00 |
+ ---------- + ------------------ + ------ + ----- + ----------------------- + ---------------- +
10 rows in set (0.00 sec)



Mysql database backup and recovery
[Root @ amd240 ~] # Mysqldump-u root-p -- all-databases> all. SQL -- back up all databases
Enter password:
-- Warning: Skipping the data of table mysql. event. Specify the -- events option explicitly. -- the prompt is that mysql does not back up the event table by default. Add the -- events -- ignore-table = mysql. events parameter;
/Usr/local/mysql/bin/mysqldump-uroot-p -- events -- ignore-table = mysql. events -- all-databases> all. SQL
[Root @ ftp ~] # Mysql-u root-p
Add users and groups
[Root @ ftp ~] # Groupadd-g 2001 ftpgroup
[Root @ ftp ~] # Useradd-u 2001-s/bin/false-d/bin/null-c "proftpd user"-g ftpgroup ftpuser
[Root @ ftp ~] # Cat/etc/passwd | grep ftpuser
Ftpuser: x: 2001: 2001: proftpd user:/bin/null:/bin/false
[Root @ ftp ~] # Cat/etc/group | grep ftpgroup
Ftpgroup: x: 2001:

Copy the original ftp directory to the new server (note the permissions and group information with the copy attribute and directory attributes)
# Scp-prv/home/ftp root @ yourhostname_or_IPaddr:/home/
If necessary, you need to manually modify the Group of each directory

Start proftpd
[Root @ ftp ~] #/Usr/local/proftpd/sbin/proftpd
[Root @ ftp ~] # Pgrep proftpd
10573 -- Process number indicates the service is up

Proftpd-nd6 -- start to view error information
Proftpd-l -- check whether the currently supported modules support mysql

Below are extended knowledge
Generally, mysqldump is used for backup and recovery. Common methods are as follows:
(1) Export the entire database (including data in the database)

Mysqldump-u username-p dbname> dbname. SQL

(2) Export the database structure (excluding data)

Mysqldump-u username-p-d dbname> dbname. SQL

(3) export a data table in the database (including data)

Mysqldump-u username-p dbname tablename> tablename. SQL

(4) export the table structure of a data table in the database (excluding data)

Mysqldump-u username-p-d dbname tablename> tablename. SQL

(5) to restore the data, run the following command:

Mysql-u username-p test_db <test_db. SQL
 
 
 
References
Http://blog.xuite.net/tunedgr01/knowledge/6378500-RedHat+-+Proftpd+%2B+MySQL+authentication+%2B+Quotas++

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.