美文网首页
Ubuntu 安装 PHP7.3 以及相关拓展

Ubuntu 安装 PHP7.3 以及相关拓展

作者: 归隐小赵 | 来源:发表于2020-10-20 17:08 被阅读0次

添加软件源

安装软件源拓展工具:

sudo apt -y install software-properties-common apt-transport-https lsb-release ca-certificates

添加 PHP PPA 源,需要按一次回车(Enter):

sudo add-apt-repository ppa:ondrej/php  

更新软件源缓存:

sudo apt update

安装PHP

安装PHP和对应拓展(redis,memcache等常见拓展)

sudo apt install php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-opcache php7.3-redis php7.3-memcache -y

设置 PHP

安装完成后,编辑 /etc/php/7.3/fpm/php.ini 替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令:

sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/7.3/fpm/php.ini 

重启PHP

sudo systemctl restart php7.3-fpm #重启  执行本命令
sudo systemctl start php7.3-fpm #启动
sudo systemctl stop php7.3-fpm #关闭
sudo systemctl status php7.3-fpm #检查状态`

检查

xdnice@192.168.1.188:~# php -v
PHP 7.3.0-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec  6 2018 20:24:55) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.0-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

安装Memcache

sudo apt-get install memcached

安装redis

sudo apt-get install redis-server

检测是否有自启且启动:

 sudo systemctl -l | grep redis

xdnice@xdnice:~$ sudo systemctl -l | grep redis
redis-server.service                                                                     loaded active running   Advanced key-value store                                                     

安装Nginx

sudo apt-get install nginx

安装Mysql

3行命令 简单安装

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev

检查是否安装成功:

xdnice@xdnice:~$ sudo systemctl -l | grep mysql
mysql.service                                                                            loaded active running   MySQL Community Server  

获取Mysql密码并修改root密码:

sudo cat /etc/mysql/debian.cnf

返回结果:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = hxLnOoGqkKYqt0sn
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = hxLnOoGqkKYqt0sn
socket   = /var/run/mysqld/mysqld.sock

user是登录用户名,password是登录密码
登录系统更改密码

mysql -udebian-sys-maint -phxLnOoGqkKYqt0sn

进入mysql,执行:

use mysql;
//更新 plugin 字段为 mysql 默认值:
update user set plugin='mysql_native_password';
//修改密码
update user set authentication_string=password('root') where user='root' and host='localhost';
//刷新权限
flush privileges;

密码已经修改成功了,设置默认字符集为utf-8

sudo vim /etc/mysql/my.cnf

输入字母I,进入编辑模式,添加字符串

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
#添加内容
[mysqld]
character_set_server = utf8
#END
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

输入: wq保存退出

设置mysql root账号外网连接权限

mysql -udebian-sys-maint -phxLnOoGqkKYqt0sn
 use mysql;
 update user set host='%' where user='root' and host='localhost';
//退出重启mysql
exit
sudo service mysql restart

安装完成!
账号root,密码root

相关文章

网友评论

      本文标题:Ubuntu 安装 PHP7.3 以及相关拓展

      本文链接:https://www.haomeiwen.com/subject/lkidmktx.html