Getting started with Debian server settings

Source: Internet
Author: User
Tags debian server
Debian server configuration entry-Linux Release Technology-Debian information. The following is a detailed description. 1. Select Apache + MySQL + PHP4.
You may ask me: Why do I have to choose a combination of Apache + MySQL + PHP4 instead of other software? Well, I want to tell you that the famous Free Lamp combination is Linux/Apache/MySQL/PHP/Perl/Python. You can go to www.freelamp.com to check it out. The Application of PHP on the Internet is becoming increasingly apparent. For Web development, I have no choice but to use PHP. For details, go to www.php.net. MySQL is very lightweight and has excellent performance. Apache does not need to be said. Few Web sites on the Internet do not need it.

2 Installation

Installing software On Debian is really simple. No need for configure, no need for make and no need for make install. The Debian staff all over the world have done everything for you.

You can install all these software in one breath:

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

Among them, php-gd is a very good graphics library, if you do not need to use php to generate dynamic images, you do not need to install.

At this time, the system will automatically list some related software, and then ask if you want to continue (Debian is great, this is one of them: automatically search for software associations, and automatically add the installation) -- Debian gives you a chance to repent. If you don't want to install it now, press n and quit.

Of course, press Enter here to continue the installation. Now Debian will download the software from the site specified in your sources. list. After the download is complete, the configuration will be automatically performed. You will be asked for your opinion during the configuration process and a few questions will be asked.

For example, he asked you: do you want to run MySQL when the computer starts? Of course Yes is selected, otherwise it will be started every time it is used, which is troublesome.

Q: Do you want to run the apacheconfig script? The default value is N, but input Y to configure it for us. After the configuration, ask if you want to save the configuration. Of course, yes. Then, he will ask you if you want to start Apache.

Then, the system automatically configures PHP. Because you have chosen php-gd and php-mysql, he will ask if you want to write the support for gd. so and mysql. so into php. ini. The answer is yes. You see, Debian is smart.

3 Configuration

3.1 configure Apache

3.1.1 php support

Apache does not support php when it is installed. When you click Connect with A. php script, the browser will download the Script :-(

Modify/etc/apache/httpd. conf to provide php support. Run:

# Nano/etc/apache/httpd. conf

By the way, I like this nano editor very much and it is easy to get started.

Use the nano ctrl + w function to find the following line:

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

Remove the well number before this line so that apache can load the libphp4.so module.

Then, configure the hosts page and find:

DirectoryIndex index.html index.htm index.shtml index. cgi

Changed:

DirectoryIndex index. php index. php3
Index.html index.htm index.shtml index. cgi

Add the. php3 extension support and php source code support, and find:

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

Modify the following two rows:

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

3.1.2 modify the default Character Set

Let Apache use simplified Chinese as the default character set. Find this line:

Adddefacharcharset on

Modify:

Adddefacharcharset gb2312

All right, Apache is configured. Press ctrl + o to save the configuration, and press ctrl + x to exit the nano.

To make the changes take effect, restart Apache and run:

# Apachectl restart

Apache 1.3 provides this apachectl tool, but 2.0 is gone.

In addition, note that the server software package provided by Debian provides almost all scripts for starting, terminating, and restarting the service. All scripts are placed under/etc/init. d.

For example, Apache can be controlled using the following command:

#/Etc/init. d/apache restart

Other services can also perform this operation.

3.2 MySQL Configuration

3.2.1 Modify the MySQL password

Because MySQL does not have a password by default, you must modify your password for security reasons!

Let's see if your mysql has no password:

$ Mysqladmin version

If you can see the mysql version information, it proves that MySQL currently has no password.

Run mysqladmin password xxxxxx to change the password:

# Mysqladmin password xxxxxx

Here, xxxxxx is your new password.

Now you need to run mysqladmin version -- user = root -- pass, and then enter the password to view the version number and other information.

Note: The -- user = root -- pass part in the preceding command can be abbreviated as-u root-p. Let's test whether the password has taken effect:

# Mysqladmin version-u root-p
Enter password:

3.2.2 enable port 3306 listening

This work should be careful. In security considerations, by default, Debian closes port 3306. Because many hackers use it to attack your system. If you do not use other machines to access the database, do not open this port.

Modify/etc/mysql/my. cnf and find:

Skip-networking

Comment it out:

# Skip-networking

3.2.3 modify the default Character Set

Let MySQL use simplified Chinese as the default character set. Edit/etc/init. d/mysql and find this line:

/Usr/bin/safe_mysqld>/dev/null 2> & 1 &

Changed:

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

OK. Restart MySQL:

#/Etc/init. d/mysql restart

3.3 PHP configuration

It is mainly to modify the default Character Set of php and change it to simplified Chinese. Edit/etc/php4/apache/php. ini:

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

Find the; default_charset = "iso-8859-1" line:

; Default_charset = "iso-8859-1"

Remove the semicolon and change it to default_charset = "gb2312"

Default_charset = "gb2312"

4. Comprehensive Test

Now, the installation is complete. Let's test it.

This part can be skipped by experts. I wrote this for beginners.

4.1 create a database

Next we will create a simple database with only one table named user in the database to store the user name, plaintext password, birth date, and activation status.


$ Dbname = 'mytest ';
$ Tablename = 'user ';
$ Page = 0;
$ Rowperpage = 20;

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

4.2 Test

Copy mytest. php to/var/www. Access mytest. php in your browser and you will see the database content.

Put mytest. php under/var/www because/var/www is defined as the root directory of the document by default in Apache httpd. conf.

For beginners, there are several browsers in the linux console, such as w3c, lynx, and links. The three have their own advantages and disadvantages and are not perfect. I personally think links is suitable for beginners, because a menu appears after pressing the esc key.

5 conclusion

This article is the first chapter in the series of tutorials for getting started with Debian server settings. We recommend that you read this article in sequence. If you have any questions, contact the author kanaka.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.