# For The Love Of God, help me. (Apache2, ProFTPD, MySQL, etc)

## HydroSan

I've been having multiple problems getting my server Up And Running even at basic levels. I cannot get Virtual Servers (e.g: subdomains) working, I cannot get ProFTPD to display directories (though it SEEMS to log in fine), and MySQL is directly linked to ProFTPD due to the MD5 password scheme I want to do just for security and Peace Of Mind.

The following topics have been made, most unanswered and unhelpful (unfortunately), so I've decided to compile all previous topics into this one. All I ask for his links or help on one or more subject. I have spent over five solid days pounding away with Webmin, reading through documentation, reading these forums (see links), and hacking at things. I'm at my wits end, and I'm starting to think that all of this was a really bad idea, and am considering just scrapping the newly gotten Custom DNS and going back to my old hoster.

Please help me. 

Problem One: Apache2

Let's start with the basic Apache stuff. I don't know what the hell I'm doing, obviously.

https://forums.gentoo.org/viewtopic.php?t=195691

I've got it so that Apache shows up alright with websites and images and everything. I don't know how secure it is, but that can wait. What I want to do is have subdomains (sub.domain.com) for my friends and various sites I'm hosting. I followed this:

https://forums.gentoo.org/viewtopic.php?t=139053

To no avail. It just spits out 'cannot find img.sankyuu.com' whenever I try to access it. And yes, I've started, restarted and edited all the configuration files correctly.

Problem Two: ProFTPD

I followed this guide and taught myself INSERT statements (and god that was fun  :Rolling Eyes:  ), and it seems to log-in. HOWEVER. It does not allow me to see anything. It just continues to say 'Receiving file list...' until it times out. I've followed that guide to the T.

https://forums.gentoo.org/viewtopic.php?t=156660

(Forsight) Problem Three: QMail

I haven't tackled QMail yet, but juding from the length of this guide: 

https://forums.gentoo.org/viewtopic.php?t=56633&highlight=qmail

... setting up QMail will be the most aggrivating hell immaginable, considering topics with smaller guides are already a nightmare.   :Laughing: 

---

So, can anyone help me? A hint? A wink? A nudge? A flip of the bird? I don't care. Anything helps, even if it only pushes me one step closer to the edge.

Thank you in advance for reading this - if you've read this far, please reply.   :Crying or Very sad: 

----------

## adaptr

Apache subdomains / virtual hosts:

```
UseCanonicalName off

NameVirtualHost 1.2.3.4:80

<VirtualHost 1.2.3.4:80>

 ServerName one.domain.tld

 Documentroot /var/www/one

</VirtualHost>

<VirtualHost 1.2.3.4:80>

 ServerName two.domain.tld

 Documentroot /var/www/two

</VirtualHost>
```

And set access permissions.

If that doesn't work you're already doing something wrong, believe me.

I strongly suggest you do not use Webmin or any other hands-off admin tools until you are proficient at the commandline.

I use mc, which is Gnu's greatest gift to man.

```
emerge mc

mc
```

Any more questions, come back and ask them, but I won't chase around zillions of posts I have no interest in.

----------

## amasidlover

img.sankyuu.com actually needs a DNS entry before you can use it as a virtual host... It appears sankyuu.com and www.sankyuu.com have entries but not img...

----------

## HydroSan

Bah. Silly me.   :Confused: 

EDIT: Wait, that means I've gotta pay another $30 a year per Subdomain? WTF?

----------

## adaptr

If you let yourself be ripped off like that, sure.

I have a domain for which I pay about $25 a year (20)

That includes full DNS and, obviously, as many subdomains as I require - it's my domain.

----------

## neomatrix35

thats right if you want img.sankyuu.com and www.sankyuu.com just add them both in your apache and bind configs... point of fact you can whateverthehellyouwant.sankyuu.com as long as you them to your apache and bind configs

add it to your apache configs just like above and in your dns for sankyuu.com just add the lines

img    A     $youripaddress

www   A     $youripaddress

and so on

EDIT sorry there should be tabs in between that not spaces

----------

## beandog

 *adaptr wrote:*   

> Apache subdomains / virtual hosts:
> 
> ```
> UseCanonicalName off
> 
> ...

 

Or

```
NameVirtualHost *:80

<VirtualHost *:80>

ServerName www.server.org

etc

