Tag: ubuntu

  • ubuntu22.04 auto run on startup iptables -t nat -A POSTROUTING -j MASQUERADE

    ubuntu22.04 auto run on startup iptables -t nat -A POSTROUTING -j MASQUERADE

    在 Ubuntu 22.04 中,由于系统默认使用 systemd 且 iptables 规则重启后会丢失,要实现开机自动执行这条 NAT 转发规则,最可靠的方式是通过 systemd 服务来实现。以下是详细步骤: 新建一个文件 /usr/local/bin/iptables-nat.sh ,内容: chmod +x /usr/local/bin/iptables-nat.sh 再新建一个启动文件:/etc/systemd/system/iptables-nat.service systemctl daemon-reloadsystemctl enable iptables-nat.servicesystemctl start iptables-nat.service 以下是验证:

  • 2024年如何安装Linux, Nginx, MySQL, PHP (LEMP stack) wordpress on Ubuntu22.04

    2024年如何安装Linux, Nginx, MySQL, PHP (LEMP stack) wordpress on Ubuntu22.04

    新装的ubuntu22.04 (在interserver购买的vps) ,下面步骤直接操作: apt updateapt install nginx 查看防火墙的可配置文件的选项,便于后面的规则添加: 和防火墙的现在的运行状态: inactive表示防火墙并没有启用,把它开启,先开启ssh,别把自己关到外面,再配置web服务器,还没有签证书,只开80端口就可以: 这样,防火墙开启了,并且有了2条规则,80和22 查看自己的ip:curl -4 icanhazip.com ,此时可以通过ip访问nginx 下面安装mysql: apt -y install mysql-server 运行 mysql_secure_installation 安全配置,安全最重要!!! 直接就可以进入mysql: 下面安装php: apt -y install php8.1-fpm php-mysql 先看看nginx的启动用户是哪个: 下面配置nginx的php解析,就使用用户www-data mkdir -p /var/www/us.moneyslow.comchown -R www-data:www-data /var/www/us.moneyslow.com 我们只用/etc/nginx/conf.d下的配置文件,其他地方的都删掉: # rm -rf /etc/nginx/sites-enabled/# rm -rf /etc/nginx/sites-available/ vi /etc/nginx/conf.d/us.moneyslow.conf 测试配置文件,并重启nginx: 在/var/www/us.moneyslow.com目录下创建一个php的测试文件:index.php 可以访问到php页面: 这样基本就ok了,更详细的测试数据库的文档可以参考: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu 如果进一步安装wordpress,可以参考: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-22-04

  • 诡异的ping结果自动添加了.com是为啥?

    诡异的ping结果自动添加了.com是为啥?

    在一个vps服务器上,ping一个.com的域名: 发现没有,自动添加了.com ,同样可以验证: 以上是明确有正确解析的域名,来一个不存在的域名: 同样的,自动添加了.com 开始不知道为什么,后来查了资料才知道是因为自己设置主机名是moneyslow.com造成的,简单说,就是你如果设置了主机名为moneyslow.com,那么默认你的主机是在.com的域里,你自己的名字是moneyslow,这个.com是你所属的“域”,当你查找另外一个主机时,系统会自动在.com的域里为你查找,这是一个功能,所以会给你自动加上.com,表示在.com域里进行查找。 所以解决办法有两个: 1、在/etc/resolv.conf里添加: 最终/etc/resolv.conf的内容如下: 2、修改主机名,不带.com 参考地址:https://superuser.com/questions/630939/linux-ping-and-telnet-automatically-add-com-to-non-existing-domain-names 另外,本例子中由于运营商的问题,mail.moneyslow.com在解析正确的情况下,依然不能ping通,是这个运营商的问题,但是这个问题是另外一个问题,恰巧引起了这个问题。

  • 科普Anycast技术,很贵很贵的IP地址

    科普Anycast技术,很贵很贵的IP地址

    全国用户最终会根据距离DNS服务器的远近来判断使用哪个DNS服务器做域名解析; 从DNS角度来说,正因为不同的地理位置用户会根据就近路由判断,从而选择不同的DNS服务器,最终会使三台DNS服务器达到负载均衡的效果; 若其中某一个节点出现故障以后,业务会立即自动迁移到其他可用的节点上,从而避免网路服务故障。

  • 阿里云腾讯云服务器绑定多个公网IP的路由问题
  • ubuntu22.04安装配置优化mysql8

    ubuntu22.04安装配置优化mysql8

    ubuntu22.04安装配置优化mysql8

  • ubuntu22.04永久修改主机名

    ubuntu22.04永久修改主机名

    ubuntu22.04永久修改主机名

  • ubuntu22.04下dns服务器地址127.0.0.53 和 MASQUERADE 的矛盾

    ubuntu22.04下dns服务器地址127.0.0.53 和 MASQUERADE 的矛盾

    ubuntu的dns的坑,虽然我们更换了dns server,但是系统还是去找127.0.0.53,这个是systemd-resolved这个服务很多人遇到的坑的地方。 今天不管它,停掉!

  • shell下的翻译命令Translate-shell, translate to any language from the command line

    shell下的翻译命令Translate-shell, translate to any language from the command line

    项目地址:https://github.com/soimort/translate-shell 另外一个项目地址:https://www.soimort.org/translate-shell/ 两种安装方法:1、git clone https://github.com/soimort/translate-shell && cd translate-shellmakesudo make install 2、apt-get install translate-shell 安装完成后,以下是常用命令: 1、查看支持语言类型:trans -T 2、翻译中文到英文:#trans :en 你好 你好(Nǐ hǎo) Hello Definitions of 你好[ 简体中文 -> English ] interjectionHello!你好!, 喂!Hi!嗨!, 你好!Hallo!你好! 你好Hello, Hi, Hello there 3、翻译一个文本文件:trans :en file:///home/sapoclay/gtrans.txt 4、交互模式:trans -shell en:es thanks 其他具体用法可以参考github官网,或者以下帮助文档:

  • ubuntu22.04安装php7(或者升级到php8.2)

    ubuntu22.04安装php7(或者升级到php8.2)

    ubuntu操作系统下安装php7版本

  • 腾讯云阿里云服务器多个网卡配置多个公网ip

    腾讯云阿里云服务器多个网卡配置多个公网ip

    ubuntu20下多个公网ip地址配置方法

  • Ubuntu22.04编译安装nginx时报错error: ‘ENGINE_free’ is deprecated: Since OpenSSL 3.0
  • ubuntu18下升级nginx到最新版

    ubuntu18下升级nginx到最新版

    ubuntu18下nginx升级到最新版

  • linux(ubuntu) crontab 日志切割logrotate为什么是6点25分?
  • ubuntu18.04的dns配置有点与众不同

    ubuntu18.04的dns配置有点与众不同

    /etc/resolved.conf是整个dns解析的核心文件,应该是一个规范文件,linux的有关的解析域名的系统api只从这个文件里面获取dns server。

  • ubuntu的/etc/rc.local不执行的问题

    ubuntu的/etc/rc.local不执行的问题

    本文的操作系统是: VERSION=”18.04.6 LTS (Bionic Beaver)” 1、查看/etc/systemd/system/rc-local.service 中是否有【Install】段(用于设置启动的的一些参数) [Unit]Description=/etc/rc.local CompatibilityDocumentation=man:systemd-rc-local-generator(8)ConditionFileIsExecutable=/etc/rc.localAfter=network.target [Service]Type=forkingExecStart=/etc/rc.local startTimeoutStartSec=0TimeoutStopSec=30RemainAfterExit=yesGuessMainPID=no [Install]WantedBy=multi-user.target 2、设置具体的开机自动执行的脚本: cat /etc/rc.local 加权限配置自动启动chmod +x /etc/rc.localsystemctl enable rc-localsystemctl start rc-local.service 检查systemctl status rc-local.service 以上骚操作一般都会搞定

  • ubuntu如何更改crontab的默认编辑器nano改为vim
  • 文本编码判断Non-ISO extended-ASCII text, with very long lines, with CRLF line terminators

    文本编码判断Non-ISO extended-ASCII text, with very long lines, with CRLF line terminators

    如题有些下载的文本的编码格式很奇怪。通过file命令看到: file systeminfo.txt Non-ISO extended-ASCII text, with very long lines, with CRLF line terminators 假如作者搞了个奇奇怪怪的编码格式,你都不知道。通过一个脚本来发现它: 执行: ./code.sh systeminfo.txt 查看result.txt,关注GB开头的就可以了: 执行转换命令: iconv -f GB18030 -t UTF-8 systeminfo.txt > 2222.txt # file 2222.txt2222.txt: UTF-8 Unicode text, with very long lines, with CRLF line terminators

  • Install 安装 PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04

    ########## Install NGINX ############## # Install software-properties-common package to give us add-apt-repository package sudo apt-get install -y software-properties-common # Install latest nginx version from community maintained ppa sudo add-apt-repository ppa:nginx/stable # Update packages after adding ppa sudo apt-get update # Install nginx sudo apt-get install -y nginx # Check status sudo service nginx # Start…

  • Ubuntu 16.04安装MariaDB Master and Slave Replication主从配置

    Ubuntu 16.04安装MariaDB Master and Slave Replication主从配置

    原文标题:How to Setup MariaDB Master and Slave Replication on Ubuntu 16.04 Requirements Two fresh Alibaba Cloud instance with Ubuntu 16.04 installed. A static IP address 192.168.0.101 is configured on the Master node and 192.168.0.102 is configured on the Slave node. A Root password is set up on both instance. Launch Alibaba Cloud ECS Instance First,…

  • Ubuntu自安装的Chrome启动失败解决方法

    Ubuntu自安装的Chrome启动失败解决方法

    使用Ubuntu系统时,桌面上的chrome图标不能点击进入,一直都是无响应状态,但是其他浏览器,比如自带的Firefox就可以正常启动和使用。 点击chrome图标不管用,并且看不到任何出错信息,无法定位问题出在哪里。只好,从终端使用google-chrome命令来启动chrome浏览器客户端了。于是,出现以下错误信息: money@money-Latitude:~$ google-chrome [5901:5901:0610/183033:ERROR:process_singleton_linux.cc(309)] 其他计算机 (money-Latitude-E5430-non-vPro) 的另一个 Google Chrome 进程 (7578) 好像正在使用此个人资料。Chrome 已锁定此个人资料以防止其受损。如果您确定其他进程目前未使用此个人资料,请为其解锁并重新启动 Chrome。 [5901:5901:0610/183033:ERROR:simple_message_box_views.cc(208)] Unable to show a dialog outside the UI thread message loop: Google Chrome – 其他计算机 (money-Latitude-E5430-non-vPro) 的另一个 Google Chrome 进程 (7578) 好像正在使用此个人资料。Chrome 已锁定此个人资料以防止其受损。如果您确定其他进程目前未使用此个人资料,请为其解锁并重新启动 Chrome。 Note:显然,上面的错误信息告诉我们,尼玛,chrome会记录我们在计算机上的操作数据在本地,然后我们修改主机名后,导致老数据被锁住了,这样新的主机名下chrome无法获取用户对应的浏览器数据,因此chrome无法正常启动,并且在UI上还无法看到相关错误,导致假死现象出现。 解决方法: 先把本机上的chrome卸载掉,当然这不会把那些被锁定的数据也一并删除掉,不然我也不会写一篇博客记录下。因此,接下来,你需要删除掉自个目录下的残留的chrome用户数据。 在当前用户目录下面执行命令: 先cd到用户目录。 money@money-Latitude:~$ cd .config/ money@money-Latitude:~/.config$ rm -rf google-chrome/ 再试试?

  • How to Install Google Chrome Web Browser on Ubuntu 18.04 安装谷歌浏览器chrome

    Google Chrome is the most widely used web browser in the world. It is fast, easy to use and secure browser built for the modern web. Chrome is not an open source browser and it is not included in the Ubuntu repositories. Google Chrome is based on Chromium, an open-source browser which is available in…

  • ubuntu下增加rsync服务并设置为自启动

    Step 1 – Install rsync Install rsync with apt command sudo apt-get -y install rsync Step 2 – Configure rsync daemon Configure rsync config using nano , it will automatically create file if not exist vi /etc/rsyncd.conf [backup] # destination directory path = /home/backup # hosts you allow to access, only allow ip 192.168.1.100 hosts…

  • ubuntu 内核升级到Linux 4.4.0-121-generic x86_64 后安装docker到18.03.0-ce

    安装基本按照官方文档: https://docs.docker.com/install/linux/docker-ce/ubuntu/ 但是如果有些问题不顺利可能会重装,删除旧的docker 要注意的地方: rm -rf /var/lib/docker/ 如果改过bridge的名字,注意这个地方/etc/docker/daemon.json: {   “bridge”: “docker0” } 如果docker 起不来,检查 /etc/systemd/system/docker.service.d 下的脚本,可以删除。 apt install docker-ce 的时候有可能会遇到 libseccomp2 版本的问题 下载要求的版本进行安装即可 dpkg -i libseccomp2_2.3.1-2.1ubuntu2_16.04.1_amd64.deb 最终实现: # uname -msr Linux 4.4.0-121-generic x86_64 # docker version Client:  Version:       18.03.0-ce  API version:   1.37  Go version:    go1.9.4  Git commit:    0520e24  Built: Wed…

  • ubuntu 内核升级与降级

    升级linux内核,普遍使用系统提供的功能 sudo apt-get dist-upgrade 降级就比较麻烦了,需要我们自己手动安装。 下面老蔡以Ubuntu 14.04为例,从内核版本linux-headers-3.13.0-44降级到linux-headers-3.13.0-24为例,来演示下怎么降级linux内核。 sudo aptitude install -y linux-image-3.13.0-24-generic \ linux-headers-3.13.0-24 grep submenu /boot/grub/grub.cfg   看到父选项 Advanced options for Ubuntu grep menuentry /boot/grub/grub.cfg 看到子选项 Ubuntu, with Linux 3.13.0-24-generic 其他版本也可以从执行结果中选取相应的。 然后修改/etc/default/grub文件 sudo vim /etc/default/grub 将其中 GRUB_DEFAULT=0 改为 GRUB_DEFAULT=”Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-24-generic” #GRUB_DEFAULT=”Advanced options for Ubuntu>Ubuntu, with Linux 4.4.0-117-generic” #GRUB_DEFAULT=0 然后执行…

  • docker proxy TLS handshake timeout.

    docker 设置代理后下载镜像的时候会报错: TLS handshake timeout. 解决办法: /etc/systemd/system/docker.service.d# cat http-proxy.conf  [Service]  Environment=”HTTP_PROXY=http://192.168.50.165:6500/” “NO_PROXY=localhost,127.0.0.1,hostname” Environment=”HTTPS_PROXY=http://192.168.50.165:6500/” 注意加的 “NO_PROXY=localhost,127.0.0.1,hostname” 起作用。 重启system的服务: systemctl daemon-reload 验证下配置是否正常加载:systemctl show –property=Environment docker 重启docker:systemctl restart docker

  • 利用squidman在mac上搭建代理服务作为ubuntu的apt源

    利用squidman在mac上搭建代理服务作为ubuntu的apt源

    软件地址:http://squidman.net/squidman/ 打开后修改端口号,点击开始即可。 场景:如果有服务器不能上网的话,可以连过来,比如ubuntu 的apt 源。 新建文件: /etc/apt/apt.conf 内容: Acquire::http::Proxy “http://192.100.50.15:61500”;

  • Ubuntu 中的 APT 和 dpkg 有什么区别? apt-get update 和 upgrade 的区别

    Debian系的Linux发行版的两种包管理工具:apt (Advanced Packaging Tools) 高级包管理工具(install安装,remove移除)dpkg Debian package,直接操作下载好的软件包文件(-i安装,-r移除)。 apt update:只检查,不更新(已安装的软件包是否有可用的更新,给出汇总报告)用法: apt update apt upgrade:更新已安装的软件包用法: apt upgrade 软件包名 关系:apt是基于dpkg的。APT 和dpkg都是命令行包管理界面,APT 使用 dpkg 安装包,当 APT(或其表亲 Apt-get)安装软件包时,它实际上是在后端使用 dpkg 来完成该操作。通过这种方式,dpkg 更像是 APT 更友好的用户界面的“幕后”工具。APT会自动检查并获取相关的依赖项,以确保您尝试正确安装任何功能。这就是为什么我们建议在使用 dpkg 安装软件包后,您仍然使用 APT 的特殊命令来恢复依赖项:sudo apt install -f 使用语法 Apt:apt install ./discord-0.0.14.deb使用语法 Dpkg:dpkg -i ./discord-0.0.14.deb APT可以下载包,可以从远程存储库中检索文件并安装它。dpkg,只能安装自己已经下载的本地文件。它无法搜索远程存储库或从中提取包。dpkg 不会安装依赖,只简单地安装软件包。 apt 列出已安装的软件 apt list –installed安装 apt-get install xxx卸载 apt-get remove xxx…

  • ubuntu vnc 灰屏和鼠标xx的问题

    ubuntu vnc 灰屏和鼠标xx的问题

    网上好多解决办法都是改配置文件,到头来还是google出来解决问题,地址: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-14-04 详细: Since we are going to be changing how our VNC servers are configured, we’ll need to first stop the VNC server instance that is running on port 5901: 杀掉目前到vnc进程: vncserver -kill :1 Before we begin configuring our new xstartup file, let’s back up the original in case we need it later: 备份:…