Ubuntu下使用apt方式安装Mysql8.0版本 以及 使用ppa搭建nginx+PHP+redis+mysql环境记录

一、Ubuntu下使用apt方式安装Mysql8.0版本

    在Ubuntu上使用apt-get install mysql会自动安装5.7版本(repositories上MySQL的版本是5.7,)。可以试试# apt search mysql8发现找不到任何内容,而搜索# apt search mysql能看到有5.7版本。因此我们不通过直接执行apt-get install mysql-server命令来安装我们要安装的MySQL8版本。mysql8.0版本的下载地址:MySQL :: Download MySQL Community Server

    安装方式可以自己手动下载一个一个包,然后按照一定顺序逐个安装,但那样真的很麻烦,要下载的包很多,而且顺序还不能错,直接安装mysql-community-server-core-dbgsym还会报错。比如下面:

#下载MYSQL 服务包
root@test:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/libmysqlclient21-dbgsym_8.0.25-1ubuntu18.04_amd64.deb
root@test:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-server-core-dbgsym_8.0.25-1ubuntu18.04_amd64.deb
root@test:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-client-dbgsym_8.0.25-1ubuntu18.04_amd64.deb
root@test:~# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-community-client-core-dbgsym_8.0.25-1ubuntu18.04_amd64.deb
......
#直接安装mysql-community-server-core-dbgsym报错如下:
# dpkg -i mysql-community-server-core-dbgsym_8.0.25-1ubuntu18.04_amd64.deb 
mysql-community-server-core-dbgsym depends on mysql-community-server-core (= 8.0.25-1ubuntu18.04); however:
Package mysql-community-server-core is not installed.
dpkg: error processing package mysql-community-server-core-dbgsym (--install):

  所以建议的安装方式是通过下载apt来安装: MySQL :: Download MySQL APT Repository

