Quickly build a LAMP (Apache, MySQL, and PHP) Environment in CentOS

Source: Internet
Author: User
Tags apache log file apache log


Building a LAMP (Apache, MySQL, and PHP) Environment in CentOS is a perfect combination of PHP-based website services, the LAMP combination has excellent performance, perfect support system, and flexible configuration methods. However, the Lamp architecture is becoming increasingly bloated. It is best to optimize the hardware after the Lamp installation is complete, for better performance. LAMP can be built on many platforms (Linux, Windows, Unix, and MacOS X). This article uses the CentOS system to install the LAMP package for example. To build a server with CentOS installed, you must install only the least system components. Run the following command on www.2cto.com to install Apache2: 1 yum install httpd. After you press enter, yum will prompt the currently installed httpd version and update it automatically. If not, it will be installed automatically. Note that "Y" is entered during the yum installation process to confirm the installation. After Apache is installed, manually start Apache2: 1/etc/init. d/httpd start and enter the Server IP address in the browser to view the default page of Apache2. At this time, Apache can only provide HTTP Services, and cannot execute php or connect to the MySQL database. Then, install MySQL because CentOS already contains MySQL. Therefore, you only need yum: 1 yum install mysql-server. Then, run the following command to start the MySQL service: 1/etc/init. d/mysqld start continue to install php5 use the following command to install php5: 1 www.2cto.com yum install php after installing php5, you must restart Apache for php to take effect: 1/etc/init. d/httpd restart. Apache can parse and execute the php script. Because the default Apache website root directory is located at:/var/www/html/, an info. php file is created in this directory to test whether Apache + PHP is correctly installed: 1 echo "<? Php phpinfo ();?> ">/Var/www/html/info. php then access IP/info. php In the browser. The output of PHPINFO is displayed, indicating that PHP and Apache have been correctly installed. Next, install the MySQL database and other modules (such as the GD graphics library and mbstring Library ): 1 yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc installation process may be slow, please be patient. Restart Apache: 1/etc/init. d/httpd restart re-open IP/info in the browser. on the php page, you can find MySQL, GD, mbstring, and other modules. At this time, the LAMP runtime environment has been initially installed. Finally, you need to set the LAMP component to Automatic startup: 1 chkconfig -- levels 2345 httpd on 2 www.2cto.com chkconfig -- levels 2345 mysqld on. Finally, we will introduce the related configuration and environment Apache main configuration file: /etc/httpd/conf/httpd. conf Apache main configuration directory. You can classify different types of configuration into this directory:/etc/httpd/conf. d/Apache website root directory:/var/www/html/Apache log File directory: my. cnf configuration file:/etc/my. cnf MySQL database file location: After/usr/lib/mysql is installed, first, pay attention to the firewall and open the relevant ports. Instead, you must set the security of MySQL and Apache to avoid security vulnerabilities. Author qingshanli1988

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.