Let's explain what LAMP is. As the title says, LAMP is actually the abbreviation of Linux, Apache, MySQL, and PHP. Of course, the last "P" is also known as Perl or Python. Needless to say, this article explains four things: Linux, Apache, MySQL, and PHP.
I have been working on a website for a long time. I first played ASP. Later I studied. Net and used. Net for similar development. However, I mainly want to build my website, so I will focus on website operation. Of course, I chose mature CMS or blog programs on the market. Currently, both CMS and blog programs can be integrated into one another. Because the content is similar in form, which one can be selected depends on your expertise.
Since Linux and PHP are free of charge, they are quite popular abroad. Most hosts in China are on Windows, and the ASP and. Net I learned can be used together. Later, due to various reasons, my website was moved abroad, and finding a Windows host with good cost performance abroad was really difficult. It was not only a language obstacle, but also a good sense of foreign copyright, therefore, there are few cost-effective Windows hosts. I had to switch to the Linux platform. The popular WordPress attracts me, so the main focus is on the Linux host and PHP. Although I am not familiar with PHP.
Although the Linux platform has better components than Apache, such as Nginx developed by Russians and LiteSpeed with superior performance, I have used both of them. The former is characterized by high efficiency and low resource usage, tencent is said to be based on this operation. The latter is famous for its powerful performance. It is also said that it is officially recommended by WordPress to run the best WordPress components. However, various online materials show that although Apache performance and resource usage are inferior to those of other components, the goal of Apache development is to ensure stability. Isn't any website expected to run stably? So I chose to learn Apache as the server environment of the website. Once you have learned one, the others will be able to draw the opposite line.
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 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-server
After installation, MySQL can be automatically started with the system:
1
2
[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:
<? Php
Phpinfo ();
?>
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.
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.