Linux environment construction: CentOs + Apache + MySQL + PHP

Apache

1. Install Apache

yum install httpd -y

2. Modify the httpd configuration file, remove the # before ServerName and modify it to: ServerName localhost and save and exit##

vim /etc/httpd/conf/httpd.conf

3. Start httpd service##

systemctl start httpd

4. Test the Apache service under windows, use a browser to visit: http://192.168.81.133/ (this address is the server address of CentOs), and get the following Apache default welcome page for setting up the Apache service successfully##

MySQL

1. Download and install MySQL official Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2. Install MySQL with yum command

yum install mysql57-community-release-el7-10.noarch.rpm -y 

3. Install MySQL server (this step may take some time, after the installation is completed, the previous mariadb will be overwritten)

yum install mysql-community-server -y 

4. Start MySQL

systemctl start  mysqld

5. View MySQL status##

systemctl status mysqld

6. Check the log file to find out the initial password of the root user##

grep "password"/var/log/mysqld.log

7. Enter the MySQL database and enter the initial password (you can't do anything at this time, because MySQL must modify the password before operating the database by default)

mysql -uroot -p

8. Modify the password, here set the login user root, the password is root123

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123';

There is a problem at this time. If the new password is set too simple, an error will be reported. The reason is that MySQL has a password setting specification, which is related to the value of validatepasswordpolicy. At this time, two values need to be set to use. Simple password:

mysql>set global validate_password_policy=0;
mysql>set global validate_password_length=1;

Then repeat step 8 again

9. Uninstall Yum Repository to prevent automatic update for each yum operation in the future##

yum remove mysql57-community-release-el7-10.noarch -y

PHP

1. yum install PHP

yum install php -y
yum install php-mysql -y

2. Restart Apache

systemctl restart httpd

3. Add the phpinfo.php test file in the Apache default website directory##

vim /var/www/html/phpinfo.php

4. Enter the following test code in phpinfo.php, save and exit##

5. Test the PHP service under windows, use a browser to visit: http://192.168.81.133/phpinfo.php (the address is the server address of CentOs), and get the following page, that is, the PHP service is successfully built##

6. Set boot up automatically##

systemctl enable httpd
systemctl enable mysqld

**7. Add php test file to test MySQL connection **

vim /var/www/html/test.php

<? php
  $link=mysql_connect("localhost","root","root123");if(!$link)
    echo "FAILD!Connection error, wrong username and password";else
    echo "OK!Can connect";
  echo "<br>";printf("MySQL server version:%s",mysql_get_server_info());
  $link->close();?>

**8. Use a browser to access the test file: **http://192.168.81.133/test.php

Disclaimer: This article is original, the author is a game, please keep this statement and the attached article link when reprinting: http://www.duiyi.xyz/c%e5%ae%9e%e7%8e%b0%e9%9b%b7%e9%9c%86%e6%88%98%e6%9c%ba-65/

Recommended Posts

Linux environment construction: CentOs + Apache + MySQL + PHP
CentOS yum install Apache + PHP + Tomcat7 + MySQL
Hadoop environment construction (centos7)
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
CentOS 7 install Nginx, PHP, MySQL packages
CentOS 7 configure php language development environment
Install MySQL on Linux CentOS7 (Windows)
Build Nginx environment on Linux (CentOS)
Install mysql8.0.13 version under Linux CentOS7 system
[PHP] Build a PHP operating environment under CentOS
Novice learning Linux (eight) ---- MySql installation (Centos7)
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
Centos7 uses yum to install Apache, mariadb, PHP
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
CentOS install mysql
CentOS install PHP
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
Centos MySQL8 configuration
centos 7.5 install mysql5.7.17
Environment configuration of JDK, mysql and tomcat under Centos7
Linux Network Foundation (CentOS7)
Linux (centos7) build gitlab
CentOS6.7 build LNMP environment
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
lamp (centos7) installation lamp environment
Linux Centos7 install jdk1.8
CentOS 7.2 Yum install MySQL 5.6
CentOS (linux) install PostgreSQL
Centos7 install Mysql8 tutorial
CentOS 8 Apache enable SSL
Centos6.9 install npm environment
Mysql8.0.15 installation configuration (centos7)
Centos manually install mysql8
Install mysql under Centos 7
CentOS7 reset MySQL8.0 password
Centos7 install Mysql database
Linux notes (1): CentOS-7 installation
Install mysql5.1 under CentOS6.5
Centos7 configure nodejs environment
Configure CentOS7 GPU environment
Linux CentOS 7 installation tutorial
CentOS 7 build LNMP environment
Centos 7 install JDK (Linux install jdk)
The problem of MySQL import file failure in CentOS environment