</VirtualHost>
```

for those of us too lazy to type in the ip address every time.  :Wink: 

----------

## beandog

Ok, I'll try to help with a serious post now ...

How much progress have you made with Apache2?

I wouldn't worry about security too much -- you can enable SSL and run everything over HTTPS so if you ever login it won't be sent over plaintext or anything.  PHP as well is pretty easy to tighten down, just turn off unnecessary options and things like that and you'll probably be good to go.

My first recommendation though would be to *always* install apache + php from source code instead of emerging them.  It gives you much more power over the configurations options and I really, really, really, really, really, really, really hate how every stinkin stupid Linux distro messes with the default apache configs and tweaks them and moves them around in weird places instead of leaving them vanilla.  So, I'm a little biased in that area.  :Wink: 

If you want a quick rundown of how to do that, I can show you.  Or you can emerge it and that's an option too.  It's up to you.

As far as a mail server -- I'd recommend postfix.  Each time I set it up, it's been pretty simple.  Just read the main config file and you're good to go.

Steve

----------

## Lews_Therin

Editing bind addresses or configuring DNS for subdomains is unneeded.

Something that you could try, is putting the virtual hosts lines into the end of apache2.conf instead of vhosts.conf. It seems that the vhosts file doesn't get read or something, because my virtual hosts weren't working either until I merged them into the main file.

Have you tried both passive and active FTP modes on the client when connecting to the server?

----------

## HydroSan

Thanks for all the replies!   :Very Happy: 

Lets start from the top...

 *Quote:*   

> hats right if you want img.sankyuu.com and www.sankyuu.com just add them both in your apache and bind configs... point of fact you can whateverthehellyouwant.sankyuu.com as long as you them to your apache and bind configs
> 
> add it to your apache configs just like above and in your dns for sankyuu.com just add the lines
> 
> img A $youripaddress
> ...

 

How exactly would this work? I remember seeing DynDNS having a BIND configuration option in the 'advanced' mode. So I'm supposing this is what I'd want. I hope BIND isn't hard to learn.  :Embarassed: 

 *Quote:*   

> How much progress have you made with Apache2?

 

I've got it running with PHP support with a PHP/MySQL script running successfully, allowing people to upload images. 

And as for Apache being installed from source, I think I'll let Portage handle it for now. I've gotten this far and I know I'm almost through getting done with Apache.

 *Quote:*   

> As far as a mail server -- I'd recommend postfix. Each time I set it up, it's been pretty simple. Just read the main config file and you're good to go. 

 

Postfix? I've heard of it. But can it do what I need? I've gotta have around four to five (or more) domain email addresses (e.g: my current one, hydro@sankyuu.com) running, and obviously with enough security for it to be good. Any links I could read up on?

 *Lews_Therin wrote:*   

> Editing bind addresses or configuring DNS for subdomains is unneeded.
> 
> Something that you could try, is putting the virtual hosts lines into the end of apache2.conf instead of vhosts.conf. It seems that the vhosts file doesn't get read or something, because my virtual hosts weren't working either until I merged them into the main file.
> 
> Have you tried both passive and active FTP modes on the client when connecting to the server?

 

There is a line in apache2.conf (IIRC) that Includes the vhosts.conf file. It is commented-out by default, but uncommenting it seemed to work and my Virtual Hosts show up in Webmin.

Oh, and Active file transfers work great! Thank you.   :Very Happy: 

----------

## amasidlover

if you're using dyndns then you shouldn't need to pay any more or use BIND, simply create CNAME references. If you go to the Zone ( Click on Account, then  sankyuu.com). Then under cname records click 'Add CNAME'. Then in the Host section enter 'img' and in the data section enter sankyuu.com.

As for postfix, try emerging it and have a look at the master.cf file, it is very well commented and  hopefully you can just fill in the blanks...

----------

## Lews_Therin

 *HydroSan wrote:*   

> There is a line in apache2.conf (IIRC) that Includes the vhosts.conf file. It is commented-out by default, but uncommenting it seemed to work and my Virtual Hosts show up in Webmin.
> 
> Oh, and Active file transfers work great! Thank you.  

 

Ah, I see those lines now. Can't believe I missed them   :Rolling Eyes: 

Glad to hear FTP works now.

About the mailserver, have you tried exim? There's a very good guide to getting it up and running here, complete with a sample configuration file to check out.

----------

## beandog

I think I totally missed the boat here on something .. heh ... what are you using dyndns for?  Do you have a dynamic ip you want pointed to a domain or something?

----------

## HydroSan

 *sdibb wrote:*   

> I think I totally missed the boat here on something .. heh ... what are you using dyndns for?  Do you have a dynamic ip you want pointed to a domain or something?

 

I've got an ADSL line, yes. The IP changes every time I reconnect, so I required a DNS.

 *Quote:*   

> About the mailserver, have you tried exim? There's a very good guide to getting it up and running here, complete with a sample configuration file to check out.

 

Well, people have told me to use QMail, Postfix, and now Exim. I don't know what I should do in this department.   :Shocked: 

Please keep in mind that this is a domain and that I need to let people from the outside check their email via my server.

----------

## Lews_Therin

Exim/qmail/postfix allow people to send mail to and from your server. People check mail over something like courier-imap (IMAP and POP3 server).

----------

## HydroSan

Alright. Current status:

FTP: Working-ish with MySQL-MD5 password support.

Mail: Nothing yet.

Apache: Working on.

I've somehow screwed up Apache. I used to be able to get subdomains (such as img.sankyuu.com) and such, but now I can't get anything working. My configuration files are as follows:

apache2.conf

```
### /etc/apache2/conf/apache2.conf

