Ubuntu Apache 添加端口

编辑 /etc/apache2/ports.conf,添加你要监听的端口

Listen 8888

设置虚拟主机

<VirtualHost *:8888>
...
</VirtualHost>

oh my zsh 常用插件的常用命令

Ubuntu:

agi: 安装包

agp: 删除包和配置文件

agu: 更新本地包索引文件

agug: 更新所有包

git:

gaa	
#git add --all 添加所有修改到暂存区

gcam
# git commit -a -m 添加注释 比如 gcam "update"

gp
# git push 提交

systemd:

  • sc-start (即 sudo systemctl start 下同)
  • sc-stop
  • sc-reload
  • sc-restart
  • sc-status

arch linux:

  • pacin (sudo pacman -S)安装软件包
  • pacreps (pacman -Ss) 搜索软件包
  • pacre (sudo pacman -R) 删除软件包
  • pacrem (sudo pacman -Rns) 删除软件包包括依赖和配置文件
  • pacupg (sudo pacman -Syu)更新所有软件包

dnf:

  • dnfi 安装包
  • dnfgi 安装组包
  • dnfr 删除包
  • dnfu 更新包
  • dnfs 搜索包

Ubuntu 彻底卸载数据库

首先在终端中查看MySQL的依赖项

dpkg --list|grep mysql

卸载

apt-get remove mysql-common

清除残留数据

dpkg -l|grep ^rc|awk '{print$2}'|sudo xargs dpkg -P

继续查找安装的相关包,卸载

dpkg --list|grep mysql

ubuntu 20.04更换网站服务器apache为nginx

首先停用apache

systemctl stop apache2

安装nginx和php-fpm

apt install nginx php-fpm

创建nginx配置文件 nano /etc/nginx/sites-available/zrdn.conf

server {
    listen 80;
    server_name zuoridangnian.com;
    root /var/www/zrdn;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}

启用站点

ln -s /etc/nginx/sites-available/zrdn.conf /etc/nginx/sites-enabled

重启nginx

systemctl restart nginx

配置ssl证书,安装certbot nginx

apt-get install certbot python3-certbot-nginx

配置证书

certbot –nginx

选择域名,然后选择第二项,renew 更新证书,然后因为我用了cloudflare的cdn,所以选择No Redirect

如果你也用了cloudflare 并且ssl是flexible模式,则你vps其实可以不用安装ssl证书

重载一下nginx,大功告成

systemctl restart nginx

ubuntu server 18.04升级到20.04

首先将系统升级到最新

sudo apt update && sudo apt upgrade

然后安装ubuntu版本升级工具

sudo apt install update-manager-core

然后强制升级系统

sudo do-release-upgrade -d

期间出现让你选择y/N的选择y

其它选择的直接默认回车

过个几分钟就能升级好了

最后选择y重启即可!

nodejs连接远程mysql常见问题

Error: connect ETIMEDOUT

应该是mariadb默认只允许本地连接,修改 /etc/mysql/mariadb.conf.d/50-server.cnf 文件

然后将 bind-address 127.0.0.1 改成 0.0.0.0 然后重启mysql

Error: ER_HOST_NOT_PRIVILEGED: Host ‘xxx’ is not allowed to connect to this MariaDB server

这种是你登录的用户只允许本地连接

USE mysql;
SELECT user,host FROM user;

// 这样可以看到你的用户和权限,把localhost改成你的ip或者改成 % 允许所有ip登录

GRANT ALL PRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'passwd' WITH GRANT OPTION;

上面该权限的代码要注意 用户名 不用加单引号,%要加,密码要加

参见 Configuring database connection results in Error: Host ‘xxxxxxx’ is not allowed to connect to this MySQL server – Atlassian Documentation

ubuntu 18.04 安装LAMP

apt-get -y install mariadb-server mariadb-client apache2 php7.2 libapache2-mod-php7.2 php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache  php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettext  php7.2-opcache php-apcu


mysql_secure_installation

## 新建用户给予权限

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'howtoforge';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

## certbot 证书

apt-get install software-properties-common
add-apt-repository universe
add-apt-repository ppa:certbot/certbot

apt-get install certbot python3-certbot-apache

certbot --apache

Ubuntu 18.04 (LTS) LAMP server tutorial with Apache, PHP 7.2, and MySQL

Certbot – Ubuntubionic Apache

ubuntu安装ftp服务

apt-get install vsftpd
systemctl start vsftpd
rm /etc/pam.d/vsftpd

Ubuntu安装最新版本的Apache

1.添加第三方PPA

sudo add-apt-repository ppa:ondrej/apache2
sudo apt update

2.安装apache

sudo apt install apache2

Ubuntu安装最新版本PHP并设置Apache使用版本

ubuntu16.04默认php版本7.0,18.04是7.2,而最新的php版本是7.3
1.添加php apt储存库

apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update

2.然后安装指定的php版本

apt-get install php7.3

然后根据需要安装模块

apt-get install php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php7.3-zip php7.3-mysql php7.3-xml

查看版本

➜  ~ php -v
PHP 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 17 2018 09:22:12) ( 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-2+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

cli的版本已经是最新的了
3.设置apache使用的版本
在Debian系中可以直接使用

a2dismod php7.0
a2enmod php7.3

然后重启apache即可
 

没有更多文章了