# apt-get update
# wget https://repo.mysql.com//mysql-apt-config_0.8.17-1_all.deb
# dpkg -i mysql-apt-config_0.8.17-1_all.deb
# apt-get update
# apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
# apt --fix-broken install
Processing triggers for libc-bin (2.27-3ubuntu1.3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
# apt-get install mysql-server
success 

    在执行dpkg -i mysql-apt-config_0.8.17-1_all.deb的时候会提示你选择MYSQL版本。执行apt-get install mysql-server会提示输入初始化root密码。安装前apt-get update不要有问题,我在dpkg安装时一直不能成功,因为apt-get update报错。有个package不能验证通过。

# apt-get update
Reading package lists... Done 
W: GPG error: http://repo.y.. main/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C8F1E19FE0C56BD4  
E:The repository 'http://repo.y.." main/ Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

    可以通过编辑/etc/apt/sources.list 去掉有问题的包后再尝试apt-get update,也可以试试网上提供的通用方法。我这里使用这个通用方法并没有成功,不过列在这里当个记录。
#网上提示可用的方法
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 425956BB3E31DF51

二、Ubuntu下使用ppa搭建nginx+PHP+redis+mysql环境记录

ubuntu下使用ppa搭建nginx+PHP+redis+mysql环境的执行记录,以待后续留用。

#包中包含了add-apt-repository的二进制文件工具
root@us12:~# apt-get install python-software-properties software-properties-common    
root@us12:~# apt-get update
root@us12:~# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
......
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it
#这里按ENTER
gpg: keyring `/tmp/tmp69m7qjho/secring.gpg' created
gpg: keyring `/tmp/tmp69m7qjho/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp69m7qjho/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
root@us12:~# apt-get update
Fetched 23.9 kB in 1s (19.6 kB/s)
Reading package lists... Done
root@us12:~# apt-get install php-pear php7.1-cli php7.1-common php7.1-curl php7.1-dev php7.1-fpm php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-zip php7.1-intl php7.1-gd php7.1-xml
#列出php7.1的所有扩展
root@us12:~# apt-cache search php7.1   
php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-geoip - GeoIP module for PHP
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-redis - PHP extension for interfacing with Redis
php-rrd - PHP bindings to rrd tool system
php-smbclient - PHP wrapper for libsmbclient
php-solr - PHP extension for communicating with Apache Solr server
php-ssh2 - Bindings for the libssh2 library
php-uuid - PHP UUID extension
php-yac - YAC (Yet Another Cache) for PHP
php-zmq - ZeroMQ messaging bindings for PHP
libapache2-mod-php7.1 - server-side, HTML-embedded scripting language (Apache 2 module)
libphp7.1-embed - HTML-embedded scripting language (Embedded SAPI library)
php-apcu-bc - APCu Backwards Compatibility Module
php-ds - PHP extension providing efficient data structures for PHP 7
php-gearman - PHP wrapper to libgearman
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-gnupg - PHP wrapper around the gpgme library
php-http - PECL HTTP module for PHP Extended HTTP Support
php-lua - PHP Embedded lua interpreter
php-mailparse - Email message manipulation for PHP
php-memcache - memcache extension module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-pcov - Code coverage driver
php-phalcon - full-stack PHP framework delivered as a C-extension
php-pinba - Pinba module for PHP
php-propro - propro module for PHP
php-psr - PSR interfaces for PHP
php-radius - radius client library for PHP
php-raphf - raphf module for PHP
php-sass - PHP bindings to libsass - fast, native Sass parsing in PHP
php-sodium - PHP wrapper for the Sodium cryptographic library
php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP
php-tideways - Tideways PHP Profiler Extension
php-uploadprogress - file upload progress tracking extension for PHP
php-xdebug - Xdebug Module for PHP
php-yaml - YAML-1.1 parser and emitter for PHP
php7.1 - server-side, HTML-embedded scripting language (metapackage)
php7.1-bcmath - Bcmath module for PHP
php7.1-bz2 - bzip2 module for PHP
php7.1-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.1-cli - command-line interpreter for the PHP scripting language
php7.1-common - documentation, examples and common module for PHP
php7.1-curl - CURL module for PHP
php7.1-dba - DBA module for PHP
php7.1-dev - Files for PHP7.1 module development
php7.1-enchant - Enchant module for PHP
php7.1-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.1-gd - GD module for PHP
php7.1-gmp - GMP module for PHP
php7.1-imap - IMAP module for PHP
php7.1-interbase - Interbase module for PHP
php7.1-intl - Internationalisation module for PHP
php7.1-json - JSON module for PHP
php7.1-ldap - LDAP module for PHP
php7.1-mbstring - MBSTRING module for PHP
php7.1-mcrypt - libmcrypt module for PHP
php7.1-mysql - MySQL module for PHP
php7.1-odbc - ODBC module for PHP
php7.1-opcache - Zend OpCache module for PHP
php7.1-pgsql - PostgreSQL module for PHP
php7.1-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.1-pspell - pspell module for PHP
php7.1-readline - readline module for PHP
php7.1-recode - recode module for PHP
php7.1-snmp - SNMP module for PHP
php7.1-soap - SOAP module for PHP
php7.1-sqlite3 - SQLite3 module for PHP
php7.1-sybase - Sybase module for PHP
php7.1-tidy - tidy module for PHP
php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.1-xmlrpc - XMLRPC-EPI module for PHP
php7.1-xsl - XSL module for PHP (dummy)
php7.1-zip - Zip module for PHP
php7.1-phalcon - High performance PHP framework
php7.1-phalcon-dbgsym - Debug symbols for php7.1-phalcon
#使用apt seach 可以显示是否已经installed
root@us12:~# apt search php7.1
Sorting... Done
Full Text Search... Done
libapache2-mod-php7.1/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
libphp7.1-embed/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1/xenial,xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 all
php7.1-bcmath/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-bz2/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-cgi/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-cli/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-common/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-curl/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-dba/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-dev/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-enchant/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-fpm/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-gd/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-gmp/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-imap/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-interbase/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-intl/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-json/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-ldap/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-mbstring/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-mcrypt/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-mysql/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-odbc/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-opcache/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-pgsql/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-phalcon/xenial 3.4.5-1+php7.1 amd64
php7.1-phalcon-dbgsym/xenial 3.4.5-1+php7.1 amd64
php7.1-phpdbg/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-pspell/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-readline/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.1-recode/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-snmp/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-soap/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-sqlite3/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-sybase/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-tidy/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-xml/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
php7.1-xmlrpc/xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64
php7.1-xsl/xenial,xenial 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 all
php7.1-zip/xenial,now 7.1.33-1+ubuntu16.04.1+deb.sury.org+1 amd64 [installed]
root@us12:~# apt-get install libcurl4-gnutls-dev libpcre3-dev
root@us12:~# pecl install redis;sh -c "echo 'extension=redis.so' > /etc/php/7.1/mods-available/redis.ini"
root@us12:~# sed -i 's/listen = .*/listen = 127.0.0.1:9000/g' /etc/php/7.1/fpm/pool.d/www.conf
root@us12:~# service php7.1-fpm restart
root@us12:~# apt-get install nginx mysql-server redis-server beanstalkd

    安装mysql的时候会要求输入2次root密码完成mysql初始密码设定,ppa安装的php默认是使用sock文件通信,一般会改成tcp使用默认的9000端口。可以使用以下两种启动命令,
systemctl restart/start/stop/status php7.1-fpm
service php7.1-fpm restart/start/stop/status
service nginx restart等

    另外在ubuntu上使用ondrej/php这个PPA安装php时,如果出现类似下面的报错:UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128) 原因是当前系统不是UTF-8的locales,可以通过LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php命令解决。LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林戈的IT生涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值