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, 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 <? Phpinfo ()?>, Press esc and 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.