Posted by ncb on Wed 22 Feb 2006 at 09:10
This documents my adventure setting up a LAMP server on Sarge with Apache2, PHP5, MySQL5, phpMyAdmin, Smarty, and ADODB. It covers installation and just enough sample code to test everything. It turned out to be pretty long. I should point out that I have deviated from the "Debian Way" by downloading phpMyAdmin, Smarty, and ADODB directly from their respective websites and installing them in /usr/local. I could find no backports for these, and kept running into dependecies on PHP4 which I did not want to install.
Contents
What I Installed and Where I Got It.
Note: The PHP folks say it's a bad idea to use the threading Apache2, so I used the MPM prefork version from Sarge. For more info read the FAQ "Why shouldn't I use Apache2 with a threaded MPM in a production environment?". Also there is the MPM prefork info provided by Apache.
As noted above, this is the MPM prefork version available in Sarge. I'm also installing some of the packages it recommends. No changes are required to /etc/apt/sources.list for this.
$> apt-get update $> apt-get upgrade $> apt-get install apache2-mpm-prefork apache2-doc lynx ca-certificates.
Before we start messing with it, you might as well check that Apache is working. Point a browser at www.yourdomain.com and verify that you see the installed default Apache site. If you don't, check your DNS and firewall. Fix whatever the problem is before you go on.
I decided on these security tweaks from reading the security tips on the Apache site. You can add these to the main config file, but I opted to keep my own config changes separate by putting them in a file in the /etc/apache2/conf.d/ directory. I created a file there named local_configs.conf and put the following in it.
# Tighten access to the file system.
<Directory />
# Forbid default access to file system locations
Order Deny,Allow
Deny from all
# prevent use of .htaccess files in all directories
# apart from those specifically enabled.
AllowOverride None
</Directory >
# Limit available info about this server.
ServerSignature Off
ServerTokens production
Don't forget to reload Apache after changing the config.
The Debian installation of Apache2 comes all set up do "name-based" virtual hosting right out of the box. This is perfect if you have more than one domain to host on your server, or plan to in the future. For the uninitiated, here's a quick rundown on virtual hosting.
Virtual hosting refers to the practice of running more than one web site (domains) on a single server. The fact that they are running on the same physical server is not apparent to the end user. There are two types of virtual hosting, IP-based and name-based.
IP-based virtual hosting is when you have a different IP address for every domain. We'll not be doing it in this HOWTO.
Name-based virtual hosting is when you have multiple domains running from one IP address, and is what we will be using here. This means that the DNS A records (or CNAME records) for www.company1.com and www.company2.com can both point to the one IP address of your server, and Apache will sort out which site to serve up based on the domain that was requested. If someone points their browser at the IP address of your server, e.g. http://123.456.123.45, they will be served the first site that you have configured. Unless you change it, this will be the Apache default site as it is installed by Debian's Apache2 package.
For more info on virtual hosting, read the Apache docs.
Setting up a name-based virtual site is easy once you understand the layout a bit. I suggest you scan the file /etc/apache2/README. It's pretty short and clear. For the impatient, here are just the things we are going to touch to get one name-based virtual site up. I'll use "mydomain.com" as the virtual domain in all the examples.
First, create a subdirectory of /var/www/ to contain the site. It makes sense to name this directory after the domain that will live there.
$> mkdir /var/www/mydomain.com
Now create the subdirectory /var/www/mydomain.com/docs/. This will be the only directory that is publicly accessible.
$> mkdir /var/www/mydomain.com/docs
Now create /var/www/mydomain.com/docs/index.html, something simple like the following:
<html> <head> <title>Mydomain.com test index page</title> </head> <body> <h1>Hello World!</h1> </body> </html>
Now create /etc/apache2/sites-available/mydomain.com. We use the <VirtualHost> directive to define the virtual site, and the <Directory> directive to define the ...xxx/docs/ directory as publicly accessible (Allow from all). Like so:
<VirtualHost * >
#Basic setup
ServerAdmin webmaster@mydomain.com
ServerName www.mydomain.com
DocumentRoot /var/www/mydomain.com/docs
<Directory /var/www/mydomain.com/docs>
Order Deny,Allow
Allow from all
# Don't show indexes for directories
Options -Indexes
</Directory>
</VirtualHost>
Now, to enable the site you use the a2ensite command (Note:use a2dissite to disable). The following creates a symlink /etc/apache2/sites-enabled/mydomain.com, which enables the site.
$> a2ensite mydomain.com
You need to reload Apache to see the site...
$> /etc/init.d/apache2 reload
If DNS is working, you should now be able to point your browser at www.mydomain.com see the index.html page you created above.
There are a few other things I noticed that might be useful to someone. Here they are in no particular order.
We need to add one the dotdeb.org mirrors to sources.list for this. The mirrors are listed at www.dotdeb.org/mirrors. I chose one from Germany by adding the following to /etc/apt/sources.list
# Use dotdeb.org for LAMP related packages not available in Sarge deb http://dotdeb.pimpmylinux.org/ stable all deb-src http://dotdeb.pimpmylinux.org/ stable all
Now, thanks to Guillaume Plessis of dotdeb.org, installing PHP5 on Sarge is easy.
$> apt-get update $> apt-get install libapache2-mod-php5
There is a sample php config provided in /usr/share/doc/php5-common/examples/php.ini-recommended. It contains the "warmly recommended" php.ini settings for production servers. I chose to use this config file instead of the installed default. This is a very well commented file and worth the time to read. If you want to use this recommended config instead of the default, first save a copy of the original php.ini file, like so ..
$> mv /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.original
... and then put the recommended file in place of the original file.
$> cp /usr/share/doc/php5-common/examples/php.ini-recommended \ /etc/php5/apache2/php.ini
Now, like we did with Apache, let's hide info about our php config by telling PHP to hide itself. Open up php.ini in your favorite editor and set expose_php to off.
expose_php = off
Also, I plan to follow the convention of naming all php include files with the .inc extension. For good measure, I want Apache to hide these by default, so I add this to the /etc/apache2/conf.d/local_configs.conf file I created earlier (this is the same way .htaccess files are protected in the main Apache config file).
# Hide all files with the .inc extension.
<Files *.inc>
Order allow,deny
Deny from all
</Files *.inc>
Thanks (again) to the dotdeb.org mirror we have already added, this is easy. apt-get will find the latest version there.
$> apt-get install mysql-server
Don't forget to set a password for the MySQL root user. Do the following, replacing "secret" with your chosen password, and make it a good one.
$> /usr/bin/mysqladmin -u root password 'secret'
Note: It would be wise to create a non-root user for MySQL having just the MySQL permissions absolutely necessary to the PHP applications you are going to write. I'm using the root user for the purposes of this howto.
Also grab the php5 mysql extensions from dotdeb.org:
$> apt-get install php5-mysql
Let's create a quick database and table to both verify that MySQL is working, and give us something to test ADODB with later. At a command line, login to MySQL.
$> mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1920 to server version: 5.0.18-Debian_3.dotdeb.1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Now we will, 1) create a database 2) tell MySQL to "use" the database 3) create a table, and 4) insert a couple of records into the table. You should be able to copy and paste these commands at the mysql prompt. BTW, I stole this example out the MySQL Reference Manual.
mysql> CREATE DATABASE mydomain;
Query OK, 1 row affected (0.00 sec)
mysql> USE mydomain;
Database changed
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO pet VALUES ('Libby','Diane','dog','f','2001-04-15',NULL);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM pet;
+----------+-------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
| Libby | Diane | dog | f | 2001-04-15 | NULL |
+----------+-------+---------+------+------------+-------+
2 rows in set (0.00 sec)
mysql> quit
Bye
I find the MySQL command line painful. phpMyAdmin makes it a lot easier, so let's install it.
phpMyAdmin is a great tool for creating and managing databases. As noted I could not find a backported package for it. So, I just downloaded and installed it directly from the phpMyAdmin site.
First we'll create a directory that's out of the way of Debian's package management system in /usr/local. We'll call it php5 since we'll be putting Smarty and ADODB files here as well.
$> mkdir /usr/local/php5
Now we untar phpMyAdmin in this directory (creates /usr/local/php5/phpMyAdmin-2.7.0-pl2), and remove the tar.gz file.
$> cp phpMyAdmin-2.7.0-pl2.tar.gz /usr/local/php5/ $> cd /usr/local/php5/ $> tar -zxvf phpMyAdmin-2.7.0-pl2.tar.gz $> rm phpMyAdmin-2.7.0-pl2.tar.gz
Note: I opt to leave the version info in the phpMyAdmin directory name so I can easily untar a new version right next it without blowing anything away.
The sample config file provided is config.default.php. We need to copy it to config.inc.php.
$> cd /usr/local/php5/phpMyAdmin-2.7.0-pl2/ $> cp config.default.php config.inc.php
Now we need to make a couple of changes to config.inc.php. First, let's define the URI we'll be using to access PhpMyAdmin (this is not the path to the phpMyAdmin directory, but rather the alias we will use for it in the Apache config). Find the following line,
$cfg['PmaAbsoluteUri'] = '';
and change it to something like this.
$cfg['http://www.mydomain.com/phpmyadmin'] = '';
Next we need to choose an auth type. The three options are 'config', 'http', and 'cookie'. The 'config' option is the default, and requires you to keep your MySQL password right here in this file, which I don't like. The 'http' option prompts you for the password when you access PhpMyAdmin, but will send the password in clear text, which I also don't like. The 'cookie' option is the best I think, and allows you to define a passphrase with the [blowfish_secret] parameter, which phpMyAdmin will use to encrypt the password in a cookie when you log in. To use the 'cookie' auth type, we need to make two changes. First, find the section of the file that looks like this:
/** * The 'cookie' auth_type uses blowfish algorithm to encrypt the password. If * at least one server configuration uses 'cookie' auth_type, enter here a * passphrase that will be used by blowfish. The maximum length seems to be 46 * characters. */ $cfg[''] = '';
You need to change this line ..
$cfg[''] = '';
.. to something like the following. Note that you have to add the "blowfish_secret" part within the brackets (I don't know why). Note also that you will not be prompted for the passphrase you enter here, so feel free to make it a real ugly one.
$cfg['blowfish_secret'] = 'some_passphrase_under_46_characters_long';
Then find this line ..
$cfg['Servers'][$i]['auth_type'] = 'config';
... and change the auth type from 'config' to 'cookie', like so ..
$cfg['Servers'][$i]['auth_type'] = 'cookie';
That's it. Save the file.
Configuring Apache to Display phpMyAdmin
Now we need to tell Apache where phpMyAdmin lives, and also create an Apache alias for the phpMyAdmin directory (so we don't have to remember to type "phpMyAdmin-2.7.0-pl2" into the browser all the time). Also, since I don't want anyone else to even try logging in to phpMyAdmin, I will restrict access to just the IP address of my own workstation. To do all this we just need to add a small section to the file /etc/apache2/sites-available/mydomain.com that we created earlier. Add a section like the following, remebering to change the IP address to something appropriate.
# Provide an alias to phpmyadmin
Alias /phpmyadmin /usr/local/php5/phpMyAdmin-2.7.0-pl2
<Directory /usr/local/php5/phpMyAdmin-2.7.0-pl2>
# Restrict phpmyadmin access to just my worksation
Order Deny,Allow
Deny from all
Allow from 192.168.1.2
</Directory>
Reload Apache, and you should be able to point your browser at www.mydomain.com/phpmyadmin and login as the MySQL root user.
Smarty is a template engine for PHP. It allows you to separate your presentation code (html) from the logic (php) in your web applications. If you don't know why this is important to do, then develop a great big web site with a whole bunch of PHP applications, wait long enough to forget how you did everything, and then try to redesign the site. Or, just read Smarty's Why Use It page. They explain it better than I can.
As previously noted I could not find a backport for Smarty, so I just downloaded the latest version from here. Once you have the tar.gz let's untar it in the /usr/local/php5 directory we created earlier.
$> cp Smarty-2.6.12.tar.gz /usr/local/php5/ $> cd /usr/local/php5/ $> tar -zxvf Smarty-2.6.12.tar.gz $> rm Smarty-2.6.12.tar.gz
Now edit /etc/php5/apache2/php.ini and add the Smarty /libs subdirectory to the php_include_path, like so:
include_path = ".:/usr/local/php5/Smarty-2.6.12/libs"
Remember, whenever you make a change to php.ini you need to reload Apache.
Now we will create the four directories that Smarty needs to function and set the permissions on them. This is basically right out of the Smarty site's Quick Install page.
cd /var/www/mydomain.com $> mkdir smarty $> mkdir smarty/templates $> mkdir smarty/templates_c $> mkdir smarty/cache $> mkdir smarty/configs $> chown www-data:www-data smarty/templates_c $> chown www-data:www-data smarty/cache $> chmod 775 smarty/templates_c $> chmod 775 smarty/cache
Note: The Smarty documentation says to keep these directories out of the doc root. These are not in our doc root because we defined the doc root for mydomain.com as /var/www/mydomain.com/docs/. It is therefore important to remember not to change the doc root to /var/www/mydomain.com/, which would expose these directories to the world. You can of course put these directories anywhere else you want. My reason for placing them here is that I find it convenient to have just one directory (/var/www/mydomain.com/) containing everything related to the content of a domain.
Now let's make a test PHP app. First make a directory for it to live in.
$> mkdir /var/www/mydomain.com/docs/myapp/
Then create a file named index.php in that directory containing the following:
<?php
// Include Smarty.class.php (this is /usr/local/php5/Smarty-x.x.x/Smarty.class.php)
// The full path is not needed here because it is defined in php.ini's include_path.
require('Smarty.class.php');
// Initialize smarty paths
$smarty = new Smarty;
$smarty->template_dir = '/var/www/mydomain.com/smarty/templates/';
$smarty->compile_dir = '/var/www//mydomain.com/smarty/templates_c/';
$smarty->config_dir = '/var/www/mydomain.com/smarty/configs/';
$smarty->cache_dir = '/var/www/mydomain.com/smarty/cache/';
// Set a smarty variable
$smarty->assign('name', 'Johnny');
// Display the smarty template
$smarty->display('myapp_index.tpl');
?>
Now we need to make a template, called myapp_index.tpl, in the directory /var/www/mydomain.com/templates/. Something like the following:
<html>
<head>
<title>Smarty</title>
</head>
<body>
Hello, {$name}!
</body>
</html>
Now you should be able to display this template by pointing your browser at www.mydomain.com/myapp/ and see Hello, Johnny!
Now that we know it works, let's make our Smarty setup more flexible. We don't really want to define the smarty directory paths in every PHP script when we could just define them once in an include file. First let's make a new directory for it.
$> mkdir /var/www/mydomain.com/includes/
We also want to add this directory to the include_path in php.ini. Don't forget to reload Apache afterwards.
include_path = ".:/usr/local/php5/Smarty-2.6.12/libs:/var/www/mydomain.com/includes"
Now create the file /var/www/mydomain.com/includes/smarty_setup.inc and define the smarty directories in it.
<?php
// Include Smarty.class.php (this is /usr/local/php5/Smarty-x.x.x/Smarty.class.php)
// The full path is not needed here because it is defined in php.ini's include_path.
require('Smarty.class.php');
// Initialize smarty paths
$smarty = new Smarty;
$smarty->template_dir = '/var/www/mydomain.com/smarty/templates/';
$smarty->compile_dir = '/var/www//mydomain.com/smarty/templates_c/';
$smarty->config_dir = '/var/www/mydomain.com/smarty/configs/';
$smarty->cache_dir = '/var/www/mydomain.com/smarty/cache/';
?>
With this done, you can simplify /var/www/mydomain.com/myapp/index.php to look like this.
<?php
// Load Smarty setup
require('smarty_setup.inc');
// Set a smarty variable
$smarty->assign('name', 'Johnny');
// Display the smarty template
$smarty->display('myapp_index.tpl');
?>
This is much cleaner looking. More importantly, if there is ever a need to redefine the location of the smarty directories, the only file that will need editing is smarty_setup.inc, not every script ever written. We'll take the same approach with ADODB.
ADODB is a database abstraction class for PHP. It allows you to write PHP scripts that can easily be modified to work with several databases. Using it also has the effect of streamlining your PHP code for databases queries.
Installation is straightforward. Just download it, and untar it in /usr/local/php5 just as we did with Smarty and phpMyAdmin.
$> cp adodb471-1.tgz /usr/local/php5/ $> cd /usr/local/php5/ $> tar -zxvf adodb471-1.tgz $> rm adodb471-1.tgz
Add the adodb directory to php.ini's include_path, and remember to reload apache when you're done.
include_path = ".:/usr/local/php5/Smarty-2.6.12/libs:/usr/local/php5/adodb:/var/www/mydomain.com/includes"
Like we did for Smarty, we're going to make a setup file for ADODB that we can just include in the PHP scripts that will access the database. We'll call it adodb_setup.inc, and put it in the directory /var/www/mydomain/includes. Make it look like the following, changing "secret" to your MySQL root password, and "mydomain" to the name of your database:
<?php
// Load adodb libs from include_path
include('adodb.inc.php');
// Define the Data Source Name (DSN) for adodb
$dsn = 'mysql://root:secret@localhost/mydomain';
// Connect to database
// This makes the $db connection object available to scripts
$db = ADONewConnection($dsn);
?>
Note: Your MySQL password is right here in this file. Keep this file and the directory it lives in out of the doc root.
Now let's pull all this together. We'll go back to our myapp application and have it use ADODB syntax to make a database query. Then we'll display the results using a Smarty template.
First edit /var/www/mydomain.com/myapp/index.php to look like the following. Note that we are including the file adodb_setup.inc that we just created.
<?php
// Load Smarty setup
require('smarty_setup.inc');
// Load ADODB and make db connection
require('adodb_setup.inc');
// Tell adodb we want an associative array
$db->SetFetchMode(ADODB_FETCH_ASSOC);
// Query the pet table and assign the
// result set to the $rs variable
$rs = $db->Execute('select * from pet');
// Pass the result set to smarty
$smarty->assign('rs', $rs);
// Other vars for smarty
$smarty->assign('pg_title', 'MyApp');
$smarty->assign('name', 'Johnny');
// Display the smarty template
$smarty->display('myapp_index.tpl');
?>
Finally, edit the file /var/www/domain.com/smarty/templates/myapp_index.tpl to look something like the following, in which Smarty displays the $pg_title and $name variables passed from the PHP script, and also iterates through the database result set (the $rs variable), drawing an html table along the way.
<html>
<head>
<title>{$pg_title}</title>
</head>
<body>
<h1>{$pg_title}</h1>
<h2>Hello, {$name}.</h2>
<strong>Results of pet query</strong> <br />
<hr />
<table>
<tr>
<th>Pet Name</th>
<th>Owner</th>
<th>Species</th>
<th>Gender </th>
<th>Birth </th>
<th>Death </th>
</tr>
{foreach from=$rs item=pet}
<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}">
<td>{$pet.name}</td>
<td>{$pet.owner}</td>
<td>{$pet.species}</td>
<td>{$pet.sex}</td>
<td>{$pet.birth}</td>
{if !$pet.death}
<td>Still kicking</td>
{else}
<td>{$pet.death}</td>
{/if}
</tr>
{/foreach}
</table>
</body>
</html>
The resulting html from this should look something like the following:
<html>
<title>MyApp</title>
</head>
<body>
<h1>MyApp</h1>
<h2>Hello, Johnny.</h2>
<strong>Results of pet query</strong> <br />
<hr />
<table>
<tr>
<th>Pet Name</th>
<th>Owner</th>
<th>Species</th>
<th>Gender </th>
<th>Birth </th>
<th>Death </th>
</tr>
<tr bgcolor="#eeeeee"}">
<td>Puffball</td>
<td>Dianne</td>
<td>hamster</td>
<td>f</td>
<td>1999-03-30</td>
<td>Still kicking</td>
</tr>
<tr bgcolor="#d0d0d0"}">
<td>Libby</td>
<td>Dianne</td>
<td>dog</td>
<td>f</td>
<td>2001-04-15</td>
<td>Still kicking</td>
</tr>
</table>
</body>
</html>
Pretty cool eh? Well whether you think that's cool or not, pat yourself on the back for getting this far. My next howto is going to be shorter for sure.
[ Parent ]
[ Parent ]
[ Parent ]
I configure my web sites as:
/srv/www/www.cswd.co.uk/htdocs/ /srv/www/www.cswd.co.uk/logs/
I am migrating to the FHS standard though which is:
/srv/cswd.co.uk/httpd/www/htdocs/ /srv/cswd.co.uk/httpd/www/logs/
I think this is a better approach as if someone needs to access something remotely, you have to either symlink into the var tree or let other users browse var. This way you can force them into /srv/domain!
Hope this helps.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Just as an aside, using dpkg -l | grep php will show incomplete results. The package names get truncated, and often remove the string you are grep'ing for. For example, in the following the libapache2-mod-php5 that I know is installed is missing from the output.
# dpkg -l | grep php ii php5-common 5.1.2-1.dotdeb Common files for packages built from the php ii php5-mysql 5.1.2-1.dotdeb MySQL module for php5
A slightly better way is to pass the search string to dpkg rather than to grep, and then grep for lines starting with ii. This still cuts off the package names, but at least you get a complete list. Like so ...
# dpkg -l *php* | grep ^ii ii libapache2-mod 5.1.2-1.dotdeb PHP 5 scripting language - apache 2.0 module ii php5-common 5.1.2-1.dotdeb Common files for packages built from the php ii php5-mysql 5.1.2-1.dotdeb MySQL module for php5
A still better way is to set the bash COLUMNS var higher so the package names don't get truncated in the first place.
# COLUMNS=110 dpkg -l *php* | grep ^ii ii libapache2-mod-php5 5.1.2-1.dotdeb.2 PHP 5 scripting language - apache 2.0 module ii php5-common 5.1.2-1.dotdeb.2 Common files for packages built from the php5 source ii php5-mysql 5.1.2-1.dotdeb.2 MySQL module for php5
[ Parent ]
[ Parent ]
[ Parent ]
Nicely done.
The editting system will be improved in the future, it was just a quick hack to give authors the ability to fix up mistakes without having to wait for me to do it.
For what its worth there are backups kept of articles, edits, and other things - so had things gone horribly wrong I could have restored it.
[ Parent ]
[ Parent ]
I'm not sure if you're referring to the mysql-client package or the libmysqlclient14/15 packages. Here's a list of everything having to do with mysql on my system. Does yours look the same?
# COLUMNS=128 dpkg -l *mysql* | grep ^ii ii libdbd-mysql-perl 2.9007-0.dotdeb.0 ii libmysqlclient14 4.1.15-0.dotdeb.1 ii libmysqlclient15 5.0.18-3.dotdeb.1 ii mysql-client-5.0 5.0.18-3.dotdeb.1 ii mysql-common 5.0.18-3.dotdeb.1 ii mysql-server 5.0.18-3.dotdeb.1 ii mysql-server-5.0 5.0.18-3.dotdeb.1 ii php5-mysql 5.1.2-1.dotdeb.2
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
You're welcome. I'm glad it was helpful.
I'm sorry I don't know which development libraries you mean. If you can figure out the package name for what you want then you may be able to install it with apt-get.
If the package you are after is libmysqlclient15-dev then just apt-get install libmysqlclient15-dev will pull that package in from dotdeb.org.
You can browse dotdeb's repository at packages.dotdeb.org.
[ Parent ]
[ Parent ]
If you want to know what all the available mysql-related Debian packages are, try going to www.debian.org/distrib/packages#search_packages, type "mysql" in the box, hit the search button and enjoy. Maybe scan the results for the words "development" or "library".
I'd guess what you want is libmysqlclient14-dev and/or libmysqlclient15-dev, both of which will be pulled from dotdeb.org if you've added it to sources.list.
There are lots of mysql related packages and I'm not familiar with most of them. I'm not aware however of a libmysql-server package or the like. I'd guess your irc app is going to be acting in the role of a client though, so ...
Hope that helps.
[ Parent ]
[ Parent ]
"Had to enable mysql for php in php.ini"Interesting. I didn't have to do that. I assume it was done for me by one of the package installs along the way. Maybe we did things in a different order?
"also noticed that smarty is looking for myapp_index.tpl in the smarty templates dir not /var/www/mydomain.com/templates unless I missed something."
Hm. Looks like you're missing the "smarty" subirectory in that path. Maybe that's the problem. Following the instructions in this article, where smarty looks for the templates should be determined by the file /var/www/mydomain.com/includes/smarty_setup.inc, which has this....
// Initialize smarty paths
$smarty = new Smarty;
$smarty->template_dir = '/var/www/mydomain.com/smarty/templates/';
$smarty->compile_dir = '/var/www//mydomain.com/smarty/templates_c/';
$smarty->config_dir = '/var/www/mydomain.com/smarty/configs/';
$smarty->cache_dir = '/var/www/mydomain.com/smarty/cache/';
So, as long as php.ini's include_path contains /var/www/mydomain.com/includes (so php can find smarty_setup.inc), and smarty_setup.inc is included in the php script with require('smarty_setup.inc';, then smarty should be looking in /var/www/mydomain.com/smarty/* for it's directories.
Hope that helps.
[ Parent ]
[ Parent ]
I think you may indeed have an error in your config.inc.php file. If you followed this howto then that file should be at /usr/local/php5/phpMyAdmin-2.7.0-pl2/config.inc.php. Do like it says and check for semicolons etc wherever you made a change.
You can try a tail -f /var/log/apache2/error.log while attempting to load phpmyadmin and you may see an error telling you what line number of the file contains the error.
The reason you are not seeing the error in the browser BTW is because of the display_errors = Off setting in php.ini. This is one of the recommened settings for security reasons. Set it to on if you don't want to have to check the log for errors.
Hope that helps. Please post again if it doesn't.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Hm, I didn't run into that. I just today did apt-get update/upgrade on the box I used when writing the article and had success. I ended up with mysql-server-5.0.21-2, and (only) libc6-2.3.2.
There was one hiccup. Initially, after apt-get upgrade, the mysql-server-5.0 and mysql-client-5.0 packages would not upgrade because they wanted the new package libmysqlclient15off. To fix that I just did "apt-get install libmysqlclient15off" which removed the old libmysqlclient15 package, installed the new libmysqlclient15off package from the dotdeb repository, and then proceeded in upgrading mysql-server-5.0 etc.
Here's a list of the installed packages/versions related to mysql after the upgrade.
libdbd-mysql-perl 2.9007-0.dotdeb.0 libmysqlclient14 4.1.15-0.dotdeb.1 libmysqlclient15off 5.0.21-2.dotdeb.1 mysql-client-5.0 5.0.21-2.dotdeb.1 mysql-common 5.0.21-2.dotdeb.1 mysql-server 5.0.21-2.dotdeb.1 mysql-server-5.0 5.0.21-2.dotdeb.1 php5-mysql 5.1.4-1.dotdeb.2
Also note that the mysql-server-5.0 package I ended up with requires only libc6 >= 2.3.2, which I verified with the command "dpkg-query -s mysql-server-5.0".
So, I don't know what's wanting the higher verison of libc6, but as far as I can tell it's not any of the packages from dotdeb.org that I used for this article. Are you sure you aren't pointing at a testing or unstable repository in your sources.list file? Mine looks like this:
deb http://debian.oregonstate.edu/debian/ stable main deb-src http://debian.oregonstate.edu/debian/ stable main deb http://security.debian.org/ stable/updates main # For any volatile packages deb http://volatile.debian.net/debian-volatile stable/volatile main # Add dotdeb so we can get php5 and stuff that debian stable lacks # See http://www.dotdeb.org/ deb http://dotdeb.pimpmylinux.org/ stable all deb-src http://dotdeb.pimpmylinux.org/ stable all
Hope that helps.
[ Parent ]
$> apt-cache policySample Output:
990 http://security.debian.org sarge/updates/main Packages release v=3.1,o=Debian,a=stable,l=Debian-Security,c=updates/main origin security.debian.org 500 http://dotdeb.pimpmylinux.org stable/all Packages release o=packages.dotdeb.org,a=sarge,l=packages.dotdeb.org origin dotdeb.pimpmylinux.org 990 http://debian.oregonstate.edu stable/main Packages release v=3.1r4,o=Debian,a=stable,l=Debian,c=main origin debian.oregonstate.edu(From Left to Right, Down) This displays the priority number in which candidate sources are selected by apt, the magical mirror line, and pertinent identification information for each deb mirror.
$> apt-cache policy mysql-serverSample Output:
Installed: None
Candidate: 4.0.24-10sarge2
Version Table:
5.0.26-0.dotdeb.1 0
500 http://dotdeb.pimpmylinux.org stable/all Packages
100 /var/lib/dpkg/status
4.1.15-0.dotdeb.4 0
500 http://dotdeb.pimpmylinux.org stable/all Packages
4.0.24-10sarge2 0
990 http://debian.oregonstate.edu stable/main Packages
990 http://security.debian.org sarge/updates/main Packages
Notice how apt selected the distro with the highest priority and not the Dotdeb distro for MySQL5.Package: * Pin: origin dotdeb.pimpmylinux.org Pin-Priority: 2000Explanation:
Package: [wildcard for all packages or you can list specific pkg names] Pin: origin [dotdeb mirror here] Pin-Priority: [any number larger than other priorities (i.e. 990, etc.)]Now run the apt-cache policy commands again. Notice the difference?
[ Parent ]
[ Parent ]
[ Parent ]
Now we need to make a template, called myapp_index.tpl, in the directory /var/www/mydomain.com/templates/. Something like the followingShould be replaced by:
Now we need to make a template, called myapp_index.tpl, in the directory /var/www/mydomain.com/smarty/templates/. Something like the followingYou forgot to add the smarty directory.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
ii libapache2-mod-php5 5.1.4-1.dotdeb.2 PHP 5 scripting language - apache 2.0 module ii php5-cgi 5.1.4-1.dotdeb.2 PHP 5 scripting language ii php5-common 5.1.4-1.dotdeb.2 Common files for packages built from the php5 source ii php5-dev 5.1.4-1.dotdeb.2 Files for PHP5 module development ii php5-gd 5.1.4-1.dotdeb.2 GD module for php5 ii php5-mcrypt 5.1.4-1.dotdeb.2 MCRYPT module for php5 ii php5-mysql 5.1.4-1.dotdeb.2 MySQL module for php5 ii phpmyadmin 2.8.1-1 set of PHP-scripts to administrate MySQL over the WWWbut the phpinfo() out put shows the php5-mysql module was not compiled (just as someone posted in the previous comment), even worse is that I couldn't see mysql part down below the output neither, that being said, the module IS NOT working. I wonder what can I do to fix this problem? I alreadly tried to reinstall php5-mysql, to no avail. Maybe I should reinstall some other packages as well? Thanks, FYI:
'../configure' '--prefix=/usr' '--with-apxs2=/usr/bin/apxs2' '--with-config-file-path=/etc/php5/apache2' '--enable-memory-limit' '--enable-inline-optimization' '--disable-debug' '--with-regex=php' '--disable-rpath' '--disable-static' '--with-pic' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--enable-dbase' '--with-gettext' '--enable-mbstring' '--with-pcre-regex' '--enable-pdo' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-simplexml' '--with-libxml-dir=/usr' '--with-dom=/usr' '--with-xsl=/usr' '--with-sqlite' '--enable-sqlite-utf8' '--enable-wddx' '--enable-tokenizer' '--with-xmlrpc' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--enable-dbx' '--with-mime-magic=/usr/share/misc/file/magic.mime' '--with-exec-dir=/usr/lib/php5/libexec' '--without-mm' '--without-mysql' '--without-pdo-sqlite' '--without-sybase-ct'
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
www:~# apt-get -s install phpmyadmin Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: apache-common libapache-mod-php4 libzzip-0-12 php4 php4-common ucf Suggested packages: apache apache-ssl apache-perl php4-pear php4-gd php5-gd Recommended packages: debconf-utils The following NEW packages will be installed: apache-common libapache-mod-php4 libzzip-0-12 php4 php4-common phpmyadmin ucf 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Inst ucf (1.17 Debian:3.1r2/stable) Inst apache-common (1.3.33-6sarge1 Debian:3.1r2/stable, Debian-Security:3.1/stable) Inst libzzip-0-12 (0.12.83-4 Debian:3.1r2/stable) Inst php4-common (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Inst libapache-mod-php4 (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Inst php4 (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Inst phpmyadmin (4:2.6.2-3sarge1 Debian:3.1r2/stable, Debian-Security:3.1/stable) Conf ucf (1.17 Debian:3.1r2/stable) Conf apache-common (1.3.33-6sarge1 Debian:3.1r2/stable, Debian-Security:3.1/stable) Conf libzzip-0-12 (0.12.83-4 Debian:3.1r2/stable) Conf php4-common (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Conf libapache-mod-php4 (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Conf php4 (4:4.4.2-0.dotdeb.2 packages.dotdeb.org:sarge) Conf phpmyadmin (4:2.6.2-3sarge1 Debian:3.1r2/stable, Debian-Security:3.1/stable)
[ Parent ]
[ Parent ]
apt-get -s remove apache-common libapache-mod-php4 libzzip-0-12 php4 php4-common ucf
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
In my default installation of Apache 2 on Debian Sarge, apache2.conf states:
Include /etc/apache2/conf.d/[^.#]*
This means that Apache will only include files without the period or hash characters - conf.d/local_configs.conf will therefore not get included (unless you've changed apache2.conf, which I didnt notice).
Noticed this when I found error pages were ignoring my ServerTokens directive. Rename it to local_configs and you'll be ok. Check your configs.
[ Parent ]
Having looked into this in more detail, it appears that I was wrong. I assumed it was a regular expression which would explain why my file wasn't being loaded. However, according to the apache docs, include uses fnmatch, so I can't see why it would ever treat it like that. I was very probably just reloading the wrong server... so just ignore me ;)
May be worth noting though that it will ignore files starting with a period or a hash character.
[ Parent ]
[ Parent ]
Excellent article. Thanks for the help. Was able to complete a migration between Debian servers thanks to your well written work.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
deb http://dotdeb.pimpmylinux.org/ sarge all deb-src http://dotdeb.pimpmylinux.org/ sarge allI'll probably leave it like this until I can figure out how to safely upgrade my blade to Etch.
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
-fer
[ Parent ]