CentOS7 install the LAMP environment and centos7lamp Environment

Source: Internet
Author: User

CentOS7 install the LAMP environment and centos7lamp Environment

1. Install using yum

Yum-y install httpd mysql-server php-mysql postgresql-server php-postgresql php-pgsql php-devel

2. Configure httpd

2.1 start the httpd service and add this service unit to the current running level

Systemctl start httpd. service

Systemctl enable httpd

2.2 Open Port 80 of firewalld Firewall

Firewall-cmd -- add-service = http (instant access)

Firewall-cmd -- permanent -- add-service = http (write configuration file)

 

3. Configure MySQL

3.1 install wget

Yum install wget

3.2 download the mysql repo Source

Wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

3.3 install mysql-community-release-el7-5.noarch.rpm package

Sudo rpm-ivh mysql-community-release-el7-5.noarch.rpm

3.4 install the database

Sudo yum install mysql-server

3.5 run the mysql-u root command and the system reports an error.

3.6 change the File Permission and run the sudo chown-R root: root/var/lib/mysql command.

3.7 restart mysql

Service mysqld restart

3.8 run the mysql-u root command to enter mysql and use the mysql database

Use mysql

3.9 set the User root Password

Update user set password = password ('root') where user = 'root ';

3.10 Add a password for logging on with localhost

Set password for 'root' @ 'localhost' = password ('root ');

3.11 allow remote Logon

Grant all privileges on *. * TO 'root' @ '%' identified by 'root' with grant option;

3.12 run the command: FLUSH PRIVILEGES

3.13 restart mysql

3.14 enable port 3306

Firewall-cmd -- add-port = 3306/tcp

 

4. Test

4.1 create a database and a data table

4.2 create a new file under var/www/html and write the code

Vi demo. php

<? Php

Mysql_connect ('address', 'username', 'Password ');

......

4.3 enter the linux IP address and the file name (for example, 192.168.1.100/demo. php) on another computer. If the result is displayed, the configuration is successful!

In addition:

1. Check whether port 80 is enabled.

Firewall-cmd -- query-port = 80/tcp

2. enable port 80

Firewall-cmd -- add-port = 80/tcp

3. View IP addresses

Ip addr

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.