CentOS under Yum installation lamp (apache+mysql+php) environment

Source: Internet
Author: User

1. Install apache,mysql,php with Yum
1.1 Installing Apache

The code is as follows Copy Code
#yum Install httpd Httpd-devel

When Setup is complete, start Apache with/etc/init.d/httpd start
Set to boot:

The code is as follows Copy Code
Chkconfig httpd on

1.2 Installing MySQL
1.2.1 Installation

The code is as follows Copy Code
#yum install MySQL mysql-server mysql-devel

Again, when finished, start MySQL with/etc/init.d/mysqld start
1.2.2 Set the MySQL root password
After installation MySQL can not use the password is able to enter, if you need to set the password, enter the following command:

The code is as follows Copy Code
# mysqladmin-u root-p password <your new password>
# Enter Password: #安装的时候没有输入密码, direct return here

1.2.3 Allow remote logins

The code is as follows Copy Code
# mysql-u Root-p
# Enter Password: <your new password>
# Mysql>grant all privileges in *.* to ' username ' @ '% ' identified by ' password ' with GRANT OPTION;

When you are done, you can remotely manage MySQL with Mysql-front.
1.2.4 Set to boot

The code is as follows Copy Code
# Chkconfig Mysqld on

1.3 Installing PHP

The code is as follows Copy Code
# yum Install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
#/ETC/INIT.D/HTTPD Start

2. Test
2.1 Create a new test.php file in/var/www/html/, write the following content, and then save it.

The code is as follows Copy Code
?
Phpinfo ();
?>

2.2 Firewall configuration
A. Add. Allow access port (80:http).

The code is as follows Copy Code
# Vi/etc/sysconfit/iptables
Iptables-i rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 80-j ACCEPT

B. Shutdown firewall {not recommended}.

The code is as follows Copy Code
# Service Iptables Stop

C. Reset the Load Firewall

The code is as follows Copy Code
# Service Iptables Restart

2.3 Then open the http://serverip/test.php in the client browser and, if successful, indicates that the installation was successful.
At this point, the installation is complete. Feeling, yum really good use.

CentOS Open Firewall 80 port
Note: Sometimes the installation may not be accessible, you need to open port 80
A big reason is the firewall:
Query for open 80 ports through the/etc/init.d/iptables status command if there are no two ways to handle:
1. Modify the Vi/etc/sysconfig/iptables command to add the firewall to open 80 ports

The code is as follows Copy Code
#/sbin/iptables-i input-p tcp–dport 80-j ACCEPT
#/sbin/iptables-save

2. Close the firewall

The code is as follows Copy Code
#/etc/init.d/iptables Stop/start/restart stop/start/reboot
#restart reboot

Permanently shutdown firewall Chkconfig–level iptables off

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.