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