Ninvfeng Blog

记录web开发中的所见所得

centos7 安装lnmp环境

centos7 折腾记录

  • 设置代理修改 /etc/profile 文件,添加下面内容:

    http_proxy=http://192.168.33.1:1080
    https_proxy=http://192.168.33.1:1080
    export http_proxy
    export https_proxy

  • 给 yum 也设置代理,修改 /etc/yum.conf 文件,添加以下代码:

    proxy=http://192.168.33.1:1080/

  • 安装依赖与常用工具
    yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel gcc autoconf automake epel-release vim wget python-devel
  • yum安装php7.2

    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    yum update
    yum -y install php72w-devel php72w-fpm php72w-pear php72w-pdo php72w-pdo_mysql php72w-opcache php72w-common php72w-cli php72w-gd php72w-mbstring php72w-xml php72w-xmlrpc php72w-imap php72w-interbase
    pecl install yaf
    echo ";more extension" >> /etc/php.ini
    echo "extension=yaf.so" >> /etc/php.ini
    pecl install mongodb
    echo "extension=mongodb.so" >> /etc/php.ini
    pecl install redis
    echo "extension=redis.so" >> /etc/php.ini
    pecl install swoole
    echo "extension=swoole.so" >> /etc/php.ini

  • 如果想仅下载安装包可使用 --downloadonly --downloaddir=/data/rpm 参数

    yum install php71w-devel php71w-fpm --downloadonly --downloaddir=/data/rpm

  • yum 安装 nginx

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    yum install -y nginx

  • yum 安装mysql

    rpm -Uvh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
    yum install mysql-server mysql mysql-devel

  • 查看安装密码

    grep 'temporary password' /var/log/mysqld.log
    mysqlP@ssw0rd

  • 安装mongodb

    新建文件 /etc/yum.repos.d/mongodb-org-3.4.repo
    [mongodb-org-3.4]
    name=MongoDB 3.4 Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
    gpgcheck=0
    enabled=1

    yum install -y mongodb-org

  • yum 安装redis

    yum install -y redis

  • 安装完毕,启动服务并设置开机启动

    systemctl start php-fpm
    systemctl start mysqld
    systemctl start redis
    systemctl start mongod
    systemctl start nginx

    systemctl enable php-fpm
    systemctl enable mysqld
    systemctl enable redis
    systemctl enable mongod
    systemctl enable nginx

  • nginx 添加vhost

    server {

    listen 80;
    server_name vagrant.d;
    root /data/www/public; 
    
    location / {
        index index.php index.html;
    }
    
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    
    if (!-e $request_filename) {
        rewrite ^/(.*) /index.php?$1 last;
    }

    }

  • 其他记录

    idea 激活服务器: http://39.108.107.41:41017

    查看进程pid
    ps -ef | grep "minecraft_server.1.11.2.jar" | grep -v grep | awk '{print $2}'

    结束进程
    kill ps -ef | grep "minecraft_server.1.11.2.jar" | grep -v grep | awk '{print $2}'

    当vagrant无法同步文件夹时
    vagrant plugin install vagrant-vbguest
    vagrant vbguest

    关闭SELinux
    编辑 /etc/selinux/config
    将SELINUX=enforcing改为SELINUX=disabled

    vagrant导出box
    vagrant package --base vagrant_default_1523427689397_56913 --output bgframework.box

文章评论已关闭!