Adding this script to the startup transaction is a more complex task. If you're not using Redhat Linux and you're not sure about doing it, you'd better ask someone who knows. In Redhat Linux, execute the following command (in the MySQL directory) to complete the job:% CP share/mysql/mysql.server/etc/rc.d/init.d/% CD/ETC/RC.D/INIT.D% chmod 50 0 mysql.server% CD/ETC/RC.D/RC3.D% ln-s. /init.d/mysql.server s99mysql% CD/ETC/RC.D/RC5.D% ln-s. /init.d/mysql.server S99mysql Now it's all done! To test this job, you can restart your system and make a request for the service to see if it is working properly. Installing PHP under Linux as we mentioned earlier, PHP is not a standalone program. It is actually a plugin for your Web service (possibly Apache). You actually have three ways to install PHP plugins in Apache: As a CGI program, Apache runs it every time you need to process a PHP page. Compiled as a module into the Apache program. Loaded as a module in Apache every time it is started. The first method is the simplest to install and configure, but this requires Apache to call PHP as a program every time a request is received from a PHP page. This will certainly reduce the response time of your Web server, especially if more than one request is received at the same time. The second and third methods are equally good in terms of performance, but it's likely that you've already installed Apache, and you probably don't want to download it again and recompile and reinstall it. Therefore, we use a third method. First, we download the PHP package from http://www.php.net/(or one of the mirror sites listed in http://www.php.net/mirrors.php). When we were writing this tutorial, PHP 4.0 was basically ripe. I have tried PHP 4.0-rc2 myself, and I have not encountered any problems. It is estimated that the final stable version will be released soon (maybe we haven't finished the tutorial yet), and I suggest you install the latest version so that you don't have to make any changes when the official version comes out. Here we have installed 3.0, and I will note that 3.0 and 4.0 may be different at the time of installation. The file name of the file you downloaded is Php-versiOn.tar.gz. Our first step is to untie this file:% tar xfz php-version.tar.gz% CD php-version to install PHP as an Apache-installable module, you need Apache's APXS program. The program should be included in the vast majority of Apache versions, but if you are using a copy of the Redhat Linux installation, you will need to install the Apache advanced RPM package to get it. You can find this package from your Redhat CD and you can also download it from http://www.redhat.com/. By default, Redhat will install this program to/USR/SBIN/APXS. If you see this file, it proves that it has been installed. During this installation, you must be logged in as Superuser, which includes some changes to the Apache configuration file. The next step is to configure the PHP installer so that it knows which options to choose and where to look for the programs it needs (such as Apache and MySQL). Unless you're sure, you just enter the following command (on the same line):%./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php-- With-apxs=/usr/sbin/apxs--enable-track-vars--enable-magic-quotes--enable-debugger If you already have PHP installed 3.0 (not 4.0 or later), you'll also need to tell it where to look for MySQL in your system with the following additional parameters:--with-mysql=/usr/local/mysql/you go back to the command prompt after several screens of tests on the monitor. The following two commands compile and install PHP:% make% make install PHP is now installed in/usr/local/php (unless you specify a different directory by the/configure--prefix parameter above). You should be able to find a configuration file named PHP.ini in the same directory (unless you specify a different directory through the/configure--with-config-file-path parameter above). PHP provides a php.ini module file whose file name is php.ini-optimized (php.ini-dist in PHP3.0). Copy this file to the appropriate directory: % CP Php.ini-optimized/usr/local/php/php.ini for PHP 3.0:% CP Php.ini-dist/usr/local/php/php.ini You don't worry about php.ini tuning for the time being 。 Now, we need to make sure that Apache knows where to find PHP, so it can load it at startup. Use your familiar text editor to open your Apache httpd.conf configuration file (in Redhat Linux, in/etc/httpd/conf/httpd.conf). Look for a line like this: LoadModule php4_module lib/apache/libphp4.so If you are installing PHP 3.0, the PHP4 in this line is replaced by PHP3. What you're looking for is a new, non-annotated line (not a line that starts with a #), not the one you commented out earlier. In general, it is displayed with other loadmodule lines in the file. When you find it, you need to change the path so that it can match all the other loadmodule lines in the file. Under Redhat Linux, this means changing this line to: LoadModule php4_module modules/libphp4.so Then, look for lines that start with DirectoryIndex. This line tells Apache what file name to use when looking for a default page for a given directory. Typically, you'll see index.html and some other filenames, and you'll need to add index.php and index.php3 to this line: DirectoryIndex index.html index.cgi ... index.php Index.php3 Finally, go to the end of this file and add a new line to tell Apache which file extensions are treated as PHP files: AddType application/x-httpd-php. phtml. php. PhP3 after everything is done, save the changes and restart your Apache service. Apache should not have any error messages when it starts. Post-installation settings when both PHP and MySQL are installed, the first thing is to set a "root password" for MySQL, whether you're under Windows, Linux, or another operating system. MySQL only allows authorized users to access and manipulate the information stored in its database, so you must let MySQL know who is authorized and who is unauthorized. When MySQL is installed for the first time, itGenerates a user named "root" that can access everything without a password. Your first task is to set a password for the root user so that no one can mess up your database. You have to realize the importance of MySQL, just like Web services and FTP services, that can be accessed by any machine on the same network. If you work on a computer connected to the Internet, that means anyone in the world can try to connect to your MySQL server! You must immediately choose a hard-to-guess password! To set the root password in MySQL, enter the following command (including quotation marks) under the bin subdirectory of the directory where you installed MySQL: mysqladmin-u root password "Your new password" to make sure that MySQL accepts this change, You have to tell it. Reload the list of arguments for the user and password: mysqladmin-u root Reload if the command displays an error message telling you that you can't access it, don't worry, it just proves that the password is already in effect. To test your new password, you can request the MySQL server to tell you about its current status: Mysqladmin-u root-p status When prompted, enter the password. You'll see some simple information that contains the current state of the service. The-u root parameter tells the program that you want to log in as a "root" user. The-p parameter tells the program to prompt you to enter your password before connecting. The status parameter tells the program that you want to see the system state. If you need to close the MySQL server, you can use the following command. Note the meaning of the-u root and-p parameters here is the same as mentioned above: Mysqladmin-u root-p shutdown Now that your MySQL database system is running safely, now the rest of the work is to configure PHP. PHP is configured with a text file called PHP.ini. If you are installing PHP under Windows, you should have copied the php.ini to your Windows directory. If you are using the instructions above to install PHP on Linux, you should have copied the php.ini to the PHP installation directory (/usr/local/php). Open the php.ini with your familiar text editor and skim through it. The vast majority of settings have been well described, and the vast majority of default settings can be adapted to your requirements. Just check and verify that your configuration matches the following: MAGIC_QUOTES_GPC = Ondoc_root = Extension_dir = If you are running PHP 4.0, you also need to check the following line: Register_globals = On if you are running PHP 3.0 under Windows, remove the ";" from the beginning to uncomment the following line (4.0 not required): Extension=php_ Mysql.dll Save the changes to the php.ini, and then restart your Web server. Under Linux, if you are logged in as a superuser, you can restart Apache:/etc/rc.d/init.d/httpd Restart now everything is ready! Now the only thing left is to test and confirm that everything is OK (see your first PHP script). If your web host provides PHP and MySQL if the host that provides you with Web space has installed and set up MySQL and PHP for you, you just want to learn how to use them, and you need to do the facts in not much. You should now contact your hosting provider for information on how to access these services. Especially important, you need to get the username and password for the Access MySQL service that you set up for you. They may have set up an empty database for you (which will prevent you from confusing the database with other users on the same MySQL server), and you need to know the name of the database. There are two ways to access the MySQL service. The first approach is to use Telnet to log in to the host and use the MySQL client program (MySQL, mysqladmin, mysqldump, etc.) to directly interact with the MySQL service. The second option is to install those client programs on your own computer and connect to the MySQL server. Your web host may support one or both of these methods, so you have to ask first. If they support your work through Telnet login, you will also need a username and password to log in via Telnet (this username and password may not be the same as your access to the MySQL service). You have to ask these two setup messages clearly. If they support remote access to the MySQL service, you need to download a program to connect and interact with the server. This tutorial assumes that you have downloaded a set of MySQL client programs from http://www.mysql.com/. This package can be run under Windows or run under UNIX, and is free. The installation instructions contained in the package are very simple. If you prefer some graphical interface, you can download similar mysqlwinadmin for Windows (also available from http://www.mysql.com/). I recommend that you first learn to use basic client programs, although the life that is used in these programsThis is similar to the script that accesses the MySQL database in a PHP script. Your first PHP script has told you so much about the installation, but it's not fair for me to try to get you to experiment with PHP-driven Web pages.
http://www.bkjia.com/PHPjc/532242.html www.bkjia.com true http://www.bkjia.com/PHPjc/532242.html techarticle adding this script to the startup transaction is a more complex task. If you're not using Redhat Linux and you're not sure about doing it, you'd better ask someone who knows. In the ...