# Pure-ftpd with MySQL start problem.

## Net-Base.dk

Hey.

I have tryed install Pure-ftpd with MySQL support but after i have started pure-ftpd i cant connect to the ftp server.

I have installed Pure-ftpd with thies USE variables.

```
 # emerge -av pure-ftpd

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] net-ftp/pure-ftpd-1.0.20-r1  -caps +ldap +mysql +pam -postgres +ssl +vchroot 0 kB

Total size of downloads: 0 kB

Do you want me to merge these packages? [Yes/No]

```

My Pure-ftpd configuration looks like this

```
 # vi /etc/conf.d/pure-ftpd

IS_CONFIGURED="yes"

SERVER="-S 21"

MAX_CONN="-c 30"

MAX_CONN_IP="-C 10"

DAEMON="-B"

DISK_FULL="-k 99%"

AUTH="-l mysql:/etc/pureftpd-mysql.conf -l unix"

TIMEOUT="-I 5"

LOG="-f ftp"

MISC_OTHER="-A -j -M -w -Z -Y 1"

```

then i have edited my pureftpd-mysql.conf file to this

```
 # vi /etc/pureftpd-mysql.conf

MYSQLSocket     /var/run/mysqld/mysqld.sock

#MYSQLServer     localhost

#MYSQLPort       3306

MYSQLUser       xxxx

MYSQLPassword   xxxxxxxxxxxx

MYSQLDatabase   pureftpd

#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMENDABLE uppon cleartext

MYSQLCrypt      cleartext

MYSQLGetPW      SELECT Password FROM users WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MYSQLGetUID     SELECT Uid FROM users WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MYSQLGetGID     SELECT Gid FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MYSQLGetDir     SELECT Dir FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MySQLGetBandwidthUL SELECT ULBandwidth FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MySQLGetBandwidthDL SELECT DLBandwidth FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MySQLGetQTASZ   SELECT QuotaSize FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

MySQLGetQTAFS   SELECT QuotaFiles FROM users WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

```

after this i have created a database with name "pureftpd" and added this table.

```
CREATE TABLE `users` (

  `User` varchar(32) NOT NULL default '',

  `status` enum('0','1') NOT NULL default '0',

  `Password` varchar(64) NOT NULL default '',

  `Uid` varchar(11) NOT NULL default '-1',

  `Gid` varchar(11) NOT NULL default '-1',

  `Dir` varchar(255) NOT NULL default '',

  `ULBandwidth` smallint(5) NOT NULL default '0',

  `DLBandwidth` smallint(5) NOT NULL default '0',

  `ULRatio` smallint(5) NOT NULL default '0',

  `DLRatio` smallint(5) NOT NULL default '0',

  `comment` tinytext NOT NULL,

  `ipaccess` varchar(15) NOT NULL default '*',

  `QuotaSize` smallint(5) NOT NULL default '0',

  `QuotaFiles` int(11) NOT NULL default '0',

  `ForceTildeExpansion` enum('0','1') NOT NULL default '0',

  PRIMARY KEY  (`User`),

  UNIQUE KEY `User` (`User`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8;

```

and then i have inserted this line

```
INSERT INTO `users` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`, `ULBandwidth`, `DLBandwidth`, `ULRatio`, `DLRatio`, `comment`, `ipaccess`, `QuotaSize`, `QuotaFiles`, `ForceTildeExpansion`) VALUES ('test_user', '1', 'test_password', '81', '81', '/var/www/dummy_user_web_root/', 0, 0, 0, 0, 'This is a dummy user', '*', 0, 0, '0');

```

and then i start Pure-ftpd with this line

```
 # /etc/init.d/pure-ftpd start

```

and its start fine.

But i can't connect to the FTP server, when i try in CuteFTP Pro i get this error message.

```
STATUS:>     Getting listing ""...

STATUS:>     Connecting to ftp server 10.0.0.6:21 (ip = 10.0.0.6)...

ERROR:>      Can't connect to remote server. Socket error = #10061.

