CentOS5.6 install Lamp (Apache2 + PHP5 + MySQL)

Source: Internet
Author: User
Tags phpinfo
CentOS5.6 install Lamp (Apache2 + PHP5 + MySQL)-Linux Enterprise Application-Linux server application information. For more information, see the following. [I = s] This post was last edited by duxuejiang

Translated from: howtoforge, LAMP is short for Linux + apache + MySQL + PHP. This tutorial demonstrates how to install CentOS 5.6 and PHP5 (mod_php) and MySQL database with Apache2 web server.

1. Preliminary description
In this tutorial, the host name is server1.example.com and the IP address is 192.168.0.100. These settings may be different from your settings, so you must change them as appropriate.
2. Install MySQL 5.0
Open the terminal and enter:
Yum install mysql-server
Run the following command to enable the mysql database to start automatically with the system:
Chkconfig -- levels 235 mysqld on
/Etc/init. d/mysqld start
Set the MySQL root Account password:
Mysql_secure_installation
Display on the computer terminal and follow the prompts:
[Root @ server1 ~] # Mysql_secure_installation
NOTE: running all parts of this script is recommended for all MySQL
Servers in production use! Please read each step carefully!
In order to log into MySQL to secure it, we'll need the current
Password for the root user. If you 've just installed MySQL, and
You haven't set the root password yet, the password will be blank,
So you shoshould just press enter here.
Enter current password for root (enter for none ):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
Root user without the proper authorisation.
Set root password? [Y/n] New password: Re-enter new password: Password updated successfully!
Reloading privilege tables ..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
To log into MySQL without having to have a user account created
Them. This is intended only for testing, and to make the installation
Go a bit smoother. You shoshould remove them before moving into
Production environment.
Remove anonymous users? [Y/n] ... Success!
Normally, root shoshould only be allowed to connect from 'localhost'. This
Ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] ... Success!
By default, MySQL comes with a database named 'test' that anyone can
Access. This is also intended only for testing, and shocould be removed
Before moving into a production environment.
Remove test database and access to it? [Y/n] -Dropping test database...
... Success!
-Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
Will take effect immediately.
Reload privilege tables now? [Y/n] ... Success!
Cleaning up...
All done! If you 've completed all of the above steps, your MySQL
Installation shoshould now be secure.
Thanks for using MySQL!
[Root @ server1 ~] #
3. Install Apache2
CentOS has encapsulated apache2, which can be directly input and installed on the terminal:
Yum install httpd
Configure the system and start apache:
Chkconfig -- levels 235 httpd on
Start apache:
/Etc/init. d/httpd start
Enter the IP address in the browser to check whether the server is running: http: // 192.168.0.100.


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // imcn. me/wp-content/uploads/2011/06/centosapdche.png '); ">
Note: In CentOS, the default Apache root directory is/var/www/html, and the configuration file/etc/httpd/conf/httpd. conf is used. Other configurations are stored in the/etc/httpd/conf. d/directory.
4. Install PHP5
Run the following command to install the PHP5 and Apache PHP5 modules:
Yum install php
Restart Apache
/Etc/init. d/httpd restart
5. Test PHP5 and obtain the installation details about PHP5.
Create phpinfo documents on the web server:
Vi/var/www/html/info. php
Add the following code. Because this is a function and runs back in wordpress, you need to change the double quotation marks to single quotation marks:

《? Php
Phpinfo ();
"
Enter http: // 192.168.0.100/info. php In the browser. We will see:


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // imcn. me/wp-content/uploads/2011/06/phpinfod.png '); ">
If you see the above, PHP5 works normally, continue to scroll down to see the PHP5 module you have started. MySQL is not listed, which means we have not added MySQL module support in PHP5.
6. Make PHP5 support the MySQL database module to connect to the database.
Search module:
Yum search php
Installation module:
Yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Restart apache2
/Etc/init. d/httpd restart
Refresh http: // 192.168.0.100/info. php to see if the module is running properly:


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // imcn. me/wp-content/uploads/2011/06/mysqlmok.png '); ">
7. Install phpMyAdmin to manage the database
In CentOS, enable the RPMForge software library to install phpMyAdmin:
The 64-bit system uses the following command:
Wget http://packages.sw.be/rpmforge-r... 2. el5.rf. x86_64.rpm
Rpm-Uhv rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
The 32-bit system uses the following command:
Wget http://packages.sw.be/rpmforge-r... 2-2.el5.rf.i386.rpm
Rpm-Uhv rpmforge-release-0.5.2-2.el5.rf.i386.rpm
You can now install the following command phpMyAdmin:
Yum install phpmyadmin
Configure phpMyAdmin. You need to change the Apache configuration so that phpMyAdmin is not only connected from the local host (commented out ):
Vi/etc/httpd/conf. d/phpmyadmin. conf
Find the code for similar content and configure it as follows:
#
# Web application to manage MySQL
#
#
# Order Deny, Allow
# Deny from all
# Allow from 127.0.0.1
#
Alias/phpmyadmin/usr/share/phpmyadmin
Alias/phpMyAdmin/usr/share/phpmyadmin
Alias/mysqladmin/usr/share/phpmyadmin
Next, we change the phpMyAdmin-authenticated cookie to HTTP:
Vi/usr/share/phpmyadmin/config. inc. php
Find the code for similar content and configure it as follows:
/* Authentication type */
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'http ';
Restart Apache:
/Etc/init. d/httpd restart
Access phpMyAdmin at http: // 192.168.0.100/phpmyadmin/


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // imcn. me/wp-content/uploads/2011/06/phpmyadmincentos.png '); ">
Related Software connection:
Apache: http://httpd.apache.org/
PHP: http://www.php.net/
MySQL: http://www.mysql.com/
CentOS: http://www.centos.org/
PhpMyAdmin: The http://www.phpmyadmin.net/

Reprinted from IMCN
Link:Install lamp in CentOS 5.6 (Apache2 + PHP5 + MySQL)

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.