Install LAMP in CentOS (Apache + MySQL + PHP)

Source: Internet
Author: User
Generally, the latest official version is installed. unless you have special requirements and want to install the specified version, this article will not discuss it for the moment. From the very beginning, complete an available Linux host a little bit. Here we will introduce how to install the LAMP component on CentOS6.0. Run the following command to install MySQL: PHP: 5.3.2Apache: 2.2.15MySQL: 5.1.52. install MySQL in the latest official version unless you have special requirements, this article does not discuss how to install the specified version. From the very beginning, complete an available Linux host a little bit. Here we will introduce how to install the LAMP component on CentOS 6.0. After the following statement is installed, the current version is:
  • PHP: 5.3.2
  • Apache: 2.2.15
  • MySQL: 5.1.52

1. install MySQL

First, install MySQL. Open the super terminal and enter:

[root@localhost ~]#     yum install mysql mysql-server    

After installation, MySQL can be automatically started with the system:

[root@localhost ~]# chkconfig --levels 235 mysqld on[root@localhost ~]# /etc/init.d/mysqld start

Set the password for the root account of MySQL data:

[root@localhost ~]# mysql_secure_installation

Press enter when prompted as follows:

Enter current password for root

Press enter again as follows:

Set root password? [Y/n]

The following prompt is displayed: enter the password you want to set. press enter and enter a confirmation message:

New password:

There will be four further confirmations:

Remove anonymous users? [Y/n]Disallow root login remotely? [Y/n]Remove test database and access to it? [Y/n]Reload privilege tables now? [Y/n]

Press Enter.

II. install Apache components

Since CentOS has encapsulated Apache, run and install it directly:

[root@localhost ~]# yum install httpd

Configure the system to enable Apache with the system:

[root@localhost ~]# chkconfig --levels 235 httpd on

After the configuration is complete, start Apache:

[root@localhost ~]# /etc/init.d/httpd start

Now you can access your server. if you don't miss it, you can see the Test Page of "Apache 2 Test Page powered by CentOS. Note: If other machines cannot access this service and the page is accessible directly on this server, the built-in firewall of CentOS is generally disabled. You only need to enter the firewall and open the "80" port corresponding to "WWW.

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.

3. install PHP

Run the following command to install PHP:

[root@localhost ~]# yum install php

You need to restart the Apache service:

[root@localhost ~]# /etc/init.d/httpd restart

IV. test PHP information

This step can be omitted, but to test whether the installation is successful, you can create a new PHP page for testing and use the vim editor to create a new one:

[root@localhost ~]# vi /var/www/html/info.php

Press the "I" key and enter:

 

After editing, press ESC to exit the editing mode, and then enter:

:wq

Press enter to save and exit.

In this case, you can visit your site address, such as "http: // 192.168.1.2/info. php", to check whether the relevant PHP information can be seen.

The following figure shows that PHP is successfully installed.

5. associate the PHP module with the MySQL module

You also need to associate PHP with MySQL to work properly. Search module:

[root@localhost ~]# yum search php

Install related modules:

[root@localhost ~]# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Restart the Apache module to take effect:

[root@localhost ~]# /etc/init.d/httpd restart

Refresh the "info. php" page just created, and pull down to find the relevant MySQL module to see if relevant information is detected.

If you see the relevant information, it means that MySQL is working properly.

VI. Summary

This article describes how to install the LAMP component (Apache + MySQL + PHP) in CentOS 6.0 to familiarize more beginners with the server configuration environment.

However, at this point, the environment configuration is complete, and many things are still lacking, and there are still some important problems, such as directory permission configuration problems or management problems, such as creating FTP. These contents will be discussed later.

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.