### $Id: apache2.conf,v 1.1 2004/03/22 21:17:57 stuart Exp $

###

### Main Configuration Section

### You really shouldn't change these settings unless you're a guru

###

ServerRoot /usr/lib/apache2

#LockFile /etc/apache2/apache2.lock

PidFile /var/run/apache2.pid

ErrorLog logs/error_log

LogLevel warn

### Dynamic Shared Object (DSO) Support

### 

### You should always leave these three, as they are needed for normal use.

### mod_access (Order, Allow, etc..)

### mod_log_config (Transferlog, etc..)

### mod_mime (AddType, etc...)

###

LoadModule access_module                 modules/mod_access.so

LoadModule auth_module                   modules/mod_auth.so

LoadModule auth_anon_module              modules/mod_auth_anon.so

LoadModule auth_dbm_module               modules/mod_auth_dbm.so

LoadModule auth_digest_module            modules/mod_auth_digest.so

LoadModule include_module                modules/mod_include.so

LoadModule log_config_module             modules/mod_log_config.so

LoadModule env_module                    modules/mod_env.so

LoadModule mime_magic_module             modules/mod_mime_magic.so

LoadModule cern_meta_module              modules/mod_cern_meta.so

LoadModule expires_module                modules/mod_expires.so

LoadModule headers_module                modules/mod_headers.so

LoadModule usertrack_module              modules/mod_usertrack.so

LoadModule unique_id_module              modules/mod_unique_id.so

LoadModule setenvif_module               modules/mod_setenvif.so

LoadModule proxy_module                  modules/mod_proxy.so

LoadModule proxy_connect_module          modules/mod_proxy_connect.so

LoadModule proxy_ftp_module              modules/mod_proxy_ftp.so

LoadModule proxy_http_module            modules/mod_proxy_http.so

LoadModule mime_module                   modules/mod_mime.so

LoadModule status_module                 modules/mod_status.so

LoadModule autoindex_module              modules/mod_autoindex.so

LoadModule asis_module                   modules/mod_asis.so

LoadModule info_module                   modules/mod_info.so

LoadModule cgi_module                    modules/mod_cgi.so

LoadModule cgid_module                   modules/mod_cgid.so

LoadModule vhost_alias_module            modules/mod_vhost_alias.so

LoadModule negotiation_module            modules/mod_negotiation.so

LoadModule dir_module                    modules/mod_dir.so

LoadModule imap_module                   modules/mod_imap.so

LoadModule actions_module                modules/mod_actions.so

LoadModule speling_module                modules/mod_speling.so

LoadModule userdir_module                modules/mod_userdir.so

LoadModule alias_module                  modules/mod_alias.so

LoadModule rewrite_module                modules/mod_rewrite.so

###

### New Modules for 2.0 (some are experimental)

###

LoadModule file_cache_module             modules/mod_file_cache.so

LoadModule echo_module                   modules/mod_echo.so

LoadModule charset_lite_module           modules/mod_charset_lite.so

LoadModule cache_module                  modules/mod_cache.so

LoadModule disk_cache_module             modules/mod_disk_cache.so

LoadModule mem_cache_module              modules/mod_mem_cache.so

LoadModule ext_filter_module             modules/mod_ext_filter.so

LoadModule case_filter_module            modules/mod_case_filter.so

LoadModule case_filter_in_module         modules/mod_case_filter_in.so

LoadModule deflate_module                modules/mod_deflate.so

#LoadModule optional_hook_export_module   modules/mod_optional_hook_export.so

#LoadModule optional_hook_import_module   modules/mod_optional_hook_import.so

#LoadModule optional_fn_import_module     modules/mod_optional_fn_import.so

#LoadModule optional_fn_export_module     modules/mod_optional_fn_export.so

#LoadModule bucketeer_module              modules/mod_bucketeer.so

LoadModule logio_module                  modules/mod_logio.so

