PHP environment configuration under CentOS 7 in the VM, under CentOS 7
For simplicity, set the VM Nic to the bridging mode
1. yum install httpd php
2. yum install mariadb
3. Start mariadb
Systemctl start mariadb. service # start MariaDB
Systemctl stop mariadb. service # stop MariaDB
Systemctl restart mariadb. service # restart MariaDB
Systemctl enable mariadb. service # Set startup
Create a new user for remote access
Mysql-u root-p enters the database
User mysql; # Use the mysql System database insert into user (Host, User, Password) values ('%', 'test', PASSWORD ('123 ')); # Insert a new account named test as test with the Password 123. You can modify the Update user set PASSWORD = Password ('123') as needed ') where User = 'root' # change the root password to 123 and use select * from user to reset the root password; # Check whether the User is added
Grant all privileges on *. * to test @ '%' identified by '000000'; test is the account and % is the host address. Currently, all 123 represents the password.
FlushPrivileges; refresh
Select user, host from user; # Check whether the user is added
4. Disable the firewall to allow hosts to access websites in virtual machines.
Systemctl stop firewalld. service # stop firewall
Systemctl disable firewalld. service # disable firewall startup
5. You can access the VM by enabling the vm ip address on the host.
6. Test PHP
Cd/var/www/html
Vi index. php # enter the following content
<? Php
Phpinfo ();
?>
: Wq! # Save and exit
Enter the Server IP address in the browser of the client. The configuration information shown in is displayed!
Note: The default program directory of apache is/var/www/html.
Permission settings: chown apache. apache-R/var/www/html
Now, the installation and configuration of the LAMP server (Apache + PHP + MariaDB) in CentOS 7.0 is complete!