Centos 5.4 server configuration Yum install Apache + PHP + MySQL + phpMyAdmin

Source: Internet
Author: User
Tags php mysql apache log password protection
1. Update the system kernel to the latest version.
[Root @ linuxfei ~] # Yum-y update
After the system is updated, if an error message is prompted during Yum installation, run the following command to fix the problem.
[Root @ linuxfei ~] # Rpm-import/etc/pki/rpm-GPG/RPM-GPG-KEY *
2. Install apahce, PHP, MySQL, and PHP to connect to the MySQL library component.
[Root @ linuxfei ~] # Yum-y install httpd PHP MySQL mysql-server PHP-MySQL
// Install MySQL extension
[Root @ linuxfei ~] # Yum-y install mysql-connector-ODBC mysql-devel libdbi-DBD-MySQL
// Install PHP Extension
[Root @ linuxfei ~] # Yum-y install PHP-Gd PHP-xml php-mbstring PHP-ldap php-pear PHP-XMLRPC
// Install Apache Extension
[Root @ linuxfei ~] # Yum-y install httpd-manual mod_ssl mod_perl mod_auth_mysql
One-time paste installation:
[Root @ linuxfei ~] # Yum-y install httpd PHP MySQL mysql-server PHP-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql PHP-mcrypt PHP-Gd PHP-xml php-mbstring PHP-ldap php-pear PHP- XMLRPC mysql-connector-ODBC mysql-devel libdbi-DBD-MySQL

3. Start service configuration
[Root @ linuxfei ~] #/Sbin/chkconfig httpd on [set Apache to self-start]
[Root @ linuxfei ~] #/Sbin/chkconfig -- add mysqld [MySQL Service]
[Root @ linuxfei ~] #/Sbin/chkconfig mysqld on [mysqld service]
[Root @ linuxfei ~] #/Sbin/service httpd start [self-starting HTTPd service]
[Root @ linuxfei ~] #/Sbin/service mysqld start [self-starting mysqld service]
4. Set the password of the root account of the MySQL database.
[Root @ linuxfei ~] # Mysqladmin-u Root Password 'linuxfei' [enter the password in quotation marks]
[Root @ linuxfei ~] # Mysql-u root-P login log on with a blank password as root
Enter Password: linuxfei login enter the password here

Welcome to the MySQL monitor. commands end with; or \ G. login confirm that you can log on with the password
Your MySQL connection ID is 5 to server version: 4.1.20

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

5. Install phpMyAdmin
[Root @ linuxfei/] # wget http://gd2.down.chinaz.com: 808/data management/phpMyAdmin-3.tar.gz
-- 2010-03-23 16:38:18 -- http://gd2.down.chinaz.com: 808 /?????? PhpMyAdmin-3.x.tar.gz
Resolving gd2.down.chinaz.com... 121.11.80.154
Connecting to gd2.down.chinaz.com | 121.11.80.154 |: 808... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4700100 (4.5 m) [application/X-gzip]
Saving to: 'phpmyadmin-3.x.tar.gz'

100% [============================================== >] 4,700,100 134 K/s in 37 S

16:38:56 (123 kb/s)-'phpmyadmin-3.x.tar.gz 'saved [4700100/4700100]

Decompress phpMyAdmin

[Root @ centos5/] # tar zxvf phpMyAdmin-3.x.tar.gz

[Root @ linuxfei/] # Music phpMyAdmin-3.3.1-all-languages/var/www/html/phpMyAdmin

Move the extracted directory to the/var/WWW directory and change it to phpMyAdmin.

Rename config. sample. Inc. php under the phpMyAdmin root directory to config. Inc. php.

Open and edit config. Inc. php

$ Cfg ['blowfish _ secret'] = '';

Find the following two rows and remove //

// $ Cfg ['servers'] [$ I] ['controluser'] = 'pma'; MySQL Username
// $ Cfg ['servers'] [$ I] ['controlpass'] = 'pmapass' MySQL password

Apache configuration

