first, replace the system firewall
Note: The CentOS 7.2 default system firewall is firewall, which is changed to iptables firewall.
1. Close Firewall
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable firewalld.service #禁止firewall开机启动
2. Install iptables Firewall
Yum install iptables-services #安装
Vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sample configuration for Iptables service# u can edit this manually or use system-config-firewall# S to add additional ports/services to this default configuration*filter:input accept [0:0]:forward Accept [0:0]:output ACC EPT [0:0]-a input-m State--state related,established-j accept-a input-p icmp-j accept-a input-i lo-j ACCEPT-A INPUT -P tcp-m State--state new-m TCP--dport 22-j accept-a input-m State--state new-m tcp-p TCP--dport 80-j accept
-a input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT-A input-j REJECT--reject-with Icmp-host-prohib Ited-a forward-j REJECT--reject-with icmp-host-prohibitedcommit
: wq! #保存退出
Systemctl Restart Iptables.service #最后重启防火墙使配置生效
Systemctl Enable Iptables.service #设置防火墙开机启动
second, to close SELinux
Vi/etc/selinux/config
#注释掉 #注释掉 #增加
: wq! #保存退出
Setenforce 0 #使配置立即生效
third, the system contract
Software source code Package storage location:/USR/LOCAL/SRC
Software source code Package storage location:/usr/local/rpms
Source Package Compilation Installation location:/usr/local/software Name
iv. Download the package
1. Download MySQL
Http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.31.tar.gz
2, download CMake (MySQL compilation tool, also can install Yum)
Http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
installation of compiling tools and library files
Yum install-y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp Curl Curl-devel fontconfig Fontconfig-devel FreeType freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils ke Yutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++- Devel libtool* libgomp libxml2 libxml2-devel libxpm* libtiff libtiff* make MPFR ncurses* ntp OpenSSL openssl-devel patch p Cre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
Vi. Compiling and installing MySQL
1, installation CMake
Cd/usr/local/src
Tar zxvf cmake-2.8.11.2.tar.gz
CD cmake-2.8.11.2
./configure
Make
Make install
2. Install MySQL
Groupadd MySQL #添加mysql组
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组且不允许mysql用户直接登录系统
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Chown-r mysql:mysql/data/mysql #设置MySQL数据库存放目录权限
Mkdir-p/usr/local/mysql #创建MySQL安装目录
CD/USR/LOCAL/SRC #切换至软件包存放目录
Tar zxvf mysql-5.6.19.tar.gz #解压
CD mysql-5.6.19 #进入目录
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc #配置
Make #编译
Make install #安装
RM-RF/ETC/MY.CNF #删除系统默认的配置文件 (if not removed by default)
Cd/usr/local/mysql #切换至MySQL安装目录
./scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql #生成mysql系统数据库
Ln-s/usr/local/mysql/my.cnf/etc/my.cnf #添加到/etc directory soft connection
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把MySQL加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
#MySQL程序安装路径 #MySQL数据库存放目录
: wq! #保存退出
Systemctl start Mysql.service #启动
Vi/etc/profile #把MySQL服务加入系统环境变量, add the following line configuration at the end
Export path= $PATH:/usr/local/mysql/bin
: wq! #保存退出
Source/etc/profile #使配置立刻生效
The following two lines link the MySQL library file to the default location of the system, so you can compile software like PHP without specifying the MySQL library file address.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Mkdir/var/lib/mysql #创建目录
Ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock #添加软链接
Mysql_secure_installation #设置MySQL密码, press Y to enter the password 2 times according to the prompt
Note: The above operations are in the Xshell login to the remote server with command line operation completed, upload files can be uploaded to the appropriate folder using XFTP.
......................................................................................................................... ................................................
Extracted from System operations (www.osyunwei.com), original link:CentOS 7.0 compiled installation nginx1.6.0+mysql5.6.19+php5.5.14
CentOS 7.2 Minimal compile and install MySQL5.6.31