red hat Linux to build a LAMP platform

Linux system, Apache, Mysql, PHP

Before installation configuration ensures that existing development environment package

[root@localhost ~]# yum -y install pcre-devel zlib-devel links

Close selinux and iptables

[root@localhost ~]# vi /etc/selinux/config  # 修改配置文件,关闭selinux功能
SELINUX=disabled    # 设定为disabled
#SELINUXTYPE=targeted  # 注释该项,行首添加#
[root@localhost ~]# systemctl stop firewalld  #暂时关闭防火墙
[root@localhost ~]# systemctl disable firewalld  #永久关闭防火墙
[root@localhost html]# cd /var/www/html/  #网页存放处

Install Apache, and associated dependencies ape- *

[root@localhost ~]# yum -y install httpd
[root@localhost ~]# systemctl start httpd  ##开启httpd服务
[root@localhost ~]# ss -tunl | grep 80 ##验证
tcp    LISTEN     0      128                   :::80                   :::*  
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf  ##修改配置文件
[root@localhost html]# yum -y install apr-*
[root@localhost html]# cd /var/www/html/  #网页存放处

verification

This time to open the browser if the server's external network IP, you can see it apache test page
Here Insert Picture Description

Install mysql

But MySQL database software is removed from the default list of drivers with mariadb instead, on Linux configuration tutorial, mostly installed mariadb, because centos7 by default mariadb regarded as mysql, mysql need to download all in accordance with
pre-installation check-link library there is no file installation using the command verification

[root@localhost ~]# rpm -qa | grep libaio
[root@localhost ~]#

After running the command system found no link library file that
installed the relevant software package

[root@localhost ~]# yum -y install libaio-devel.x86_64
[root@localhost ~]# yum -y install numactl

There are two solutions:
First, install mariadb
second is downloaded from the official website mysql-server
recommended installation from the official website here
whether there maradb check, if there is to uninstall

root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.35-3.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64
[root@localhost ~]# rpm -qa | grep mariadb

Check that mysql user groups and users exist, if not, create

[root@localhost ~]# cat /etc/group | grep mysql
[root@localhost ~]# cat /etc/passwd |grep mysql
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql mysql

It is the official website to download from Mysql installation package for Linux

[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

Mysql installation package found in the directory wget command execution or under your upload directory: mysql-5.7.24-linux-glibc2.12 -x86_64.tar.gz
performs decompression command:

[root@localhost ~]# tar -xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg                      mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mysql-5.7.24-linux-glibc2.12-x86_64

After the extraction is completed, you can see one more extract the files in the current directory, move the file to the / usr / local /, and the folder name changed to mysql.
If there is already mysql / usr / local / under, please modify existing mysql file a different name, or the subsequent steps may not work correctly

[root@localhost ~]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql

Create a data directory under / usr / local / mysql directory

[root@localhost local]# mkdir /usr/local/mysql/data

Change the user group and user mysql directory all directories and folders belongs, and permissions

[root@localhost local]# chown mysql:mysql /usr/local/mysql/
[root@localhost local]# chmod 755 /usr/local/mysql/

Compile and install mysql initialization, be sure to log the best position at the end of root @ localhost password (database administrator temporary password) Remember the end of the initialization output log records: the string, this string mysql temporary administrator login password

[root@localhost local]# cd /usr/local/mysql/bin/
[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

Here Insert Picture DescriptionEdit the configuration file my.cnf, add the following configuration

[root@localhost bin]# vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sysbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_name=1

Start mysql server

[root@localhost /]# /usr/local/mysql/support-files/mysql.server start

Note: If errors are reported, and see if there mysql mysqld service, if there is, then the end of the process, add soft connection, and restart the mysql service

[root@localhost bin]# ps -ef|grep mysqlps -ef|grep mysqld
[root@localhost bin]# ps -ef|grep mysqld
[root@localhost bin]# kill -9
[root@localhost bin]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@localhost bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost bin]# service mysql restart

Log mysql, modify (5 temporary password generated password is steps) password

[root@localhost bin]# mysql -u root -p
Enter password:
mysql>set password for root@localhost = password('yourpass');
Query OK, 0 rows affected, 1 warning (0.00 sec)

Open remote connection

mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;

Here Insert Picture Description
Set at startup

1、将服务文件拷贝到init.d下,并重命名为mysql
[root@localhost /]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2、赋予可执行权限
[root@localhost /]# chmod +x /etc/init.d/mysqld
3、添加服务
[root@localhost /]# chkconfig --add mysqld
4、显示服务列表
[root@localhost /]# chkconfig --list

Installing PHP

php-mysql php-mbstring are installed

[root@localhost ~]# yum -y install php php-mysql php-mbstring

Test, create a php file in / var / www / html

[root@localhost html]# vi index.php
<?php
  phpinfo();
?>

Browser access, ip / index.php should see php configuration
Here Insert Picture Description

Published 20 original articles · won praise 0 · Views 405

Guess you like

Origin blog.csdn.net/weixin_46162146/article/details/104374666