阿里云上安装mariadb10.2.6,和php-5.6.30

安装mariadb

  • 背景
    • 在阿里云上安装
  1. 首先切换到/usr/local/src目录下
[root@hf-02 ~]# cd /usr/local/src
[root@hf-02 src]# 

  1. 然后安装mariadb包,并解压mariadb包
[root@hf-02 src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
  1. 查看解压的包
[root@hf-02 src]# ls
mariadb-10.2.6-linux-glibc_214-x86_64  mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
  1. 移动并改名mariadb包
[root@hf-02 src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
  1. 切换到/usr/local/mariadb目录下
[root@hf-02 src]# cd !$
cd /usr/local/mariadb
  1. 创建用户和目录
[root@hf-02 mariadb]# useradd mysql
[root@hf-02 mariadb]# mkdir /data/
  1. 初始化
[root@hf-02 mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
  • 这里提示是缺少安装包,只需要安装perl-Data-Dumper包和libaio包即可
[root@hf-02 mariadb]# .yum install -y perl-Data-Dumper

[root@hf-02 mariadb]# .yum install -y libaio
  1. 然后再次初始化,在echo $?检查是否成功
[root@hf-02 mariadb]# echo $?
0
  1. 编辑配置文件
[root@hf-02 mariadb]# vim /etc/my.cnf

修改配置文件内容
在 [mysqld] 中
把datadir=/var/lib/mysql 改成 datadir=/data/mysql
把socket=/var/lib/mysql/mysql.sock 改成 socket=/tmp/mysql.sock

在 [mysqld_safe] 中
在log-error行和pid-file行前面 加 # ,把它们注释掉

在 !includedir /etc/my.cnf.d 也注释掉
  1. 拷贝配置文件和启动脚本
[root@hf-02 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
[root@hf-02 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
  1. 编辑启动脚本
[root@hf-02 mariadb]# vim /etc/init.d/mariadb

在文件中定义
basedir=/usr/local/mariadb
datadir=/data/mariadb
  1. 查看文件的权限,是否为755,默认是755权限
[root@hf-02 mariadb]# ls -l /etc/init.d/mariadb
-rwxr-xr-x 1 root root 12258 Dec 22 16:19 /etc/init.d/mariadb
  1. 设置开机启动,将服务加入到服务列表中
[root@hf-02 mariadb]# chkconfig --add mariadb
[root@hf-02 mariadb]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

aegis          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
agentwatch     	0:off	1:off	2:on	3:on	4:on	5:on	6:off
mariadb        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
opensmd        	0:off	1:off	2:off	3:off	4:off	5:off	6:off
srpd           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
  1. 启动mariadb服务
[root@hf-02 mariadb]# service mariadb start
Starting MySQL.171222 16:22:16 mysqld_safe Logging to '/data/mariadb/hf-02.err'.
171222 16:22:16 mysqld_safe Starting mysqld daemon with databases from /data/mariadb
                                                           [  OK  ]
  1. 查看mariadb服务是否启动
[root@hf-02 ~]# ps aux |grep mariadb
root      1017  0.0  0.0 115376  1724 ?        S    12:58   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --datadir=/data/mariadb --pid-file=/data/mariadb/hf-02.pid
mysql     1570  0.0  3.4 1125016 65304 ?       Sl   12:58   0:00 /usr/local/mariadb/bin/mysqld --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb/hf-02.err --pid-file=/data/mariadb/hf-02.pid --socket=/tmp/mysql.sock --port=3306
root      2532  0.0  0.0 112644   964 pts/0    R+   13:36   0:00 grep --color=auto mariadb
[root@hf-02 ~]# 
  1. 查看端口
[root@hf-02 mariadb]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3005/sshd           
tcp6       0      0 :::3306                 :::*                    LISTEN      22840/mysqld    
  1. 这样mariadb服务则就安装启动完成,在开机的时候会自动启动,若是要杀死进程,则killall mysqld ,就会把mariadb服务杀掉。

安装phpphp-5.6.30

  1. 首先进入到/usr/local/src/目录下
[root@hf-02 ~]# cd /usr/local/src/
[root@hf-02 src]#
  1. 然后下载php安装包
[root@hf-02 src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
  1. 解压安装包
[root@hf-02 src]# tar zxvf php-5.6.30.tar.gz
  1. 切换到/usr/local/src/php-5.6.30/目录下
[root@hf-02 src]# cd php-5.6.30
[root@hf-02 php-5.6.30]#
  1. 安装所需要的包
[root@hf-02 php-5.6.30]# yum install -y libxml2-devel

[root@hf-02 php-5.6.30]# yum install -y openssl-devel

[root@hf-02 php-5.6.30]#yum install bzip2-devel

[root@hf-02 php-5.6.30]# yum install -y libjpeg-devel

[root@hf-02 php-5.6.30]#yum install -y libpng-devel

[root@hf-02 php-5.6.30]# yum install -y freetype-devel

[root@hf-02 php-5.6.30]# yum install -y epel-release
[root@hf-02 php-5.6.30]# yum install -y libmcrypt-devel
  1. 然后进行初始化,第一次初始化
[root@hf-02 php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/sbin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
  • 错误
    • 在初始化的时候,提示这个错误
Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/local/apache2.4/bin/apxs follows:
./configure: line 8417: /usr/local/apache2.4/bin/apxs: No such file or directory
configure: error: Aborting

  • 解决办法,将--with-apxs2=/usr/local/sbin/apxs改成--with-apxs2=/usr/bin/apxs
  1. 第二次初始化,把--with-mysql --with-pdo-mysql --with-mysqli这三个=号后面的全干掉,初始化就可以成功了
    • 因为mariadb太新,php暂时只能使用较老版本的mysql的lib库文件
    • 把=号后面的全干掉意思就是编译的时候所需的mysql的lib库文件用mysql默认的文件,而不是你之前报错时指定的库文件
[root@hf-02 php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql --with-pdo-mysql --with-mysqli --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

  1. 然后检查是否初始化成功
[root@hf-02 php-5.6.30]# echo $?
0
  1. 再来make && make install
[root@hf-02 php-5.6.30]# make && make install

最后显示的结果
Installing PEAR environment:      /usr/local/php/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.3.0
[PEAR] PEAR           - installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.30/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
  1. 这样就成功安装了php5

转载于:https://my.oschina.net/u/3707314/blog/1593755

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值