环境:
版本IP地址源码包版本
CentOS7.5_MySQL
192.168.111.3
mysql-5.7.24.tar.gz,cmake-3.13.1.tar.gz,boost_1_59_0
Centos7.5_httpd
192.168.111.4
apr-1.6.5,apr-util-1.6.1,httpd-2.4.37
Centos7.5_php
192.168.111.5
php-7.3.1
目录
一、安装配置MySQL
二、安装配置httpd
三、安装配置PHP
一、安装配置MySQL
[root@localhost ~]# yum -y install ncurses-devel
#这个是cmake的依赖包
安装MySQL
[root@localhost ~]# tar xf cmake-3.13.1.tar.gz -C /usr/src/ [root@localhost ~]# cd /usr/src/cmake-3.13.1/ [root@localhost cmake-3.13.1]# ./configure && gmake && gmake install #这步时间较长 [root@localhost cmake-3.13.1]# useradd -M -s /sbin/nologin mysql #创建一个程序用户并且指定参数 [root@localhost cmake-3.13.1]# mkdir /usr/local/boost #创建一个目录,并将boost_1_66_0.tar.gz解压后放到这个目录里 [root@localhost ~]# tar zxf boost_1_59_0.tar.gz -C /usr/local/boost/ [root@localhost ~]# tar xf mysql-*.tar.gz -C /usr/src/ #解压MySQL包 [root@localhost boost_1_59_0]# cd /usr/src/mysql-5.7.24/ [root@localhost mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA _CHARSETS=all -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost && make && make install #这步时间较长 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #数据库程序安装目录 -DDEFAULT_CHARSET=utf8 #指定字符集编码 -DDEFAULT_COLLATION=UTF8_GENERAL_CI #默认的字符集校对规则,utf8_general_ci适用于utf-8字符集的通用规则 -DWITH_EXTRA_CHARSETS=all #指定额外支持的字符集编码 -DSYSCONFDIR=/etc #指定配置文件存放目录 [root@localhost mysql-5.7.24]# cd /usr/local/mysql/ [root@localhost mysql]# chown -R mysql:mysql * #将该目录下的所有文件和目录的属主和属组修改为mysql配置MySQL
[root@localhost mysql]# vim /etc/my.cnf [mysqld] datadir=/usr/local/mysql/data socket=/tmp/mysql.sock [mysqld_safe] log-error=/usr/local/mysql/data/mysql.log pid-file=/usr/local/mysql/data/mysql.pid初始化数据库
[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize --user #指定用户身份运行 --datadir #指定安装目录 --basedir #指定数据目录 执行该命令后注意会出现下面这一行,密码是最后的字符,保存好,待会儿可以进行修改 2019-04-18T08:06:48.532352Z 1 [Note] A temporary password is generated for root@localhost: 4PUsoq3O=rjs设置环境变量
[root@localhost mysql]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile [root@localhost mysql]# . /etc/profile服务启动文件
[root@localhost mysql]# cp support-files/mysql.server /usr/local/mysql/bin/mysqld.sh #将配置文件添加到系统服务 [root@localhost mysql]# chmod +x /usr/local/mysql/bin/mysqld.sh [root@localhost data]# vim /usr/lib/systemd/system/mysqld.service [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql PIDFile=/usr/local/mysql/data/mysqld.pid # Disable service start and stop timeout logic of systemd for mysqld service. TimeoutSec=0 # Execute pre and post scripts as root PermissionsStartOnly=true # Needed to create system tables #ExecStartPre=/usr/bin/mysqld_pre_systemd # Start main service ExecStart=/usr/local/mysql/bin/mysqld --daemonize --pid-file=/usr/local/mysql/data/mysqld.pid #注意这里要加上 --daemonize # Use this to switch malloc implementation #EnvironmentFile=-/etc/sysconfig/mysql # Sets open_files_limit LimitNOFILE = 5000 Restart=on-failure RestartPreventExitStatus=1 PrivateTmp=false [root@localhost data]# systemctl start mysqld [root@localhost data]# systemctl enable mysqld [root@localhost data]# mysqladmin -u root -p4PUsoq3O=rjs password 123456 #修改密码,-p后为旧密码,即初始化时出现的哪个,后面为新密码,有空格 [root@localhost data]# mysql -u root -p123456 #使用新密码,登录数据库,-p后无空格 mysql> grant all privileges on *.* to 'root'@'%' identified by '123456'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) #给用户授权远程连接,稍后在别的服务器上可以通过PHP使用该用户及密码 二、安装配置httpd安装
[root@localhost ~]# useradd -r -s /sbin/nologin -M apache #创建用户 [root@localhost ~]# ls anaconda-ks.cfg apr-1.6.5.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.37.tar.gz initial-setup-ks.cfg [root@localhost ~]# yum -y install pcre-devel openssl-devel expat-devel libxml2-devel bzip2-devel #安装依赖 [root@localhost ~]# mv apr-1.6.5 apr [root@localhost ~]# tar zxf apr-util-1.6.1.tar.gz [root@localhost ~]# mv apr-util-1.6.1 apr-util #配置所需的包 [root@localhost ~]# tar zxf httpd-2.4.37.tar.gz -C /usr/src/ [root@localhost ~]# cd /usr/src/httpd-2.4.37/ [root@localhost httpd-2.4.37]# mv /root/{apr-util,apr} srclib/ [root@localhost httpd-2.4.37]# ./configure --prefix=/usr/local/httpd --enable-so --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-includ ed-apr=/root/apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork && make && make install