系统环境:Ubuntu20.04&22.04
1,安装PHP7.4;
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.4
2,安装PHP7.4模块;
sudo apt-cache search php7.4
sudo apt-get install php7.4 php7.4-fpm php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl php7.4-xml php7.4-dev php7.4-mbstring php7.4-gd php7.4-bcmath php7.4-zip
sudo apt install php8.1 php8.1-fpm php8.1-mysql php8.1-curl php-json php8.1-cgi php8.1-xsl php8.1-xml php8.1-dev php8.1-mbstring php8.1-gd php8.1-bcmath php8.1-zip
3,安装Nginx;
sudo service apache2 stop
sudo apt-get install nginx
sudo service nginx start
sudo nginx -h
4,安装Mysql8.0;
Mysql官网上下载安装文件,把文件上传到服务器:
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
直接方向键选择OK回车:
注意加密方式选择5版本加密
sudo apt-get update
sudo apt-get install mysql-server
注意:出现下面类似报错:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
请输入下面命令:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 467B942D3A79BD29
要修改字符集,首先得找到Mysql的安装位置,可使用如下命令:
whereis mysql
将目录切换到/etc/mysql下,修改mysql.conf.d文件夹下的mysqld.cnf,在文件末尾追加character-set-server=utf8,然后保存即可:
重启Mysql服务:
sudo service mysql restart
登录Mysql
mysql -u root -p
登录成功以后在控制台窗口下输入status查看相关信息。
注意:如果选择了默认加密方式,需要调整加密方式,先在mysqld.cnf文件里面加入:
default_authentication_plugin=mysql_native_password
重新设置密码:
配置文件添加:skip-grant-tables
先刷新一下权限表。
mysql> flush privileges;
mysql -uroot -p
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
支持 emoji 图标存储:
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
5,安装Git;
sudo apt-get install git
6,安装Redis;
Ubuntu16.04安装并配置Redis
git clone https://github.com/phpredis/phpredis.git
cd phpredis
sudo phpize
sudo ./configure
sudo make
sudo make install
sudo apt-get install redis-server
ps -aux|grep redis
netstat -nlt|grep 6379
修改php.ini加入
extension=redis.so
7,安装Swoole;
sudo apt-get install autoconf
sudo git clone -b v4.8.13 --depth=1 https://gitee.com/swoole/swoole.git
cd swoole
sudo phpize
sudo ./configure \
--enable-openssl \
--enable-http2 \
--enable-sockets \
--enable-mysqlnd
sudo make
sudo make install
whereis php
cd /etc/php/7.4/cli/
sudo vim php.ini
修改php.ini加入
extension=swoole.so
swoole.use_shortname = off
注意:使用稳定版,否则可能出现编译报错
通过sudo php -m或者phpinfo()来查看是否成功加载了swoole.so
7,安装Composer;
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer