Install the LAMP environment on linux centos yum

  • 2020-05-15 03:27:27
  • OfStack

System: centos 6.5

1. yum installation and compile the source code at the time of use do not have what distinction, but the installation process is very different, yum only need three orders can be completed, and the source code needs to be 13 bags, have to make a pressurized compilation step very troublesome, and as sometimes will go wrong, the source code to compile installation takes about 2 hours, advantage can configure their address, 1 some parameters, such as yum install half an hour to fix, 1 will not go wrong, update is very convenient.

2. My machine is a system of centos release 5.9 and 64, and all the 1 machines have yum command, and yum package source can be used, that is to say, you don't need to download things by yourself, but yum-y install and the software you need to install will be downloaded and installed automatically, which is very convenient. For example, yum-y install httpd automatically downloads and installs the apache server. The lamp environment only requires the installation of httpd,mysql,php

3. First update 1 below yum-y update

4. Install Apache,Mysql,PHP with yum.

4.1 installation Apache


yum install httpd httpd-devel 

After the installation is complete, use/etc/init d/httpd apache start started

Set to boot :chkconfig httpd on

4.2 installation mysql


yum install mysql mysql-server mysql-devel 

Similarly, completed, use/etc/init d/mysqld mysql start started

4.3 set the mysql password


mysql>; USE mysql; 
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root'; 
mysql>; FLUSH PRIVILEGES;

You can also set the mysql password with the mysql_secure_installation command

4.4 allow remote login


mysql -u root -p 
Enter Password: <your new password> 
mysql>GRANT ALL PRIVILEGES ON *.* TO ' The user name '@'%' IDENTIFIED BY ' password ' WITH GRANT OPTION; 

Once you're done, you can manage mysql remotely using mysql-front.

Set to boot


chkconfig mysqld on

4.5 installation php


yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml 
/etc/init.d/httpd start

5. Test 1

In/var/www/html/build a test php file, add the following content, and then save.


<? 
phpinfo(); 
?> 

Firewall configuration

Add. Allow access to port {80: http}.


-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

b. Close the firewall {not recommended}.


service iptables stop 

c. Reset the load firewall


service iptables restart

6. Then in the client browser open http: / / serverip test php, if can show success, installation is successful.


Related articles: