A Bit of Slack Never Hurt Anyone

LAMP on Slackware (Part 3)

Prev.. This is Part 3 of "How to configure Apache, MySQL and PHP on your Slackware machine."

MySQL

Initialize the MySQL database and start the server

Assuming all went well in the previous steps, it's time to setup the MySQL database server.

The very first step is to have a look at the /etc/my-*.cnffiles

  • /etc/my-huge.cnf
  • /etc/my-medium.cnf
  • /etc/my-small.cnf

Have a look through them and decide which one suits your environment. Then copy it to /etc/my.cnf like this:cp /etc/my-small.cnf /etc/my.cnfNow execute the following commands in this order:chmod 0755 /etc/rc.d/rc.mysqld mysql_install_db chown -R mysql:mysql /var/lib/mysql /etc/rc.d/rc.mysql start mysql_secure_installationYou'll be prompted for a root mysql password. This and all other mysql user passwords are completely independant from the system passwords so don't confuse them!

Follow the prompts and choose the most secure options that suit your situation.

Networking MySQL

When connecting to a MySQL database you normally have two options, A TCP/IP port (3306) or a unix socket (/var/run/mysql/mysql.sock). Usually your webserver and users are on the same host so the most secure method is to use the Unix socket (this is the default in Slackware). If you do need to connect to the database over the network (The database not the webserver) then you'll need to comment the following line in /etc/rc.d/rc.mysqld:SKIP="--skip-networking" and then restart the mysqld service.

Putting it to use

Notes on installing applications

The instructions that come with most LAMP based software rarely take Slackware into account but armed with the knowledge gained from this article you should be able to get most things running.

Remember to specify the location of the Unix Socket and that your "root" database password is different than your system one

A common issue that arises is the "short_open_tag" option this is disabled by default as it forces more portable coding practices. If you are just seeing blank pages where you expected content, check that the "php tags" in the code are the long format
short tags example<? some php code(); ?>and the preferred long format tags<?php some php code(); ?>If you find the that the pages are full of short tags you'll need to edit the /etc/httpd/php.ini and setshort_open_tag = OnAnd restart the httpd service.

Remember: The log files are your first stop when trouble-shooting

Hopefully by now you are ready to make use of your server.

Stay Safe and have fun!

Written by John Jenkins <mrgoblin> ©2010