###

### Global Configuration

###

# Splitting up apache2.conf into two files makes it easier to support

# multiple configurations on the same serer.  In commonapache2.conf

# you keep directives that apply to all implementations and in this

# file you keep server-specific directives.  While we don't yet have

# multiple configurations out-of-the-box, this allows us to do that

# in the future easily.  (PERLPROXIED *ahem*)

#

# For Apache2 we load all conf files in conf/modules.d

Include conf/modules.d/*.conf

Include conf/commonapache2.conf

###

### IP Address/Port

###

#BindAddress *

Listen 80

###

### Log configuration Section

###

<IfModule mod_log_config.c>

#Single logfile with access, agent and referer information

#This is the default, if vlogs are not defined for the main server

CustomLog logs/access_log combined env=!VLOG

#If VLOG is defined in conf/vhosts/vhosts.conf, we use this entry

#CustomLog "|/usr/sbin/apache2splitlogfile" vhost env=VLOG

</IfModule>

###

### Virtual Hosts 

###

# We include different templates for Virtual Hosting. Have a look in the 

# vhosts directory and modify to suit your needs.

Include conf/vhosts/vhosts.conf

#Include conf/vhosts/dynamic-vhosts.conf

#Include conf/vhosts/virtual-homepages.conf

###

### Performance settings Section

###

#

# Timeout: The number of seconds before receives and sends time out.

#

Timeout 300

#

# KeepAlive: Whether or not to allow persistent connections (more than

# one request per connection). Set to "Off" to deactivate.

#

KeepAlive On

#

# MaxKeepAliveRequests: The maximum number of requests to allow

# during a persistent connection. Set to 0 to allow an unlimited amount.

# We recommend you leave this number high, for maximum performance.

#

MaxKeepAliveRequests 100

#

# KeepAliveTimeout: Number of seconds to wait for the next request from the

# same client on the same connection.

#

KeepAliveTimeout 15

# prefork MPM [THIS IS THE DEFAULT]

# StartServers: number of server processes to start

# MinSpareServers: minimum number of server processes which are kept spare

# MaxSpareServers: maximum number of server processes which are kept spare

# MaxClients: maximum number of server processes allowed to start

# MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule prefork.c>

StartServers         5

MinSpareServers      5

MaxSpareServers     10

MaxClients         150

MaxRequestsPerChild  0

</IfModule>

# worker MPM

# StartServers: initial number of server processes to start

# MaxClients: maximum number of simultaneous client connections

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# ThreadsPerChild: constant number of worker threads in each server process

# MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule worker.c>

StartServers         2

MaxClients         150

MinSpareThreads     25

MaxSpareThreads     75

ThreadsPerChild     25

MaxRequestsPerChild  0

</IfModule>

<Directory "/var/www/localhost/sankyuu">

DirectoryIndex index.html

</Directory>

# perchild MPM

# NumServers: constant number of server processes

# StartThreads: initial number of worker threads in each server process

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# MaxThreadsPerChild: maximum number of worker threads in each server process

# MaxRequestsPerChild: maximum number of connections per server process

<IfModule perchild.c>

NumServers           5

StartThreads         5

MinSpareThreads      5

MaxSpareThreads     10

MaxThreadsPerChild  20

MaxRequestsPerChild  0

</IfModule>
```

vhosts.conf

```
UseCanonicalName off

NameVirtualHost *:80

<VirtualHost *:80>

ServerName sankyuu.com

ServerAlias www.sankyuu.com

DocumentRoot /var/www/localhost/sankyuu

DirectoryIndex index.html

<Directory "/var/www/localhost/sankyuu">

DirectoryIndex index.html

</Directory>

</VirtualHost>

<VirtualHost *:80>

ServerName img.sankyuu.com

DocumentRoot /home/img/public_html

DirectoryIndex imgboard.htm imgboard.php

<Directory "/home/img/public_html">

DirectoryIndex imgboard.htm imgboard.php

</Directory>

# IndexIgnore .htaccess

</VirtualHost>
```

img.sankyuu.com is specified in DynDNS' CNAME settings and as I said, I was able to get them before.

Thanks for all your help and I'm sorry if I'm becoming a pain.  :Sad: 

----------

## HydroSan

Well, I managed to trace the problems to apparently PHP/mod_php. Every time I view a PHP page, Apache locks and stops working. Though subdomains and everything work great otherwise. I'm installing the older version of PHP (4.3.7), and IMO these problems may have started with the new PHP modules.

----------

## HydroSan

A little update! After a little research, I saw some problems with the Threading library with Apache. So I recompiled Apache without USE="threads", and PHP no longer hard-locks Apache.

Everything seems to be falling together nicely.

----------

## beandog

 *HydroSan wrote:*   

> A little update! After a little research, I saw some problems with the Threading library with Apache. So I recompiled Apache without USE="threads", and PHP no longer hard-locks Apache.
> 
> Everything seems to be falling together nicely.

 

Very cool  :Smile: 

The reason I asked about dyndns is that if you your own domain, use www.everydns.net instead.  It's free, and much nicer and more flexible.

----------

## adaptr

 *HydroSan wrote:*   

> A little update! After a little research, I saw some problems with the Threading library with Apache. So I recompiled Apache without USE="threads", and PHP no longer hard-locks Apache.

 

Harrumph...

If you "USE=threads" apache will switch from the 1.3.x default prefork mechanism to a threads-based worker MPM - this obviously breaks PHP.

Another "if you have apache problems it should be mandatory to specify how you compiled it" thread solved...

----------

## HydroSan

 *adaptr wrote:*   

>  *HydroSan wrote:*   A little update! After a little research, I saw some problems with the Threading library with Apache. So I recompiled Apache without USE="threads", and PHP no longer hard-locks Apache. 
> 
> Harrumph...
> 
> If you "USE=threads" apache will switch from the 1.3.x default prefork mechanism to a threads-based worker MPM - this obviously breaks PHP.
> ...

 

Yes, but I didn't know that.   :Laughing:  I didn't think Apache was so touchy.

Well, things are looking up now. Thanks for all your support. 

I need to get a mail server running fairly soon. It has to do the following:

1. Be able to receive and send emails from the @sankyuu.com domain. 

2. Be secure enough for remote use by other people.

3. Be generally nice and not be a complete pain in the ass to get running. 

I've seen people mention QMail, Postfix, Exim... I honestly have no idea what toc choose. Or are they all basically the same and are just different brands of the same car?

----------

## beandog

From my limited knowledge:

qmail -- super secure, super pain to setup, never has had one security flaw

postfix -- I've gotten it to run, therefore I'm in love with it

exim -- never tried it, some people use it, looks cool

Good luck.  :Wink: 

----------

## amasidlover

I've used Postfix and Exim and found that Postfix is easier to configure, but Exim is very powerful.  For one domain I'd probably stick with postfix as most people on these forums have experience of it.

But either way for people to log-in and collect mail then you need to use a POP3 or IMAP server. I've used qpopper, Cyrus and Courier and most of them require very little/no configuration providing you're willing to add users to /etc/passwd. If you don't want them to be able to log in then simply set their shell to /bin/false.

----------

## adaptr

 *HydroSan wrote:*   

> 
> 
> I need to get a mail server running fairly soon. It has to do the following:
> 
> 1. Be able to receive and send emails from the @sankyuu.com domain. 
> ...

 

On one level, they are - until you've used one or more of them for a while  :Wink: 

I'll separate them into their respective categories:

1. Sendmail

Sendmail is God.

There is absolutely nothing it can not do, if you're prepared to learn at least 2 additional languages and major in advanced semantics in order to configure it  :Wink: 

2. Qmail

Qmail is reputedly the most secure MTA in the world, but as with all of djb's products, it is not GPL, it never will be GPL, and it has some idiosyncrasies you want to be aware of.

Also the only one that requires maildirs.

3. Postfix

Postfix is written by an American Dutchie, so obviously much preferred by myself  :Wink: 

They claim it can handle a million emails a day out of the box - so if speed or volume is your thing, go Postfix.

It also has very (very) advanced spam and access rules, and is apparently easier to integrate into advanced setups than the others, notably virtual domains, vdomains with mysql, ldap authentication etc.

I've run Postfix for a few years, with spamassassin and stuff, and it's pretty good.

And last but not least

4. Exim

Exim is what I use now, on my own humble domain (it may just have 5 actual users!  :Wink: )

Why ? Well, it is Debian's standard MTA, and configuring it took me all of 3 seconds - flat.

The config is every bit as advanced as Postfix' - except that to use it as a full-fledged MTA you need only configure about 5 options and you're done!

For a solid Postfix setup you will sit up many nights with the manual swimming before your eyes.

I'd recommend starting with Exim or Postfix if this is your first MTA/maildomain setup - you'll learn more than you thought possible!

Oh and to get at your mail, just run Courier-IMAP and be done with it...

You'll probably thank me later  :Wink: 

----------

## krunk

Sorry I'm off to work in a few so didn't have time to read the whole post. 

You have to get apache working first, but this is a great howto:

http://www.qmailrocks.org

----------

