找回密码
 立即注册

腾讯轻云CentOS 7 装机笔记

[复制链接]
69伙伴 发表于 2020-8-3 23:57:59 | 显示全部楼层 |阅读模式
参考最完版美笔记
http://www.wgpro.com/forum.php?mod=viewthread&tid=1827

(以下过时作废)

折腾了几天终对腾讯轻云有个大体的性能认知了。 香港轻云 24元。 线路不错 能跑满 3M 你懂的

除了你懂得外,在跑一个 php 和frp 内存就满了。
由于没有Swap 并不建议装mysql 当个服务器用。
用了 一年多阿里香港轻云,个人总结 。

轻云只适合用带宽,如果你跑网,还是frp 回自己的路由器 nas更好。
因为使用你懂得技能后,随时准备ban重建。
等次数多了,能快速重建才是王道。

腾讯轻云 没有镜像备份! 试配置非常不方便
实测完美步骤Centos 7
centos.png





1.安装你懂得+  Nginx+ws+tls
游客,如果您要查看本帖隐藏内容请回复


2.Nginx 安装好后, 在安装PHP 7.4版本。


一、添加EPEL和REMI存储库
运行以下命令以添加所需的存储库:

  1. sudo yum install epel-release
复制代码
  1. sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
复制代码
二、在CentOS 7上安装PHP 7.4版本
我们现在可以启用PHP 7.4 Remi存储库并在CentOS 7上安装PHP 7.4:


  1. sudo yum -y install yum-utils
复制代码
  1. yum repolist all |grep php
复制代码
  1. sudo yum-config-manager --enable remi-php74
复制代码
在CentOS 7上安装PHP 7.4 以及扩展:
  1. sudo yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
复制代码
当前的PHP版本应为7.4版,如下所示:
  1. php -v
复制代码
如果要查看启用的模块,请运行:
  1. php --modules
复制代码



三、配置php-fpm.d
1.建立一个fpm conf使用BT规则 如下

  1. mkdir -p /etc/nginx/conf/php/
复制代码
写入一个php-fpm conf
  1. cat > "/etc/nginx/conf/php/74.conf" <<-\EOF
  2. location ~ \.php(.*)$ {
  3.     try_files $uri =404;
  4.     fastcgi_pass   127.0.0.1:9000;
  5.         fastcgi_index  index.php;

  6.         set $real_script_name $fastcgi_script_name;
  7.         if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)[        DISCUZ_CODE_10        ]quot;) {
  8.                         set $real_script_name $1;
  9.                         set $path_info $2;
  10.          }
  11.         fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
  12.         fastcgi_param SCRIPT_NAME $real_script_name;
  13.         fastcgi_param PATH_INFO $path_info;

  14.         include        fastcgi_params;
  15. }

  16. EOF
复制代码

输入命令行后,在按下回车 就行了!

2.在自己的vhost_conf 中启动 php

  1. server {
  2.         listen       80;
  3.         server_name wgpro.com;
  4.         root   /home/wwwroot/wgpro.com/;
  5.       
  6.         location / {
  7.             index  index.html index.htm index.php;
  8.                 error_page 403 /403.html;  
  9.                 error_page 404 /404.html;
  10.                 error_page 502 /502.html;
  11.    
  12.     #PHP-INFO-START
  13.    include php/74.conf;
  14.    #PHP-INFO-END
复制代码

其中 配置末尾添加
include php/74.conf;
与宝塔规则一致,方便手动迁站。


四、优化php-fpm
由于默认启动太多为了空出更多内存给你懂得。所以需要调整到极致nano /etc/php-fpm.d/www.conf

pm = dynamic # 创建进程的方式,动态创建
pm.max_children = 6 # 最大进程数 ( 不能只看内存来创建,要看具体使用率,有时内存足够,进程数大多时,导致 CPU 频繁上下文切换,负载会很高 )
pm.start_servers = 1 # 初始进程数
pm.min_spare_servers = 1 # 最小空闲进程数
pm.max_spare_servers = 3 # 最大空闲进程数

启动
systemctl start php-fpm

停止
systemctl stop php-fpm

重启
systemctl restart php-fpm

优化Nginx
/etc/nginx/conf/nginx.conf
nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数 (如,2个四核的cpu计为8)。
worker_processes  1;






五、常用命令
启动nginx服务
systemctl start nginx.service

停止nginx服务
systemctl stop nginx.service

重新启动服务
systemctl restart nginx.service

重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)
systemctl reload nginx.service
测试配置
/etc/nginx/sbin/nginx -t
查看是否成功
ps -ef | grep nginx
80端口被占用了
netstat -ano | grep 80netstat -tunlp | grep 80
netstat -tunlp | grep 端口号
-t (tcp) 仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化为数字
-l 仅列出在Listen(监听)的服务状态
-p 显示建立相关链接的程序名


lsof
lsof(list open files)是一个列出当前系统打开文件的工具。
lsof 查看端口占用语法格式:
lsof -i:端口号


更多 lsof 的命令如下:

lsof -i:8080:查看8080端口占用
lsof abc.txt:显示开启文件abc.txt的进程
lsof -c abc:显示abc进程现在打开的文件
lsof -c -p 1234:列出进程号为1234的进程所打开的文件
lsof -g gid:显示归属gid的进程情况
lsof +d /usr/local/:显示目录下被进程开启的文件
lsof +D /usr/local/:同上,但是会搜索目录下的目录,时间较长
lsof -d 4:显示使用fd为4的进程
lsof -i -U:显示所有打开的端口和UNIX domain文件







mysql
启动
systemctl start mysqld
停止
systemctl stop mysqld
重启
systemctl restart mysqld




设置定时任务
crontab.png




安装
一般情况下crond、crontab是安装好的,这里主要提一下万一没有crontab你别想着直接用yum去安装crond或者crontab因为你会发现找不到包,其实定时任务的包是cronie。(这里因为我遇到了所以提一下)
  1. yum install -y cronie
复制代码


这样就行了
释放缓存  每天6点释放一次 是非常合理的
echo 3 > /proc/sys/vm/drop_caches



  1. 查看任务crontab -l
复制代码

编辑配置文件
  1. nano /var/spool/cron/
复制代码


crond常用命令
  1. systemctl start   crond         启动服务
  2. systemctl stop    crond         停止服务
  3. systemctl restart crond         重启服务
  4. systemctl reload  crond         重载配置文件
  5. systemctl status  crond         查看状态
复制代码

crontab常用命令
  1. crontab -u                 设定某个用户的cron服务
  2. crontab -l                显示crontab文件(显示已设置的定时任务)
  3. crontab -e                编辑crontab文件(编辑定时任务)
  4. crontab -r                删除crontab文件(删除定时任务)
  5. crontab -i                删除crontab文件提醒用户(删除定时任务)
复制代码




开机启动
systemctl指令
  1. systemctl enable *.service #开机运行服务
  2. systemctl disable *.service #取消开机运行
  3. systemctl start *.service #启动服务
  4. systemctl stop *.service #停止服务
  5. systemctl restart *.service #重启服务
  6. systemctl reload *.service #重新加载服务配置文件
  7. systemctl status *.service #查询服务运行状态
  8. systemctl --failed #显示启动失败的服务
复制代码




临时交流 ⇨点我留言
【附件·直下】非必要·勿注册

网格·联系我们 ( 京ICP备16001788号|京公网安备 11010502049360号 ) | 网站地图 | 2012- WGPro.CoM |

GMT+8, 2024-4-20 14:45

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表