卢纳黍的想疗院


一个不务正业,爱纹身、爱金属乐、玩乐队、专业写Bug的前端狗~


LNMP一键部署PHP / NGINX / MYSQL

下载并安装lnmp

以下为Demo,实际情况按需调整
wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp

# 4: Install MySQL 5.7.30
mysql passwd:v492p4!cK@CN
# Do you want to enable or disable the InnoDB Storage Engine?
  Default enable,Enter your choice [Y/n]:Y
# 9: Install PHP 7.3.23
# You have 3 options for your Memory Allocator install.
# 1: Don't install Memory Allocator. (Default)
# 2: Install Jemalloc
# 3: Install TCMalloc
  Enter your choice (1, 2 or 3): 1 

安装完成后基本配置信息

以下为Demo,实际情况按需调整
+------------------------------------------------------------------------+
|          LNMP V1.7 for CentOS Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|           For more information please visit https://lnmp.org           |
+------------------------------------------------------------------------+
|    lnmp status manage: lnmp {start|stop|reload|restart|kill|status}    |
+------------------------------------------------------------------------+
|  phpMyAdmin: http://IP/phpmyadmin/                                     |
|  phpinfo: http://IP/phpinfo.php                                        |
|  Prober:  http://IP/p.php                                              |
+------------------------------------------------------------------------+
|  Add VirtualHost: lnmp vhost add                                       |
+------------------------------------------------------------------------+
|  Default directory: /home/wwwroot/default                              |
+------------------------------------------------------------------------+
|  MySQL/MariaDB root password: v492p4!cK@CN                          |
+------------------------------------------------------------------------+
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
nginx (pid 15932) is running...
php-fpm is runing!
SUCCESS! MySQL running (16499)
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:80                       *:*                  
LISTEN     0      128          *:80                       *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      128       [::]:3306                  [::]:*                  
Install lnmp takes 40 minutes.

安装后调整

以下为Demo,实际情况按需调整
# DEMO

# 修改www用户权限
  vim /etc/passwd
  将www:/sbin/nologin改为/bin/bash
# 到项目目录
  cd /home/
  chown -R www:www wwwroot
  cd /home/wwwroot/
  su www
  chattr -i ./default/.user.ini
  rm -rf ./default
# 查看php.ini文件位置
  php -i | grep .ini
  /usr/local/php/etc/php.ini
# 修改php.ini
  cd /usr/local/php/etc/
  vim php.ini
  # 修改310行 disable_functions
  disable_functions = 去掉shell_exec,proc_open,proc_get_status 
  # 793行
  cgi.fix_pathinfo=0   改为cgi.fix_pathinfo=1
#重启PHP
  ps aux | grep php-fpm | grep master | grep -v grep
  kill -USR2 13225 
# vim fastcgi.conf 注释下面这一行
  cd /usr/local/nginx/conf/
  fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
# 修改sudoers配置文件,92行
  sudo vim /etc/sudoers
  nginx  ALL=(ALL:ALL) ALL
  www  ALL=(ALL:ALL) ALL
   

添加公钥

以下为Demo,实际情况按需调整
# 添加公钥到这个文件访问服务器权限
authorized_keys cat <your_key >>~/.ssh/authorized_keys
# ssh登录方法 
ssh -I 公钥名 root@地址 -p 端口号 
# 新建公钥
ssh-keygen -t rsa -C "备注信息"

# 进入项目目录
cd /home/wwwroot/default
# git 初始化 && 拉取代码
git init
git remote add origin git@e.coding.net:code-normcore/doTERRA_6th_anniversary_H5/doTERRA_2020_6y_h5_backend.git

# 拉取文件
git pull origin master && git checkout -b develop && git pull origin develop
# 预发环境
git pull origin master && git checkout -b pre-release && git pull origin pre-release
//查看当前分支命令:git branch 

授权项目文件

以下为Demo,实际情况按需调整
#  将项目文件夹授权给www 
chown -R www:www ./deafult/
# 报错 chown: changing ownership of ‘./wwwroot/default/.user.ini’: Operation not permitted
# 原因:带有i属性bai的文件是不能修改的。
[root@dt-6th-uat-app1 wwwroot]# lsattr ./default/.user.ini 
----i--------e-- ./default/.user.ini
# 文件去除i属性
[root@dt-6th-uat-app1 wwwroot]# chattr -i ./default/.user.ini 
建议打赏金额1-10元

支付宝打赏

微信打赏

最近的文章

常用的Git命令及特殊问题场景怎么解决

转载自:https://juejin.cn/post/6934487656873082887?utm_source=gold_browser_extension 前言 初衷: 记得刚入行时,Git…

git 继续阅读
更早的文章

Mac 实用工具

窗口篇(Window)SizeUpMoom触控条(Touch Bar)PockBetterTouchTool代理(Proxy)ShadowSocksXClashXFortiClient下载(Downl…

Mac, Tools 继续阅读
comments powered by Disqus