清华大学镜像地址
https://mirrors.tuna.tsinghua…
阿里云镜像地址
https://developer.aliyun.com/…
// 查看 ubuntu 版本
cat /etc/issue
mv /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
// 进入下面网址抉择相应的版本复制内容
apt-get update
apt-get upgrade
LNMP 搭建日志记录
php 装置
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
# 装置 php
sudo apt install -y php7.4-fpm php7.4-redis php7.4-common php7.4-bcmath php7.4-curl php7.4-gd php7.4-mbstring php7.4-mysql php7.4-xml php7.4-zip php7.4-swoole
# 批改 PHP Pools
sudo sed -i 's/listen =.*/listen = 127.0.0.1:9000/' /etc/php/7.4/fpm/pool.d/www.conf
# 重启 php-fpm
sudo systemctl restart php7.4-fpm
# composer
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 洁净卸载
sudo apt-get autoremove php7*
sudo find /etc -name "*php*" |xargs rm -rf
sudo apt purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
start:立即启动前面接的 unit。stop:立即敞开前面接的 unit。restart:立即敞开后启动前面接的 unit,亦即执行 stop 再 start 的意思。reload:不敞开 unit 的状况下,从新载入配置文件,让设置失效。enable:设置下次开机时,前面接的 unit 会被启动。disable:设置下次开机时,前面接的 unit 不会被启动。status:目前前面接的这个 unit 的状态,会列出有没有正在执行、开机时是否启动等信息。is-active:目前有没有正在运行中。is-enable:开机时有没有默认要启用这个 unit。kill:不要被 kill 这个名字吓着了,它其实是向运行 unit 的过程发送信号。show:列出 unit 的配置。mask:登记 unit,登记后你就无奈启动这个 unit 了。unmask:勾销对 unit 的登记。
PHP CLI
sudo sed -i ‘s/display_errors = .*/display_errors = On/’ /etc/php/7.4/cli/php.ini
sudo sed -i ‘s/error_reporting = .*/error_reporting = E_ALL/’ /etc/php/7.4/cli/php.ini
sudo sed -i ‘s/memory_limit = .*/memory_limit = 512M/’ /etc/php/7.4/cli/php.ini
sudo sed -i ‘s/;date.timezone.*/date.timezone = UTC/’ /etc/php/7.4/cli/php.ini
PHP FPM
sudo sed -i ‘s/error_reporting = .*/error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED/’ /etc/php/7.4/fpm/php.ini
sudo sed -i ‘s/memory_limit = .*/memory_limit = 512M/’ /etc/php/7.4/fpm/php.ini
sudo sed -i ‘s/upload_max_filesize = .*/upload_max_filesize = 50M/’ /etc/php/7.4/fpm/php.ini
sudo sed -i ‘s/post_max_size = .*/post_max_size = 50M/’ /etc/php/7.4/fpm/php.ini
sudo sed -i ‘s/;date.timezone.*/date.timezone = UTC/’ /etc/php/7.4/fpm/php.ini
PHP Pools
sudo sed -i ‘s/user = www-data/user = www/’ /etc/php/7.4/fpm/pool.d/www.conf
sudo sed -i ‘s/group = www-data/group = www/’ /etc/php/7.4/fpm/pool.d/www.conf
sudo sed -i ‘s/listen =.*/listen = 127.0.0.1:9000/’ /etc/php/7.4/fpm/pool.d/www.conf
sudo sed -i ‘s/listen.owner.*/listen.owner = www/’ /etc/php/7.4/fpm/pool.d/www.conf
sudo sed -i ‘s/listen.group.*/listen.group = www/’ /etc/php/7.4/fpm/pool.d/www.conf
sudo sed -i ‘s/;listen.mode.*/listen.mode = 0666/’ /etc/php/7.4/fpm/pool.d/www.conf
nginx 装置
apt remove nginx nginx-common nginx-full nginx-core
sudo apt install -y curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
rm -rf nginx_signing.key
apt install nginx
service nginx stop
service nginx start
service nginx restart
service nginx status
nginx
nginx -s quit
nginx -s stop
nginx -t -c /etc/nginx/nginx.conf
nginx -t
nginx -s reload
nginx -s reopen
nginx 与 php 配置文件
形式 1:举荐应用
location ~ \.php$ {fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name;
include fastcgi_params;
}
形式 2: 须要批改 /etc/php/7.2/fpm/pool.d/www.conf
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name;
include fastcgi_params;
}
// 需批改 /etc/php/7.2/fpm/pool.d/www.conf
;listen = /run/php/php7.2-fpm.sock
listen = 127.0.0.1:9000
openresty 装置
apt-get update
导入咱们的 GPG 密钥:
wget -qO – https://openresty.org/package… | sudo apt-key add –
装置 add-apt-repository 命令
(之后你能够删除这个包以及对应的关联包)
sudo apt-get -y install software-properties-common
增加咱们官网 official APT 仓库:
sudo add-apt-repository -y “deb http://openresty.org/package/… $(lsb_release -sc) main”
更新 APT 索引:
sudo apt-get update
而后就能够像上面这样装置软件包,比方 openresty:
sudo apt-get install openresty
export PATH=$PATH:/usr/local/openresty/nginx/sbin
mysql 装置
apt install -y mysql-server mysql-client
service mysql start
service mysql status
service mysql stop
service mysql restart
mysqladmin -uzhiqiang -p123456 password 456789
mysql -uroot -p
mysql> select Host,User,authentication_string from mysql.user;
mysql> create user "zhiqiang"@"localhost" identified by "123456";
mysql> update mysql.user set authentication_string=password("123456") where User="root";
mysql> alter user 'zhiqiang'@'localhost' identified by "123456";
mysql> set password for 'zhiqiang'@'localhost' = '123456';
mysql> update user set plugin="mysql_native_password";
mysql> flush privileges;
# 首先创立一个数据库 (zqw)
create database zqw;
# 受权 zhiqw 用户领有 zqw 数据库的所有权限,但只能在本地拜访。grant all privileges on zqw.* to 'zqw'@localhost identified by '123456';
# 用户能够近程拜访 zqw 数据库
grant all privileges on zqw.* to 'zqw'@'%' identified by '123456';
# 刷新零碎权限表
flush privileges;
# 卸载
sudo rm /var/lib/mysql/ -R
sudo rm /etc/mysql/ -R
sudo apt-get autoremove mysql* --purge
搭建 GitLab 笔记
https://about.gitlab.com/inst…
apt-get install curl openssh-server ca-certificates postfix
service sshd start
service postfix start
sudo curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
apt install -y gitlab-ce
// 配置拜访门路
vi /etc/gitlab/gitlab.rb
>external_url 'http://127.0.0.1'
// 更新配置
gitlab-ctl reconfigure
启动 Gitlab 所有组件
gitlab-ctl start
// 重新启动 gitlab
gitlab-ctl restart
// 查看状态
gitlab-ctl status
RabbitMQ 环境搭建
apt install -y rabbitmq-server
启动 rabbit 服务:service rabbitmq-server start
进行 rabbit 服务:service rabbitmq-server stop
后盾启动:rabbitmq-server -detached
运行状态:rabbitmqctl status
查看所有用户:rabbitmqctl list_users
增加用户:rabbitmqctl add_user username password
删除用户:rabbitmqctl delete_user username
批改明码:rabbitmqctl change_password username newpassword
设置超级权限
rabbitmqctl set_user_tags username administrator
rabbitmqctl set_permissions -p / username ".\*" ".\*" ".\*"
开启 rabbit 网页控制台
进入 rabbit 装置目录:cd /usr/lib/rabbitmq
查看曾经装置的插件:rabbitmq-plugins list
开启网页版控制台:rabbitmq-plugins enable rabbitmq_management
重启 rabbitmq 服务
输出网页拜访地址:http://localhost:15672 应用默认账号:guest/guest 登录
spug 搭建
apt install -y supervisor redis git python3-dev python3-venv libsasl2-dev python-dev libldap2-dev libssl-dev
apt install -y libmariadbclient-dev
mkdir /data
cd /data
git clone https://github.com/openspug/spug
cd spug && git checkout -b v2.3.16
// 后端部署
cd /data/spug/spug_api
python3 -m venv venv
source venv/bin/activate
pip install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install gunicorn mysqlclient -i https://pypi.tuna.tsinghua.edu.cn/simple/
python3 manage.py updatedb
python manage.py user add -u admin -p spug.dev -s -n 管理员
// 前端部署
https://github.com/openspug/spug/releases/download/v2.3.16/web_v2.3.16.tar.gz
rm -rf /data/spug/spug_web
mkdir -p /data/spug/spug_web
tar zxf web_v2.3.16.tar.gz -C /data/spug/spug_web
spug-nginx 配置参考:https://spug.dev/docs/deploy-product/
// 守护过程
cp /data/spug/spug_api/tools/supervisor-spug.ini /etc/supervisor/conf.d/supervisor-spug.conf
service nginx restart
service supervisor restart
service redis restart