1. 登陆,升级应用,查询和关闭selinux

    yum update
    getenforce
    setenforce 0
    vi /etc/selinux
  2. 添加非root用户
    adduser deploy
    passwd deploy
    usermod -a -G wheel deploy
    vi /etc/sudoers
    %wheel ALL=(ALL) ALL
  3. ssh配置
    ssh deploy@123.456.78.90
    ssh-keygen
    mkdir ~/.ssh
    scp ~/.ssh/id_rsa.pub deploy@123.456.78.90:
    touch ~/.ssh/authorized_keys
    cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
    chown -R deploy:deploy ~/.ssh
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
  4. 禁止密码与root登陆,先确定sudo权限,打开 /etc/ssh/sshd_config,修改 PasswordAuthentication 的值为 no,取消注释。修改PermitRootLogin同上。重启SSHD。
    service sshd restart
  5. PHP、PHP-FPM 安装
    sudo rpm -Uvh  http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm;  
    //32位地址 http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm; sudo yum -y --enablerepo=epel,remi,remi-php56 install php-fpm php-cli php-gd php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-devel;
  6. PHP-FPM配置
    sudo vi /etc/php-fpm.conf
    //修改以下两处,1分钟内子进程失败达到10个就优雅重启
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m

    在配置文件中有 include=/etc/php-fpm.d/*.conf   , 表示池定义 pool definition 在php-fpm.d目录下

    vi /etc/php-fpm.d/www.conf
    //修改用户,尽量每个网站一个用户
    user = deploy
    group = deploy
    //与nginx请求处理的端口
    listen = 127.0.0.1:9000
    //服务器内存除以进程占用内存
    pm.max_children = 50
    //开启服务时自动开启的准备进程数
    pm.start_servers = 3
    //每个池的最大进程数
    pm.max_requests = 1000
    //慢日志
    slowlog = /path/to/slowlog.log
    request_slowlog_timeout = 5s
    //最后重启服务
    sudo service php-fpm restart
    chkconfig php-fpm on
  7. 安装nginx
    sudo yum install nginx;
    sudo systemctl enable nginx.service;
    sudo systemctl start nginx.service;
  8. 建立网站目录与日志目录
    mkdir -p /home/deploy/apps/example.com/current/public
    mkdir -p /home/deploy/apps/logs
    chmod -R +rx /home/deploy

    建立 /etc/nginx/conf.d/example.conf

  9. server
    {
    listen 80;
    server_name example.com;
    index index.php;
    client_max_body_size 50M;
    error_log /home/deploy/apps/logs/example.error.log;
    access_log /home/deploy/apps/logs/example.access.log;
    root /home/deploy/apps/example.com/current/public;
    location /
    {
    try_files $uri $uri/ /index.php$is_args$args;
    }
    location ~ \.php {
    try_files $uri=404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
    }
    }
  10. 重启
    sudo systemctl restart nginx.service
    sudo chkconfig nginx on
    //如果权限失败了, 以root权限启动
    sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  11. 检查防火墙,检查端口,检查selinux /getenforce ,最后可以编辑一个phpinfo页面放在网站根目录,在主机设置好hosts映射到虚拟机,终于可以在主机浏览器中输入虚拟机地址,见到php页面了。
  12. 多虚拟机参考http://www.androiddev.net/webserver-apache-to-nginx/
  13. 配置参考  http://huoding.com/2013/10/23/290
    server {
    listen 80;
    server_name foo.com; root /path;
    index index.html index.htm index.php; location / {
    try_files $uri $uri/ /index.php$is_args$args;
    } location ~ \.php$ {
    try_files $uri =404; include fastcgi.conf;
    fastcgi_pass 127.0.0.1:9000;
    }
    }
    fastcgi_pass unix:/dev/shm/php-fpm.sock;

服务器环境配置nginx / php / php-fpm(一)的更多相关文章

  1. laravel5.8笔记一:安装与服务器环境配置

    laravel版本:5.8 环境要求: PHP >= 7.1.3 OpenSSL PHP 扩展 PDO PHP 扩展 Mbstring PHP 扩展 Tokenizer PHP 扩展 XML P ...

  2. LNMP(linux+nginx+mysql+php)服务器环境配置【转载】

    本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/05/17/2507102.h ...

  3. [亲测]ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问

    前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...

  4. [亲测]七步学会ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问

    前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...

  5. ASP.NET Core 2.0发布/部署到Ubuntu服务器并配置Nginx反向代理

    原文链接https://www.linuxidc.com/Linux/2017-12/149557.htm ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用AS ...

  6. Ubuntu 下 Apache2 和 PHP 服务器环境配置

    Ubuntu 下 Apache2 和 PHP 服务器环境配置 1.简介 本文主要是 Ubuntu 下 Apache2 和 PHP 服务器环境配置方法,同样适用于 Debian 系统:Ubuntu 20 ...

  7. 零基础建站如何配置PHP运行环境 几种服务器环境配置的选择和方法

    上次给大家分享了小白建站如何选择虚拟空间及服务器,及购买域名的基础知识,这些是硬性要求,你的网站要想运行起来,硬件只是基础,真正的技术是软件,关于PHP软件开发技术,后面我们会慢慢的分享给大家,今天主 ...

  8. linux系统上安装svn服务器 环境linux+nginx+svnserver

    系统:Ubuntu 12.04 64位 lnmp环境 集成软件:PHP5.4.27.Nginx1.6.0.MySQL5.5.37 阿里云server svnserver有2种执行方式:独立server ...

  9. 超算云(GPU服务器)环境配置

    最近在用并行超算云GPU服务器(中国国家网格12区)搭建毕设的环境,这里记录一下. 首先,超算云服务器的登录可以采用网页版.也可以采用客户端(超算云地址:https://cloud.paratera. ...

随机推荐

  1. 真 · windows环境下php7.0以上开启curl方法

    看这个说明之前,大家肯定百度在网上看到什么: 配置php.ini ,把curl_dll前的分号去掉 在php.ini中,查找extension=php_curl.dll ,找到后把它前面的分号去掉 之 ...

  2. django 自定模板标签的注册

    首先注册方法一般都是先实例化一个template.Library.如: from django import template register = template.Library() 1.注册自定 ...

  3. python小项目练习之转换像素图片为字符图

    实例来源实验楼网站,没事可以多逛逛,在此多谢实验楼的无私分享 from PIL import Image import argparse """ description: ...

  4. hdu5009 Paint Pearls[指针优化dp]

    Paint Pearls Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  5. sonar-scanner扫描代码出错 SonarQube svn: E170001

    问题报错: Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication req ...

  6. Egret5.2.2 微信小游戏行的示例排行榜

    Egret5.2.2版本发布微信小游戏后,在开放数据域有一个默认排行榜.这个文件夹代码+图大小就22kb. 排行榜的效果就是示范用的,很丑...带翻页. 代码如下,基本就是使用canvas渲染了一个排 ...

  7. {Azure} 常用链接

    https://azure.microsoft.com/zh-cn/documentation/scenarios/web-app/

  8. undo文件丢失或损坏

    startup mount cp +DATA/ora11g/datafile/undotbs1.dbf alter database rename file '+DATA/ora11g/datafil ...

  9. AVG

    AVG([ DISTINCT | ALL ] expr) [ OVER(analytic_clause) ] SELECT MANAGER_ID,           LAST_NAME,       ...

  10. poj1934 Trip【线性DP】【输出方案】

    Trip Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3850   Accepted: 1030 Description ...