Archive for March, 2007
FTP Setup (VSFTPD)
Mar 22nd
As with all my suggestions do a yum or apt-get install “yum install vsftpd” or “apt-get install vsftpd”. The vsftpd configuration file is in /etc/vsftpd/vsftpd.conf. You can organize things nicely, and find the correct lines to edit, but order is not important. I add all my configuration lines right to the top of the configuration file. To make things simple for your ftp users, your going to probably want the user to automatically login into their root directory. To do this add the line “chroot_local_user=YES”. Another thing that I like to do for added security is the following; because vsftpd uses two ports (21 for the initial connection, and then a HIGH port for the data connection), you should specify the data connection port. You can do this by adding the lines “pasv_min_port=*****, and pasv_max_port=*****”. You can set the ***** to any port, or ports that you want. Remeber, if you want to allow multiple ftp users to log in at the same time you will have to allow multiple ports. Also remeber that what ever ports you choose you will have to allow through your router via port forwarding!!! You will also have to allow port 21 through port forwarding. Another important configuration is to disable anonymous; do this by finding the line “anonymous_user=YES” and change the YES to NO. Don’t comment or delete the line as anonymous access is on by default, specify NO explicitly. Also make sure the “listen=YES” line is not commented. BAM your ftp is setup. Login to start FTP’in!
Dovecot Installation and Configuration
Mar 22nd
For a server to send and receive mail it requires Sendmail, for a user to interact with the mail POP or IMAP access is a convenient feature. Dovecot is a simple IMAP, and POP piece of software. I recommend, as I always do, install using yum, or apt-get. Once installed the configuration file should simply be in the /etc directory with a filename of dovecot.conf. In the configuration file there is little that needs editing, the first and foremost you going to want to define the services you want the program to perform. This is done with the “protocols”. I prefer IMAP, which runs on port 143. Remeber, if you have SELinux install you are going to have to disable it for the Dovecot service to properly access the server. Go into your “system” menu in the main navigation, go into the administration submenu, and open Security Level and Firewall configuration (obviously this is for a graphical desktop associated with Fedora Core, or Ubuntu). In your Firewall/SELinux configuration window click the SELinux tab, expand modify SELinux, scroll down and expand the SELinux Service Protection tab, and then scroll down and click the distable SELinux protection for Dovecot. Also if you have a router you will have to enable port forwarding for port 143 to the local IP address of the server. Now go back to the /etc/dovecot.conf file for final configuration. Make sure there is a line “listen = *:143″. If you want to be specific instead of the “*” you can put the local IP address, but a “*” will suffice. The only other configuration that you will have to do is specify where the mailboxes will be kept. This is simply done with a single line “mail_location = mbox:~/mail:INBOX=/var/mail/%u”. With this mailbox setup your servers users will have a mailbox that is auto-configured with Sendmail. All mail sent to the email addresses set up by sendmail can be accessed via a IMAP or POP Dovecot interface. As with all my posts feel welcome to give an email to admin [at] bgevolution.com if you run into any issues.
Sendmail Configuration
Mar 20th
Sendmail is a simple MTA (mail transport agent). There are two programs that are required to access email, a MTA and either an IMAP or POP. The MTA allows a computer to send and receive emails, while the IMAP or the POP allows for the reading of the mail. Start with a simple yum or apt-get install. In Fedora Core there is an auto yum program in the applications menu; access this an add in the server options “sendmail”. It will automatically install all dependancies. After installed, make sure it runs at boot, and start the program. In Fedora Core go to the system menu and select administration – services. In the services make sure the sendmail checkbox is clicked and then also make sure it is started. Now for configuration. There is practically nothing that has to be done, all you have to do is go into the /etc/mail/local-host-names file, open it, and add the domain name or the ip address of your computer/server. Save and close, and now open the virtusertable file, add the email address that you want to accept mail to. The proper format is: example@exampledomain.com user The first is the email address and then a tab, then the user that is going to receive the email. If you have multiple email addresses make sure they all line (tab wise): example@exampledomain.com    user1 example2@exampledomain.com user2 ex@tempdomain.com                user3 Save the file and close. Now open the Sendmail.mc file. You must now tell Sendmail to access port 25 on your system, and its default configuration is to only look on the local network. Go to the DAEMON_OPTIONS line that is not commented with (dnl), and change it to DAEMON_OPTIONS(`Port-smtp,Name=MTA’ )dnl . Now csave the file and close. Go into a terminal change to the sendmail configuration directory (cd /etc/mail) and type “make”. Now type “service sendmail restart”. BAM you have send mail working. Make sure your firewall allows the SMTP port. Go into the systems menu, select administration – Security Level and Firewall. In this click the Mail (SMTP) box, and close the window. You will also have to make sure that your router directs port 25 to the computer/server. You will have to use port forwarding and forward port 25 to the local IP address of your computer/server.
Cband Apache Bandwidth Throttling
Mar 19th
A quick link to a perfect tutorial. http://howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling
Mysql Headaches
Mar 19th
The other day I destroyed by Mysql installation by erasing the required databases (mysql database, privileges database). My first decision was to try and uninstall and reinstall a fresh copy. This will not immediately work; during an uninstall of the files it still will not remove the database files. Mysql databases are stored at “/var/lib/mysql/”. Go to this folder to backup any databases that you were using for your web programs, rename the folder to something link “mysql(backup). After doing this a reinstall of all Mysql and dependency files will work, including a removal of the root password. You will have to reset the root password again with the following command mysqladmin -u root -p password ‘………’ the command actually has the single quotation marks that you put your password within (where the dots/periods are). After a clean install, and setting the root password, go into your backed up mysql folder and copy the databases that you want to recover into the new mysql folder. BAM your back up and running. Now just login via PHPMyadmin with “root” and your new password and you will see all your old databases and all your accidentally deleted required databases. You can add users by the PHPMyadmin “privileges” button available in the main column. If you ever have any trouble access Mysql, such as a “sock” error, its your my.cnf file stored in /etc/my.cnf . Give a Google search for default my.cnf file and copy paste the test into your cnf file in the /etc/ directory. There is a local copy of the default .cnf file located on your computer in the “doc” folder. In addition the following is a basic my.cnf file for so called “small systems”.
# Example mysql config file for small systems. # # # You can copy this file to # /etc/my.cnf to set global options, # mysql-data-dir/my.cnf to set server-specific options (in this # installation this directory is /usr/local/mysql/var) or # ~/.my.cnf to set user-specific options. # # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking set-variable = key_buffer=128K set-variable = max_allowed_packet=1M set-variable = thread_stack=64K set-variable = table_cache=4 set-variable = sort_buffer=64K set-variable = net_buffer_length=2K server-id = 1 # Uncomment the following if you want to log updates #log-bin # Uncomment the following if you are NOT using BDB tables #skip-bdb # Uncomment the following if you are using Innobase tables #innodb_data_file_path = ibdata1:100M #innodb_data_home_dir = /usr/local/mysql/var/ #innodb_log_group_home_dir = /usr/local/mysql/var/ #innodb_log_arch_dir = /usr/local/mysql/var/ #set-variable = innodb_mirrored_log_groups=1 #set-variable = innodb_log_files_in_group=3 #set-variable = innodb_log_file_size=5M #set-variable = innodb_log_buffer_size=8M #innodb_flush_log_at_trx_commit=1 #innodb_log_archive=0 #set-variable = innodb_buffer_pool_size=16M #set-variable = innodb_additional_mem_pool_size=2M #set-variable = innodb_file_io_threads=4 #set-variable = innodb_lock_wait_timeout=50 [mysqldump] quick set-variable = max_allowed_packet=16M [mysql] no-auto-rehash #safe-updates [isamchk] set-variable = key_buffer=8M set-variable = sort_buffer=8M [myisamchk] set-variable = key_buffer=8M set-variable = sort_buffer=8M
PHP Installation
Mar 18th
PHP, like Mysql, typically comes pre-installed with most linux distributions. As with Mysql there are three options to install PHP. You can download it from the main website, or use yum or apt-get. I prefer yum or apt-get as they automatically install the files for you. There is one thing that needs to be done for PHP to work with mysql. You must edit a single line in the php.ini file. The php.ini file is typically in the /etc directory. Next do a quick google search for php-mysql, you must download a file called mysql.so. This is a php plugin that allows its to interface with mysql. The instructions with the typical php-mysql package tend to recommend installation of the plugin in the /usr/lib/php/modules directory. In your php.ini file add the following line to allow php to interface with mysql. “extension_dir=”/usr/lib/php/modules” which will define the directory where the plugin is, and then add the following line “extension=mysql.so” and BAM your php will now be able to access Mysql. This typically is a required operation to get PHPMyadmin up and running, as the PHPMyadmin interface is obviously php based and allows users to interact with the Mysql database graphically!