Run the following command to install Apache2: Run yum-y install httpd. After you press enter, yum will prompt the currently installed httpd version and update it automatically. If not, it will be automatically installed. Note that "Y" is entered during the yum installation process to confirm the installation. After Apache is installed, manually start Apache2:/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. Install MySQL because CentOS already contains MySQL. Therefore, you only need to run yum: yum-y install mysql-server to start the MySQL service by running the following command:/etc/init. d/mysqld start install php5 run the following command to install php5: yum install php after installing php5, you must restart Apache for php to take effect:/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: vi <? Php phpinfo (); then access/info. php In the browser, and the output of PHPINFO appears: PHP and Apache have been correctly installed. Next, install the MySQL database and other modules (such as the GD graphics library and mbstring Library ): yum-y 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:/etc/init again. 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 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:/usr/lib/mysql can write these safe commands to reduce time. run the sh script to install it.