ConfigurationWith the software installed, we must finally turn your attention to configuration of it. Although we cannot give you a complete set of instructions about how to configure all the software (each of these packages has its own copious documentation on how to do this), we can provide some of the basics. Web ServerApacheYou configure the Apache Web Server via the httpd.conf file, found in the conf/ subdirectory of your Apache installation. It is an extremely well-documented file. We do note a few things of particular interest here. The ServerRoot directive should point to the location where Apache was installed, such as the following: ServerRoot "/usr/local/apache" After this, two directives concern how many processes the web server will manage on your system. The first, StartServers, indicates how many servers Apache will start when launching the server. The default value of 5 is typically quite sufficient. The server will quickly increase this number if it determines it needs more. The other end is the MaxClients directive, which indicates the maximum number of requests that can be serviced simultaneously. This should not be set too low, because any other requests will simply be denied. The default value of 150 is reasonable; if you expect a heavy load and are running a computer you are certain will be able to handle the load, however, you might want to consider increasing this. Do not forget that, because each process may make one or more connections to a database server, the number of simultaneous connections permitted by your database server should be at least one greater than this (so you can always make at least one administrative database connection). The following line indicates on which TCP port the server will listen. 80 is the standard for the HTTP protocol. It should not be changed unless you are running multiple servers simultaneously: Port 80 The ServerName directive is included for those systems where the server cannot determine its own name: ServerName www.cutefurrybunnies.com The final directive we mention is DocumentRoot, which tells the web server where to find the content for the site. By default, it is set to the installation location's subdirectory of htdocs/. You will most certainly want to change this to some other location. Internet Information Server ConfigurationBecause most of the configuration for Microsoft IIS is performed via the Microsoft Management Console, there is not much that remains mysterious as we navigate through the various dialog boxes. There is full context-sensitive help and plenty of instructions for each setting. Database ServerWe must next configure your database server. By default, MySQL is generally well configured after it has been installed. We will largely begin by making sure that we know where the configuration file is. We will make one change to it. On Windows systems, the MySQL configuration file is my.ini, which is usually found in the directory into which MySQL was installed. On Unix machines, there is no default configuration file, and you must copy one of the .cnf files in the support-/files/015/ subdirectory of the installation to the data/ directory. (You can also put it in /etc if you want.) Start with the my-medium.cnf file because it roughly matches our basic use of the server. root@host# cp support-/files/015/my-medium.cnf data/my.cnf Both of these files come with a number of settings, including to what TCP port database connections should be made (default of 3306), and information about table sizes and buffers. One setting in which we are particularly interested, however, is the max_connections setting. On Windows, the default value is 100, which is less than the default number of connections for Apache (150) and much less than that for IIS (which is a very large number). You should at least set this to some value that we think your server can handle, or greater than the number of web servers that Apache will spawn: max_connections=151 Do not forget to add one extra connection because MySQL defaults to reserving one for a command-line connection so that an administrator can always attempt to access the system. Another option you see is the default-storage-engine directive, which says which table type will be used by default. In older versions of MySQL, this was MyISAM, but newer versions with transaction support now list InnoDB. Either way, you should be aware of this so that you know what type of tables are creating your databases. default-storage-engine=INNODB Finally, one extra security enhancement you can make arises when we run your web server and MySQL database on the same machine. In this case, you can configure MySQL to refuse network connections and only accept connections from the local host. To support this, you must add the following options to the my.ini or my.cnf files: skip-networking enable-named-pipe Forgetting the second option makes all programs unable to communicate with the server on Windows platforms. PHPPHP ships with two php.ini files when you download and install itphp.ini-dist and php.ini-recommended. The former is more suited to development purposes; the latter is better used for production environments. On Unix systems, PHP typically looks for php.ini in /usr/local/lib, whereas on Microsoft Windows systems it looks in the PHP installation directory (for example, C:\PHP) or in C:\Windows. Most versions of Mac OS X include php.ini (or php.ini.default) in /private/etc, but this is for the version of PHP4 that ships with the operating system. In the example shown previously in this chapter to install PHP5 to /usr/local/php5, you would find php.ini in /usr/local/php5/lib. What follows is a list of "core" settings of php.ini, including the values we will use and where these are discussed in greater length in the book:
We visit a few other php.ini configuration variables in the various chapters, but the preceding list represents most of the critical values that we use with our applications. |