STATUS:>     Waiting 30 seconds...

```

What can be wrong??? i really dont understand it. i have readed a million articles of about this but i cant get my pureftpd server working.... can some one help me?

----------

## magic919

There are a number of possibles here.

Can you run

netstat -tunlp

to check Pure is listening on the port and interface you'd expect.  Can you test from the machine itself - ftp localhost - just to take a few variables out of the equation.

Can you check your MySQL logs and see if you can any errors.

Any what about any logging from Pure?  Do you see anything in your logs?

----------

## Net-Base.dk

this is what i get when i run a netstat

```
# netstat -tunlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      9404/mysqld

tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      10149/smbd

tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      10149/smbd

tcp        0      0 :::80                   :::*                    LISTEN      12026/apache2

tcp        0      0 :::22                   :::*                    LISTEN      9540/sshd

tcp        0      0 :::8888                 :::*                    LISTEN      12026/apache2

udp        0      0 127.0.0.1:32770         0.0.0.0:*                           10158/smbd

udp        0      0 127.0.0.1:32772         0.0.0.0:*                           10160/smbd

udp        0      0 10.0.0.6:137            0.0.0.0:*                           10152/nmbd

udp        0      0 0.0.0.0:137             0.0.0.0:*                           10152/nmbd

udp        0      0 10.0.0.6:138            0.0.0.0:*                           10152/nmbd

udp        0      0 0.0.0.0:138             0.0.0.0:*                           10152/nmbd

```

----------

## magic919

Okay.  So PureFTP is not running.  That explains why you can't connect then.  I think you'll have to run PureFTP in the foreground and with -v or whatever to make it more verbose if that helps.  You can check the /etc/init.d/pureftp? script to see what needs to be run on the commandline.

----------

## Net-Base.dk

The start() part of that file looks like this.

```
start() {

        checkconfig || return 1

        ebegin "Starting Pure-FTPd"

        start-stop-daemon --start --quiet --exec /usr/sbin/pure-ftpd -- $SERVER $MAX_CONN $MAX_CONN_IP $DAEMON $DISK_FULL $USE_NAT $AUTH $LOG $TIMEOUT $MISC_OTHER

        eend $?

}

```

i not shure how to change the file so PureFTP is runnig in foreground mode. can you please show me how it should look like?

----------

## magic919

Well to run it, as a minimum, type

/usr/sbin/pure-ftpd

You'll see some options that get appended to the end.  I'd expect these to be defined in /etc/conf.d/pure-ftpd.  But run the above as a start.

----------

## Net-Base.dk

the server is starting fine with this code.

```
/usr/sbin/pure-ftpd 
```

----------

## magic919

```

# vi /etc/conf.d/pure-ftpd

IS_CONFIGURED="yes"

SERVER="-S 21"

MAX_CONN="-c 30"

MAX_CONN_IP="-C 10"

DAEMON="-B"

DISK_FULL="-k 99%"

AUTH="-l mysql:/etc/pureftpd-mysql.conf -l unix"

TIMEOUT="-I 5"

LOG="-f ftp"

MISC_OTHER="-A -j -M -w -Z -Y 1"

```

I think the DISK_FULL bit is killing it.  I don't think it should have that % sign.  What I did was check the docs.

 *Quote:*   

> 
> 
> - '-k <percentage>': Don't allow uploads if the partition is more than
> 
> <percentage>% full. For instance, "-k 95" will ensure your disks will never
> ...

 

----------

## Net-Base.dk

now i have edit the file but i still not starting.

when i start it

```
 * Starting Pure-FTPd ...    [ ok ]

```

its starts fine but i cant see it in netstat -tunlp

and when i try 2 stop it.

```
 * Stopping Pure-FTPd ...    [ !! ]
```

Do you know how 2 add a log file. maby it will be posible 2 se the problem in that!

----------

## magic919

Okay.  Maybe we are getting somewhere.  It should be logging in your syslog already.  The -f ftp bit does that.

But hey, run it in the foreground with all the switches and you'll see.  Substitute the values from /etc/conf.d/pure-ftpd for the variable names you find in /etc/init.d/pure-ftpd.

Hint (but do check it)

```

