《运维》三、git、php环境配置、服务(运维3)

本文详细介绍了在Linux环境下安装和配置Git版本控制系统、升级PHP版本至5.6及配置ThinkPHP运行环境的步骤。包括Git的安装、SSH Key的生成与配置、PHP环境的更新与扩展安装、ThinkPHP的pathinfo开启、Nginx配置以及HTTPS设置等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

《一》、git安装和使用
  • 1、 安装
    sudo yum install git

  • 2、生成SSH KEY
    ssh-keygen 生成公钥和私钥,

  • 3、访问码云(https://gitee.com),配置SSH Key
    cat id_rsa.pub 复制公钥内容到SSH公钥配置中

  • 4、基本命令

  • 5、
    推荐学习Git基本命令网址:http://www.runoob.com/git/git-tutorial.html

《二》、php环境配置
  • 1:默认版本太低(5.4) 升级php 到5.6
    • 1.1.检查当前安装的PHP包
      yum list installed | grep php
    • 1.2如果有安装的PHP包,先删除他们
      yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
  • 2 : 配置源
    sudo rpm -Uvh http://mirror.webtatic.com/yum/el7/epel-release.rpm
    sudo rpm -Uvh http://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    

如果想删除上面安装的包,重新安装
rpm -qa | grep webstatic rpm -e 上面搜索到的包即可

  • 3:fpm 安装 和 基本操作
    sudo yum install php72w-fpm( 也可以php57w-fpm  php72w-fpm  )
    service php72w-fpm start/restart/stop
    
    ps -ef | grep fpm     // 查看
    
    // 直接执行,不按具体版本
    systemctl restart php-fpm
    
    • 4、安装基础扩展
    sudo yum install php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64
    
《三》、thinkphp环境配置
  • 1、开启pathinfo
    a、打开vi /etc/php.ini
    b、开启 , 往php.ini 中添加 cgi.fix_pathinfo=1
  • 2、配置nginx
    a、找一个新的域名,或者域名中新建一个二级域名:api.xyz.com
    b、在/etc/nginx/conf.d 中新建一个conf配置api.conf,内容如下:
       server {
          listen 80;
          server_name api.xyz.com;
          root /data/www/tp/public;
          
          index index.php index.html index.htm;
          access_log /var/log/nginx/access_tp5.log main;
    
         location / {
                 try_files $uri $uri/ /index.php?$args;
         }
    
         location ~ \.php$ {
                 fastcgi_pass 127.0.0.1:9000;
                 fastcgi_param PATH_INFO $fastcgi_path_info;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 include fastcgi_params;
                 try_files $uri =404;
          }
    
    }
    // 或者
    server {
    	listen 80;
    	server_name api.abc.com;
        root /data/www/tp/public;
    	index index.php index.html index.htm;
    	
    	add_header X-Powered-Host $hostname;
    	fastcgi_hide_header X-Powered-By;
    	
    	if (!-e $request_filename) {
    		rewrite  ^/(.+?\.php)/?(.*)$  /$1/$2  last;
    		rewrite  ^/(.*)$  /index.php/$1  last;
    	}
    	
    	location ~ \.php($|/){
    		fastcgi_index   index.php;
    		fastcgi_pass    127.0.0.1:9000;
    		include         fastcgi_params;
    		set $real_script_name $fastcgi_script_name;
    		if ($real_script_name ~ "^(.+?\.php)(/.+)$") {
    			set $real_script_name $1;
    		}
    		fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    		fastcgi_param   PATH_INFO               $fastcgi_path_info;
    		fastcgi_param   SCRIPT_NAME             $real_script_name;
    		fastcgi_param   SCRIPT_FILENAME         $document_root$real_script_name;
    		fastcgi_param   PHP_VALUE               open_basedir=$document_root:/tmp/:/proc/;
    		access_log      /home/wwwlog/domain_access.log    access;
    		error_log       /home/wwwlog/domain_error.log     error;
    	}
    	
    	location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
    		access_log  off;
    		error_log   off;
    		expires     30d;
    	}
    	
    	location ~ .*\.(js|css)?$ {
    		access_log   off;
    		error_log    off;
    		expires      12h;
    	}
    }
    
  • 3、重启php-fpmnginx服务
    systemctl restart nginx.service
    systemctl restart php-fpm.service
    

如果出错,可以用如下命令查看报错日志:systemctl status nginx.service -l

===> 腾讯云Nginx配置HTTPS
SSL证书管理->申请、下载证书,放到云服务器abc文件夹下

server {
        listen 443;
        server_name www.xyz.com;

        root /data/www/tp/public;
        index index.php index.html index.htm;

        access_log /var/log/nginx/access_it.log main;

        ssl on;
        ssl_certificate /abc/1_www.xyz.com_bundle.crt;
        ssl_certificate_key /abc/2_www.xyz.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;

...
...
《四》、服务
一、crontab定时任务
二、Logrotate日志切割

https://www.cnblogs.com/cainiaoliu/p/6259640.html

三、Ntpdate时间同步
  • 1、yum install ntp
  • 2、继续在命令行中操作,进行同步时间
    ntpdate 111.11.111.11
四、supervisor进程管理
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值