Install and configure Apache, PHP, MySql, and PHPMyAdmin in CentOS5.4

Source: Internet
Author: User
The purpose of installing Php is different. if you are a developer rather than a professional DBA, you just want to install PHP and MySql and then quickly transfer it to programming. Naturally, you are not familiar with Linux and configuration, in this case, if you reinstall Apache from the beginning, you need to download and configure various packages...

The purpose of installing Php is different. if you are a developer rather than a professional DBA, you just want to install PHP and MySql and then quickly transfer it to programming. Naturally, you are not familiar with Linux and configuration, in this case, if you reinstall Apache from the beginning, you need to download and configure various packages, and the packages are also dependent on each other. this is undoubtedly a nightmare for Cainiao, this is the case. At first I wanted to carefully understand the installation and configuration of these software. However, I had to wait for 2 or 3 days and still had no configuration, so I was almost frustrated and finally changed my mind, the installation and configuration are successful in the simplest way. This gives you confidence in the future of Linux beginners.
The text begins.
1. install the operating system. when installing the operating system, ensure that gcc is installed. this is the basis for running Apache. Therefore, when installing the graphical interface, select the custom installation package and select Development Toos, as shown in:

 

If you are a newbie, you 'd better choose to connect to the desktop. after all, you didn't get to the point where the command line was flushed. after selecting the desktop, you can see the folder path in Linux, some installation packages are not installed, and can be re-installed from the CD, as shown in:

One is the MySq database, and the other is Apache and Php, as shown in:

Select Web Server and click the Optional packages button below. the httpd and php packages are displayed, as shown in:


Okay, this is when you install the operating system, directly install Apache, Php, and MySql. if these are not installed after installation, you can also add and delete programs in the graphic interface (the command line is also acceptable, which is a complex point for beginners)
2. after the system is installed, make sure that the system can access the internet. you can select the NAT and Bridge modes for accessing the internet. The NAT mode is used by default and the IP address of the Master System is used for accessing the Internet, the Bridge method is to assign an IP address to the VM, and then the network is used for installation.
3. after installation, check whether these software packages exist. if they do not exist, reinstall them.
Run the following command to check whether necessary components have been installed in Linux:
Rpm-qi httpd # check whether the httpd suite is installed
Rpm-qi mysql # check whether the mysql suite is installed
Rpm-qi php # check whether the php suite is installed
Rpm-qi php-mysql # check whether the php-mysql suite is installed. Note that this is required because it is a required suite for running PHPMyAdmin.
4. install a non-existent package
What if these packages do not exist? We can use the YUM method to install images. domestic image servers are faster, because we first download a domestic image from our system.
Run the following command:
First, go to the yum source configuration directory.
Cd/etc/yum. repos. d
Yum source of the backup system
Mv CentOS-Base.repo CentOS-Base.repo.save
Download other faster yum sources
Yum source of HKUST:
Wget http://centos.ustc.edu.cn/CentOS-Base.repo
163 yum source:
Wget http://mirrors.163.com/.help/CentOS-Base-163.repo
Sohu yum source
Wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
It is recommended to use 163 of the source, which is stable and fast.
After updating the yum source, we recommend that you update it so that the operation takes effect immediately.
Yum makecache
After checking the uninstalled package in step 3, check the check number and install the missing package in yum.
1) install Apache
Yum install httpd mod_ssl
2) install php
Yum install php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml
3) install mysql
Yum install mysql-server
4). start mysql,
Service mysqld start
5). start apache
Service httpd start
If a php-mysql suite is missing, run yum install php-mysql.
5. test
Access http: // youhost/in the browser to see if the apache welcome page is displayed?
Next, write a php page named index. php: This php file should be placed in the web root directory. where is the root directory? the root directory path is configured in httpd. in the conf file, enter
Vim/etc/httpd/conf/httpd. conf
Find DocumentRoot/var/www/html in it. this is the root directory of PHP.
Let's create this file and input vim/var/www/html/index. php in the command line.
After opening, write a sentence in it , Press esc, and then enter: wq to keep and exit.
At this time, access http: // youhost/. is the php information displayed?
6. install and configure PhpMyAdmin
Same usage, huh, huh
1. after the download, copy the phpmyadmin code to/VAR/WWW/HTML under the php root directory, decompress the code, and enter:
Tar jxvf phpmyadmin2.8.2.tar.bz2
2. rename the decompressed folder to phpMyAdmin:
[Root @ localhost HTML] # mv phpmyadmin2.8.2./phpMyAdmin
3. Find The phpMyAdmin/libraries/config. default. php file, copy config. default. php to The phpmyadmin directory, and rename it config. inc. php.
4. edit the config. inc. php file vi
A. find $ cfg ['pmaabsoluteuri '] and modify the phpMyAdmin URL to be uploaded to the space:
For example, $ cfg ['pmaabsoluteuri '] = 'http: // 192.168.1.11/phpMyAdmin /';
B. find $ cfg ['servers'] [$ I] ['host'] = 'localhost'; (the default value is usually used, and there are exceptions. you do not need to modify the value)
C. find $ cfg ['servers'] [$ I] ['auth _ type'] = 'config ';
Debug config in your own machine. if you use cookies in the network space, now that we have added the Web site before, we recommend that you use cookies.
D. find $ cfg ['servers'] [$ I] ['user'] = 'root'; // MySQL user (mysql user name, use root on your machine ;)
E. find $ cfg ['servers'] [$ I] ['password'] = ''; // MySQL password (mysql User password, your server is generally the root password of the mysql User)
F. find $ cfg ['servers'] [$ I] ['only _ db'] = ''; // If set to a db-name, only (if you only have one data, set it. if you want to set up a server on your local computer, leave it blank)
G. find $ cfg ['defaultlang '] = 'zh'; // select simplified Chinese as the language.
H. Save the settings.
5. test: enter http: // youhost/phpMyAdmin/in the browser/
After logging on to phpMyAdmin, if you encounter an error, you cannot find the PHP extension setting mbstring. However, the current system seems to be using the wide character set. PhpMyAdmin without mbstring extensions cannot correctly identify strings and may produce unexpected results.
Execute Yum install php-mbstring in the command line.
Now, it is finished.
This is the simplest installation method. what should I do if I find that the php version is 5.1.6 but want to upgrade to 5.2.10?
1. uninstall the current php5.1.6 before the upgrade. do not delete it manually. if yum is installed, delete it with yum. execute yum remove php.
2. if this version is not available through the yum server, download the php source code from the website, compile it locally, and execute the following command line.
./Configure -- prefix =/my/php
Make
Make install
3. restart apache
Service httpd restart
At this time, we found that PHP is ready to run.
4. if PHP cannot connect to the MySql database, run the following command:
Install mysql-devel, one-way yes installation
Re-compile and run PHP, with -- with-mysql, PHP contains a large number of PHP extensions, as long as a -- with-mysql indicator is added, the compiled Php supports mysql access.
./Configure -- prefix =/my/php -- with-mysql
Make
Make install
Upgrade complete



Author: zhao Xuezhi

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.