/usr/sbin/pure-ftpd -S 21 -c 30 -C10 -B -k 99 -I 5 -f ftp -A -j -M -w -Z -Y 1

```

If it fails then note the error.  Start dropping these out one by one to test.  I notice $USE_NAT is not implemented here, but that shouldn't cause bother.

Tony

----------

## Net-Base.dk

The server is not starting when i use this line

```
/usr/sbin/pure-ftpd -S 21 -c 30 -C10 -B -k 99 -I 5 -f ftp -A -j -M -w -Z -Y 1

```

and it is not comming with any error messages.

----------

## magic919

You need to test this yourself by dropping out options until you find the ones that work ok.

----------

## Net-Base.dk

arh okay... yes i will do that.

----------

## magic919

Should have said earlier - drop out the -B when you are running it by hand.  You don't want to background it.

----------

## Net-Base.dk

Hey i have tryed it out now, and now i have a problem it has started a standalone server and i dont know how 2 stop it... i have only tryed 4 arguments so im not finished.

----------

## Net-Base.dk

it was after i tryed the -B argument how to stop it now?

----------

## magic919

if you run

pgrep -fl pure

you'll see the process and the PID.  Provided there is nothing else run

pkill pure

to kill it off.

----------

## Net-Base.dk

it was "-Y 1" that was the problem, so i have removed it from the /etc/conf.d/pure-ftpd but when i try 2 stop the pure-ftpd server with

```
# /etc/init.d/pure-ftpd restart

 * Caching service dependencies ...   [ ok ]

 * Stopping Pure-FTPd ...   [ !! ]
```

and then if i try 2 start it.

```
# /etc/init.d/pure-ftpd start

 * WARNING:  "pure-ftpd" has already been started.
```

how can i stop it???

----------

## magic919

You can stop it with the method above.  You may need

/etc/init.d/pure-ftpd zap

to reset the start script once the process is dead.

----------

## Net-Base.dk

YESSSS... now the server is starting fine.

But i cant login.

i have made a user:

user: test

homedir /disks/

the folder disks is a folder i have created by my self where i mount 3 HDD in... i have change the chmod to 777 for /disks/

can you tell me what the problem is?

maby it is posible to add a logfile so i can if there is some problem for pure-ftpd to connect to mysql.

----------

## magic919

It says it logs in the syslog.

----------

## Net-Base.dk

okay but where can i find the system log?

and i have added this 

-O clf:/var/log/pureftpd.log stats:/var/log/pureftpd.log w3c:/var/log/pureftpd.log

to the /etc/conf.d/pure-ftpd so it shuold log every thing in this file but the file is empty..

When i try to connect with CuteFTP Pro i can connect but not login to the server. do you have any ide of why i can connect but can't login ?

----------

## magic919

What syslog application have you installed?

----------

## Net-Base.dk

Syslog-ng

----------

## magic919

Can you post your conf file for syslog-ng then.

----------

## Net-Base.dk

the is a line in the conf file there look like this.

destination messages { file("/var/log/messages") ; };

so i will think it is that file.

----------

## magic919

Well that really is a bare minimum conf for syslog-ng and yes, that's where they should be.

----------

## Net-Base.dk

I can see in the /var/log/message file that Pure-ftpd is running.

but when i try 2 connect with the test user i have made in the MySQL database it isn't make any line with error message or something.

but if i try to connect with root i get a line with text "[WARNING] Authentivcation failed for user [root]"

and the pure-ftpd.log file is still empty.

----------

## Net-Base.dk

Hey the server is running now and i can login if i change 

```
/etc/conf.d/pure-ftpd 

AUTH="-1 unix"

```

but if i use Mysql i cant login. can you tell me why?

----------

## magic919

There's clearly a problem with your MySQL bit.  I'd suggest you cut back to the simplest MySQL config you can use.  Read the docs to find out what this is.  Then check the logs when testing.  It's all part of the troubleshooting process.

----------

## Zanussi

Hello

I have problem with starting Pure-FTPd ... when i write 

/etc/init.d/pure-ftpd start

I see this

```

