Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges


"Debian server installed portal" Guide Series Chapter 1
Blue Forest http://www.lslnet.com at 16:04 on November 29, 2002

Kanaka cold stars] [Author :
Contact : Kanaka@yeah.net, leng@haier.com
0.2.1 version :
Copyright : GPL
Last revised : November 26, 2002


Catalog

Preamble

Chapter 1 On the distribution of Debian A Pache+ M YSQL+ P HP4

Chapter 2 Used in Debian W U-ftpd FTP Server Configuration

Chapter III Used in Debian E. Xim mail server configuration

Chapter 4 On the distribution of Debian S Amba Server

Chapter V Used in Debian B Equality for DNS Server Configuration

"Debian server installed portal," the first chapter Guide Series + Web Server database server :

In the first chapter on the distribution of Debian A Pache+ M YSQL+ P HP4

Contents of this chapter

1 Choose Apache+MySQL+PHP4

2 Installation

3 Configuration

4 Test

5 1985


1 choice Apache+MySQL+PHP4

You might ask me : Why not choose other software, rather than the alternative of Apache+MySQL+PHP4 combination? Oh, I have to tell you, the famous Free Lamp portfolio that is Linux/Apache/MySQL/PHP/Perl/Python, you can see www.freelamp.com above. PHP application on the Internet is as rapidly developing like a prairie fire. If for Web, in my view, no alternative is PHP. Www.php.net details of the above can understand. MySQL is very handy, and performance excellence. Apache would not say more, several Internet Web sites without using it.

2 Installation

Debian installation of the software is really very simple. Not configure, not make, not make install, Debian workers around the world you have to do it all.

You can load all in one software :

# Apt-get install x php4 php4-gd php4-mysql mysql-server mysql-client

Among them, php-gd the graphics library is a terrific, if you do not use PHP generate dynamic pictures, not installed.
Then, the system automatically presents relevant software, and then asking you not to continue (as Debian rod, which is one point : automatic search software related to the installation of automatic replenishment) --Debian give you a chance to go back, if you do not want installed, then, according to n, to the withdrawal.
Of course, we here in accordance with the transport, installation continue. Debian will now designated sites inside your sources.list to download the software. After downloading will be automatically configured, the allocation process will solicit your views, ask you a few questions.
For example, he asked : Do you think you should be running on the computer is switched on MySQL? Yes of course, elections, when they start to use each odd trouble.
Ask you : Do you think the operation apacheconfig script? N is acquiescence, but we have our allocation for the importation of Y about it. After the allocation, and ask you whether to preserve the allocation, of course, huh, huh. He then asked whether you had to start Apache, well, it started.
Then, the system automatically configuration of PHP. As you choose a php-gd and php-mysql, he would ask whether you support into php.ini mysql.so gd.so and answered yes. You see, Debian smart cafes.

Configuration 3

Apache 3.1 Configuration

PHP 3.1.1 provides support

Just not equipped to provide the Apache PHP support. When you click there. PHP Script connected browser will be downloaded from the script : - (
Laws /etc/apache/httpd.conf to provide PHP support. Operation :

# Nano /etc/apache/httpd.conf

Incidentally, I very much like the editorial called the Nano, it is very easy to fly.
Nano ctrl+w use the find function below this line :

# LoadModule php4_module /usr/lib/apache/1.3/libphp4.so

Well this issue in front of his removed to the loading libphp4.so 64A module.
Then, the distribution of acquiescence pages found :

DirectoryIndex index.html index.htm Animals index.cgi

Read :

DirectoryIndex http://www.basd-action.net/initiatives/index.php index.php3 index.html index.htm Animals index.cgi

Plus. Php3 PHP source support and the support of the expansion were found :

#
# And for PHP 4.x, use :
#
#AddType Application/x-httpd-php. PHP
#AddType Application/x-httpd-php-source. Phps

Put it into the back two lines :

#
# And for PHP 4.x, use :
#
AddType application/x-httpd-php. PHP. Php3
AddType application/x-httpd-php-source. Phps

3.1.2 revision acquiescence Character Set

Apache regard as tacit approval for the simplified Chinese characters. Find this line :

AddDefaultCharset on

Amended as follows :

AddDefaultCharset gb2312

, On the distribution of Apache finished by ctrl+o preservation and click ctrl+x from Nano.
To effect the changes that need to restart Apache operations :

# Apachectl restart

Apachectl x 1.3 provides the tools, but have no 2.0.
In addition, attention skills : the server software Debian, almost always provide a script for start / end / restart the services. /etc/init.d/ Entirely on the script below.
For example, the Apache can be controlled through the following order :

# /etc/init.d/apache Restart

Other services can also be operated so.

MySQL 3.2 Configuration

MySQL 3.2.1 changes the password

Because MySQL acquiescence no password, for safety's sake, you must amend the password!
Let's take a look at your mysql is really no password :

$ Mysqladmin version


If you can see mysql version of the information to prove that no MySQL password.
, Operation mysqladmin password changes password : xxxxxx

# Mysqladmin password xxxxxx

Xxxxxx here is your new password.
Now you need mysqladmin version --user=root --pass operation, then the password can access version of its information.
Note that the above order of this part --user=root --pass be simplified as u root-p. We test to see whether the effect password :

# Mysqladmin-u root-p version
Enter password :

Port opened the 3306 Monitoring 3.2.2

This work must be careful. At security considerations and acquiesce in the situation, put 3,306 Debian port closed. Because many hackers to attack it through your system. If you do not access the database through other machines, then do not break the port.
Laws /etc/mysql/my.cnf found :

Skip-networking

Zhushidiao it :

# Skip-networking

3.2.3 revision acquiescence Character Set

MySQL regard as tacit approval for the simplified Chinese characters. Editor /etc/init.d/mysql find this line :

/usr/bin/safe_mysqld "2>&1 & /dev/null

Read :

/usr/bin/safe_mysqld "--default-character-set=gb2312" 2>&1 & /dev/null

, Restart MySQL :

# /etc/init.d/mysql Restart


PHP 3.3 distribution

PHP is the tacit consent to amend the characters, turning it into simplified Chinese. /etc/php4/apache/php.ini Editors :

# Nano /etc/php4/apache/php.ini

Find ;default_charset = "iso-8859-1" this trip :

;default_charset = "Iso-8859-1"

Put a semicolon in front removed and replaced default_charset = : "gb2312"

Default_charset = "gb2312"

Test 4

Well, the installation finished, we have to test.
This part of a master can ignore. I mainly to beginners, I wrote these.

4.1 to create a database

Now we have to create a simple database, the Secretary only the table, called the user, used to store a user ID / password expressly / date of birth / activation.

# Mysql-u root-p
Enter password :

Mysql> CREATE DATABASE mytest;
Query OK, one row affacted (0.00 secs)

Mysql> USE mytest;
Database changed

Mysql> CREATE TABLE user (
->
Username varchar (16) NOT NULL default ''
->
Password varchar (16) NOT NULL default binary ''
->
Birthday date NOT NULL default '1975-12-31'
->
Actived int (1) NOT NULL default '0'
->
UNIQUE KEY username (username)
->
);
 
Query OK, 0 row affected (0.00 secs)

Mysql> INSERT INTO user VALUES ( 'kanaka,' 'kanakapswd,' '1975-09-18', 0);
Query OK, one row affected (0.01 secs)

Mysql>
INSERT INTO user VALUES ( 'atfa,' 'atfapswd,' '1977-10-30', 1);
Query OK, one row affected (0.00 secs)

Mysql>
Quit
Bye

Note that under the tacit consent of all the databases on /var/lib/mysql/ below. Each database account for a catalog database of who is who. You create the database, the system automatically put it on the list below.

4.2 prepare a PHP script

Now we have to prepare a simple PHP script to be deployed inside the database above. For example, called Document mytest.php.

"?php

$dbname= 'Mytest';
$tablename= 'User';
$page=0;
$rowperpage=20;

Mysql_connect ( "localhost", "root", "your password");

4003rd viewData below this function, by myself, used to display data
4003rd certain sense, this process played a key role on this one :
ViewData ($dbname, $tablename, $page, $rowperpage);


////////////////////////////////////////////////
//
4003rd down it is only the definition of two functions, you can not go to see him ///
//
////////////////////////////////////////////////


4003rd definition of a function to return to state inquiries
EchoQueryResult function () (
Global $queryStr, $errMsg;

If ($errMsg ====== "") $errMsg = "success";
If ($queryStr> "") (
Echo "" table cellpadding=5>\n ";
Echo "" tr><td> inquiries : "/td><td>$queryStr</td></tr>\n";
Echo "" tr><td> : "/td><td>$errMsg</td></tr>\n";
Echo "" /table><p>\n ";
}
}


4003rd definition of a function to display data
Function viewData ($dbname, $tablename, $page, $rowperpage) (
Global $mysqlHandle, $PHP_SELF, $errMsg, $orderby;

Echo "" Now you h2> checking the data : "/h2>\n";

$queryStr = Stripslashes ($queryStr);
If ($queryStr ====== "") (
$queryStr = "SELECT * FROM $tablename";
If ($orderby> "")
$queryStr. = "Visible BY $orderby";
}

$pResult = Mysql_db_query ($dbname, $queryStr);
$errMsg = Mysql_error ();

$GLOBALS[queryStr] = $queryStr;

If ($pResult ====== false) (
EchoQueryResult ();
Return;
}
If ($pResult ====== 1) (
$errMsg = "Success";
EchoQueryResult ();
Return;
}

Echo "" hr>\n ";

$row = Mysql_num_rows ($pResult);
$col = Mysql_num_fields ($pResult);

If ($row ====== 0) (
Echo "no data! Forms are empty. "
Return;
}

If ($rowperpage ====== "") $rowperpage = 20;
If ($page ====== "") = 0 $page
Else $page--;
Mysql_data_seek ($pResult, $rowperpage $page *);

Echo "" table cellspacing=1 cellpadding=2>\n ";
Echo "" tr>\n ";
Echo ' "th bgcolor=" #FFCC66 ""';
Echo "user name \n";
Echo "" /th>\n ";
Echo ' "th bgcolor=" #FFCC66 ""';
Echo "password \n";
Echo "" /th>\n ";
Echo ' "th bgcolor=" #FFCC66 ""';
Echo "date of birth \n";
Echo "" /th>\n ";
Echo ' "th bgcolor=" #FFCC66 ""';
Echo "to activate \n";
Echo "" /th>\n ";
Echo "" /tr>\n ";


For ($i = 0 $i "$rowperpage; $i++) (
$rowArray = Mysql_fetch_row ($pResult);
If ($rowArray ====== false) break;
Echo "" tr>\n ";
$key = "";
For ($j = 0 $j "$col; $j++) (
$data = $rowArray[$j];

$field = Mysql_fetch_field ($pResult, $j);
If ($field->primary_key ====== 1)
$key. = "&." $field->name. "Equals." $data;

If (strlen ($data) "30)
. . "
$data = Htmlspecialchars ($data);
Echo ' "td bgcolor=" #99CCCC ""';
Echo "$data\n";
Echo "" /td>\n ";
}

Echo "" /tr>\n ";
}
Echo "" /table>\n ";
Echo "" hr> ";
//$PHP_SELF

Echo "" Differences size=2> ";
Echo "" form action= '$PHP_SELF?action=viewData&dbname=$dbname&tablename=$tablename&page=$page&rowperpage=$rowperpage' method=post> ";
Echo "" Differences color=green> ";
Echo "." ($page+1). "Page / total." (Int) ($row/$rowperpage+1). "Pages";
Echo "" /font>\n ";
Echo "|";
If ($page "0) (
Echo "" a style='mso-footnote-id:ftn1' '$PHP_SELF?action=viewData&dbname=$dbname&tablename=$tablename&page=. " ($page). '&rowperpage='. $rowperpage;
If ($orderby> "")
Echo "&orderby=$orderby";
Echo " '" preceding page "/a>\n";
) Else
Echo "the preceding page."
Echo "|";
If ($page "($row/$rowperpage) -1) (
Echo "" a style='mso-footnote-id:ftn1' '$PHP_SELF?action=viewData&dbname=$dbname&tablename=$tablename&page=. " ($page+2). '&rowperpage='. $rowperpage;
If ($orderby> "")
Echo "&orderby=$orderby";
Echo " '" page "/a>\n";
) Else
Echo "page";
Echo "|";
If ($row "$rowperpage) (
Echo "" input type=submit value= 'first jump,' "\n";
Echo "" input type=text size=4 name=page> page ";
}
Echo "" /form> ";


Echo "" form action= '$PHP_SELF?action=viewData&dbname=$dbname&tablename=$tablename&page=$page&rowperpage=$rowperpage' method=post> ";
Echo "page shows the current number of records." $rowperpage. ", You can";
Echo "" input type=submit value= 'read' ""
Echo "" type=text size=4 name=rowperpage> of input / pages ";

Echo "" /form>\n ";
Echo "" /font>\n ";
}


?>

I did not write procedures for a good long time, even PHP grammar soon forget, huh, huh. Last year, I prepared for the company's production line of an application, is the excerpt from the above, I originally wanted to write a very simple procedure here, but I still try to retain the two functions, so as to help beginners learn from there, huh, huh.

4.3 Test

Mytest.php this complex system to /var/www Now, inside your browser, visit the mytest.php will see the contents of the database.

Taking into mytest.php /var/www Now, because of the tacit consent, the Apache httpd.conf file as root /var/www put inside a definition list.
Beginners that Linux consoles in the following paragraphs is a good browser, w3c, lynx, links and so on. Three have their merits, not perfect. Links are more suitable for beginners personal feeling, because after a menu? Esc键 there.

5 1985

This paper is the "portal installed Debian server," the first chapter Guide series, we ask that you read in accordance with the order, and the author may have problems Kanaka Ties.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com