/etc/httpd/CONF/httpd. conf
main configuration file. However, many other distribution files are split into several small files to manage different parameters respectively. However, the main configuration file is based on the file name.
/etc/httpd/CONF. d /*. conf
one of the characteristics of centos, if you do not want to modify the original configuration file httpd. conf, you can separate your own extra parameters. When apache is started, this file will be read into the main configuration file.
/usr/lib/httpd/modules
Apache supports many modules, therefore, the modules you want to use are stored in this directory by default
/var/www/html
where the default "Homepage" of centos is located.
/var/www/error
If the host is set incorrectly or the data requested by the browser is incorrect, the error message displayed on the browser is the default information of this directory.
/var/www/icons
some small icons of apache
/var/www/cgi-bin
some executable CGI Program directory
/var/log/httpd
Apache log files are stored here by default, for websites with high traffic, this directory should be very careful, because this file is easily changed to a large one, you need enough space.
/usr/sbin/apachectl
This is the main execution file of Apache, which is actually a shell script, it can actively detect some settings on the system, it makes Apache startup easier
/usr/sbin/httpd
This is the main Apache binary file
/usr/bin/htpasswd
when when you want to log on to some web pages, enter the account and password. Apache itself provides the most basic password protection method. The password is generated using this command.

For MySQL, You Need To Know several important directories and files as follows:
/Etc/My. CNF: This is the MySQL configuration file, which can be used to optimize the MySQL database or specify some additional parameters for MySQL.
/Usr/lib/MySQL: the directory where the MySQL database is stored. When starting any MySQL server, remember to back up the directory completely during Backup.

In addition, you should know the following files in PHP.
/Usr/lib/httpd/modules/libphp4.so: the module provided by PHP for Apache. Can we design the most important PHP program language file on the Apache webpage?
/Etc/httpd/CONF. d/PHP. conf: Do you want to manually write this module into httpd. conf? No, because the system has actively written the PHP setting parameters to this file, and this file will be read when Apache restarts.
/Etc/PHP. ini: This is the main configuration file of PHP, including whether PHP can allow users to upload files and some low-security labels, which are all set in this configuration file.
/Etc/PHP. d/MySQL. INI/usr/lib/PhP4/MySQL. So: Can PHP support the MySQL interface. These two files are provided by the PHP-MySQL software.
/Usr/bin/phpize/usr/include/PHP: If you want to install a PHP accelerator later to speed up browsing, this file and directory will need to exist, otherwise, the accelerator software cannot be used.

Httpd. conf Basic settings
First, you need to have a complete host name in/etc/hosts. Otherwise, you will be prompted that the complete host name cannot be found when you restart the apache service.
The basic settings of httpd. conf are as follows:

Related Parameters in the project
....

For example, if you want to provide additional functions for the homepage/var/www/html, you can perform the following settings:

Options Indexes
......

Set items for the host environment
# Vi/etc/httpd/CONF/httpd. conf
ServerTokens OS
# This Project tells the client about the WWW server version and operating system and does not need to be adapted.
# If you do not want to tell too much host information, change the OS of this project to minor.

Serverroot "/etc/httpd"
# This is the top-level directory of the setting file, which usually uses absolute paths. When some of the following data settings use relative paths
# It is the lower-level directory related to the directory setting value and does not need to be changed.
Serverroot
Set the absolute path for Apache installation
Timeout
Sets the maximum wait time for the server to receive the message.
Keepalive
Set whether the server enables the continuous request function. Generally, the real server must enable the function.
Port
Set the default port of the HTTP service.
User/group
Set the executor and Group of the server program, which is generally Apache

below we will do a few experiments on apache
1: change the default website directory to the root directory
New/root/website directory
# mkdir-P/root/website
# echo "website page" >/root/website/index.html
# vi/etc/httpd/CONF/httpd. conf
find the root directory of DocumentRoot "/var/www/html" // apache
change/var/www/html to/root/website
in the "// define Apache/var/www/html" area,
change/var/www/html to/root/website.
changed the default path
and then restarted the service
# service httpd resta RT
// when you restart the service, an error may be reported, indicating that the directory cannot be found. This is mainly caused by SELinux.
how can this problem be solved? There are two ways to disable SELinux
# setenforce 0
or change the SELinux attribute of the/root/website file, match the httpd server's requirements.
how can this problem be solved? We can copy the SELinux attribute of the/var/www/html directory
# chcon-r -- reference/var/www/html/root/website
and restart the service., then you can see that there is no error.
but when you access localhost, you will find that the access is denied. Why? The main reason is that your/root permission is 750, and the ahache user has no access permission, you need to change the permission, you can change it like this
# chmod-r 755/root
and then access it to find it is normal

2: Name-based VM
The two domain names need to be resolved to your server. The corresponding relationship is
/Var/www/Server server.example.com
/Var/www/client client.example.com
When you access these two domain names, you can display the content of the homepage in different files.
# Echo "server page">/var/www/Server/index.html
# Echo "client page">/var/www/client/index.html
Then we edit a configuration file.
# Vi/etc/httpd/CONF. d/virtual. conf // remember that the content in Conf. D is also the configuration file of Apache.
Add the following content:
Namevirtualhost 192.168.76.133: 80

Servername service.example.com
DocumentRoot/var/www/Server

Servername client.example.com
DocumentRoot/var/www/client

# Service httpd restart
In this way, the name-based virtual host is configured.
If you do not have DNS, you can add a record to the hosts file on your machine for Linux in the/etc/hosts file for windows in the c: \ windows \ system32 \ drivers \ etc \ hosts file
Add the two rows
192.168.76.133 server.example.com
192.168.76.133 client.example.com
In this way, you will find that the access to different domain names shows different content, so the name-based virtual host is configured!

3: IP address-based VM
First add a temporary Nic
# Ifconfig eth0: 0 192.168.76.132 // for temporary use, it will disappear after restart
Then the virtual. conf file is convenient.
# Vi/etc/httpd/CONF. d/virtual. conf
Modify the content
# Namevirtualhost 192.168.76.20.: 80

Servername service.example.com
DocumentRoot/var/www/Server

Servername client.example.com
DocumentRoot/var/www/client

After you access it with an IP address, you can find that different content can be displayed, or you can edit the hosts file to access it with a domain name.
In this way, the IP address-based virtual host is also successful!

4: alias
Add/etc/httpd/CONF/httpd. conf
Alias/test "/root/website/" // alias. In this way, when you access 192.168.76.20./ test, the page of 192.168.76.20.is displayed.
Note the difference between/test and/test/. If you use/test, you can only access it with 192.168.76.20./ test. If you use/test/, 192.168.76.20. /test/access, and/test won't let you access
Forget to put/etc/httpd/conf first. the virtual directory just set in the d directory is commented out or cannot be accessed because the virtual directory is created, and httpd. the configuration in conf cannot be accessed. Of course, localhost can be used for access, but none of the other accesses can be used.

5. Download Web Resources
Add an alias first
# Vi/etc/httpd/CONF/httpd. conf
After alias/test "/root/website/", add
Alias/down "/var/FTP/pub"
Set parameters for the/var/FTP/pub region.

Options indexes Multiviews
AllowOverride none
Order allow, deny
Allow from all

Automatically List Directory documents when Multiviews is added to options without Index
Then restart the service so that the files in the/var/FTP/pub file can be listed in http: // 192.168.76.20./ down/. Try to save it as a file. Can you download it? Haha success!

6:. Implementation of htpasswd
# Vi/etc/httpd/CONF/httpd. conf
We have just done this for/var/FTP/pub.
Add the following information:
Alias/down "/var/FTP/pub /"

Options indexes Multiviews
AllowOverride authconfig
Order allow, deny
Allow from all

Authtype basic
Authname "this is test"
Authuserfile/etc/httpd/htpasswd
Require user test

Restart the HTTPd service,
Generate a. htpasswd User Password
Htpasswd-C/etc/httpd/htpasswd Test
The password is required to access 192.168.76.20./ down later.
This will succeed.

Http://www.lupaworld.com/forum.php? MoD = viewthread & tid = 61210 & page = 1

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.