/etc/init.d/pure-ftpd start

 * Caching service dependencies ...                        [ ok ]

 * Starting Pure-FTPd ...

 * Could not launch Pure-FTPd                               [ ! ! ]

```

Did you know, what is problem?

My conf file is 

```

# Config file for /etc/init.d/pure-ftpd

##Comment variables out to disable its features, or change the values in it... ##

## This variable must be uncommented in order for the server to start ##

IS_CONFIGURED="yes"

## FTP Server,Port (separated by comma) ##

## If you prefer host names over IP addresses, it's your choice:

## SERVER="-S ftp.rtchat.com,21"

## IPv6 addresses are supported.

## !!! WARNING !!!

## Using an invalid IP will result in the server not starting,

## but reporting a correct start!

SERVER="-S 217.12.53.48,21"

## By default binds to all available IPs.

## SERVER="-S 21"

## Number of simultaneous connections in total, and per IP ##

MAX_CONN="-c 30"

MAX_CONN_IP="-C 10"

## Start daemonized in background ##

DAEMON="-B"

## Don't allow uploads if the partition is more full then this var ##

DISK_FULL="-k 90%"

## If your FTP server is behind a NAT box, uncomment this ##

#USE_NAT="-N"

## Authentication mechanisms (others are 'pam', ...) ##

## Further infos can be found in the README file.

AUTH="-l mysql:/etc/pureftpd-mysql.conf" 

## Change the maximum idle time (in minutes) ##

## If this variable is not defined, it will default to 15 minutes.

#TIMEOUT="-I <timeout>'"

## Facility used for syslog logging ##

## If this variable is not defined, it will default to the 'ftp' facility.

## Logging can be disabled with '-f none'.

LOG="-f none"

## Charset conversion support *experimental* ##

## Only works if USE "charconv" is enabled (only Pure-FTPd >=1.0.21).

## Set the charset of the filesystem.

# CHARCONV="--fscharset <charset>"

## If you want to process each file uploaded through Pure-FTPd, enter the name

## of the script that should process the files below.

## man pure-uploadscript to learn more about how to write this script.

# UPLOADSCRIPT="/path/to/uploadscript"

## Misc. Others ##

MISC_OTHER="-A -E -x -j -Z -d"

#

# Use these inside $MISC_OTHER

# More can be found on "http://download.pureftpd.org/pub/pure-ftpd/doc/README"

#

# -A [ chroot() everyone, but root ]

# -e [ Only allow anonymous users ]

# -E [ Only allow authenticated users. Anonymous logins are prohibited. ]

# -i [ Disallow upload for anonymous users, whatever directory perms are ]

# -j [ If the home directory of a user doesn't exist, auto-create it ]

# -M [ Allow anonymous users to create directories. ]

# -R [ Disallow users (even non-anonymous ones) usage of the CHMOD command ]

# -x [ In  normal  operation mode, authenticated users can read/write

#   files beginning with a dot ('.'). Anonymous users can't, for security reasons

#   (like changing banners or a forgotten .rhosts). When '-x' is used, authenticated

#   users can download dot-files, but not overwrite/create  them,  even  if they own

#   them. ]

# -X [ This  flag  is  identical  to  the  previous one (writing

#       dot-files is prohibited), but in addition, users can't even *read* files and

#       directories beginning with a dot (like "cd .ssh"). ]

# -D [ List files beginning with a dot ('.') even when the client doesn't

#      append the '-a' option to the list command. A workaround for badly

#      configured FTP clients. ]

# -G [ Disallow renaming. ]

# -d [ Send various debugging messages to the syslog. ONLY for DEBUG ]

# -F <fortune file> [ Display a fortune cookie on login. Check the README file ]

# -H [ By default, fully-qualified host names are logged. The '-H' flag avoids host names resolution. ]

```

Thank's for replies

----------

