Debian常用环境安装配置总结

导语:Centos8于2021年12月31日停止服务支持,所以今天学习了如何使用debian部署常用环境安装和配置。

# 目录

  • PHP7.4
  • nginx
  • mysql
  • redis

# PHP7.4

  • 升级软件
apt update
apt upgrade
1
2
  • 配置源
apt -y install lsb-release apt-transport-https ca-certificates wget
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt update
1
2
3
4
  • 搜索安装
apt search php7.4
1

php7.4

  • 安装php7.4及依赖包
apt install php7.4
apt install php7.4-{fpm,dev,cli,curl,gd,bcmath,common,json,redis,ssh2,xml,xmlrpc,intl,soap,mbstring,sqlite3,mysql,pgsql,ldap,opcache,bz2,zip}
1
2
  • 查看版本
php -v
PHP 7.4.21 (cli) (built: Jul  2 2021 15:33:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
1
2
3
4
5
  • 运行php-fpm
systemctl status php-fpm
systemctl start php-fpm
1
2

# nginx

  • 安装nginx
apt install nginx 
1
  • 查看版本
sudo nginx -v
nginx version: nginx/1.14.2
1
2
  • 运行配置
systemctl start nginx
1

# mysql

  • 添加源
wget http://repo.mysql.com/mysql-apt-config_0.8.10-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
1
2
  • 安装mysql
sudo apt update
sudo apt install mysql-server
1
2
  • 启动
sudo systemctl status mysql
1
  • 保护mysql
sudo mysql_secure_installation
1
  • 登录
mysql -u root -p
1

# redis

  • 安装redis
wget https://download.redis.io/releases/redis-6.2.4.tar.gz
tar -xzf redis-6.2.4.tar.gz
cd redis-6.2.4
make
1
2
3
4
  • 配置redis
# 移动Src到自定义
mkdir -p /usr/local/etc/redis/{bin,etc}
cp redis-6.2.4/src/redis-cli /usr/local/etc/redis/bin
cp redis-6.2.4/src/redis-server /usr/local/etc/redis/bin
cp redis-6.2.4/src/redis.conf /usr/local/etc/redis/etc
1
2
3
4
5
  • 后台运行
vim /lib/systemd/system/redis.service
1
[Unit]
Description=Redis
After=syslog.target network.target remote-fs.target nss-lookup.target
​
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid

ExecStart=/usr/local/etc/redis/bin/redis-server /usr/local/etc/redis/etc/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
​
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

建立链接,刷新配置

ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service
systemctl daemon-reload
1
2

修改profile文件

vi /etc/profile
1
# 最后行添加:
export PATH="$PATH:/usr/local/redis/bin"
1
2

应用文件:

source /etc/profile
1
  • mkcert
sudo yum install nss-tools
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64
chmod +x  mkcert
sudo mv mkcert /usr/local/bin
mkcert -install
1
2
3
4
5

分享至:

  • qq
  • qq空间
  • 微博
  • 豆瓣
  • 贴吧