zoukankan      html  css  js  c++  java
  • day43 LNMP单机环境安装

    第1章 LNMP单机环境安装

    1.Nginx安装

    groupadd www -g 1000
    useradd www -s /sbin/nologin -M -u 1000 -g 1000
    id www
    cat > /etc/yum.repos.d/nginx.repo << 'EOF'
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
    EOF
    yum makecache
    yum install nginx -y
    rm -rf /etc/nginx/conf.d/default.conf
    systemctl start nginx
    systemctl enable nginx
    sed -i '/^user/c user  www;' /etc/nginx/nginx.conf
    

    2.PHP安装

    cat > /etc/yum.repos.d/php74.repo << 'EOF'
    [remi-php74]
    name=Remi's PHP 7.4 RPM repository for Enterprise Linux 7 - $basearch
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php74/$basearch/
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
    
    [remi-safe]
    name=Safe Remi's RPM repository for Enterprise Linux 7 - $basearch
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/safe/$basearch/
    enabled=1
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
    EOF
    yum makecache
    yum install -y php php-fpm php-cli php-gd php-mysqlnd php-pdo php-mcrypt php-xml php-opcache php-pecl-redis5
    sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf
    sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf
    systemctl start php-fpm
    systemctl enable php-fpm
    
    

    3.MySQL安装配置

    yum install mariadb-server mariadb -y
    systemctl start mariadb
    systemctl enable mariadb
    

    4.检查

    ps -ef|egrep "nginx|php|mysql"
    

    02-mysql光速入门

    mysql基础命令:
    1.设置密码
    mysqladmin password

    2.使用账号密码连接
    mysql -uroot -p123

    3.查看数据库

    > show databases;
    

    4.切换到数据库里

    > use mysql;
    

    5.查看库里面有哪些表

    > show tables;
    

    6.查询当前数据库有哪些用户

    > select user,host from mysql.user;
      查询   字段      从   库.表;
    
    MariaDB [(none)]> select user,host from mysql.user;
    +------+-----------+
    | user | host      |
    +------+-----------+
    | root | 127.0.0.1 |
    | root | ::1       |
    |      | localhost |
    | root | localhost |
    |      | web-7     |
    | root | web-7     |
    +------+-----------+
    

    7.退出登录

    > exit
    

    03-LNMP调试

    第1章 Nginx和PHP调试

    1.配置nginx

    cat > /etc/nginx/conf.d/php.conf << 'EOF'
    server {
        server_name www.oldboy.com;
        listen 80;
        root /code;
        index index.php index.html;
    
        location ~ \.php$ {
            root /code;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    EOF
    nginx -t
    systemctl restart nginx
    

    2.创建php测试文件

    mkdir /code -p
    cat > /code/info.php << 'EOF'
    <?php
        phpinfo();
    ?>
    EOF
    chown -R www:www /code/
    

    3.访问测试

    http://www.oldboy.com/info.php
    

    第2章 nginx+php+mysql测试

    1.创建php测试文件

    cat > /code/mysql.php << 'EOF'
    <?php
        $servername = "localhost";
        $username = "root";
        $password = "123";
    
        // 创建连接
        $conn = mysqli_connect($servername, $username, $password);
        
        // // 检测连接
        if (!$conn) {
            die("Connection failed: " . mysqli_connect_error());
        }
        echo "php 连接 MySQL 数据库成功";
    ?>
    EOF
    
    

    2.访问测试

    http://www.oldboy.com/mysql.php
    

    04-部署博客wordpress

    第1章 部署博客Wordpress

    1.nginx配置

    rm -rf /etc/nginx/conf.d/*
    cat > /etc/nginx/conf.d/wordpress.conf << 'EOF'
    server {
        listen 80;
        server_name blog.oldboy.com;
        root /code/wordpress;
        index index.php index.html;
    
        location ~ \.php$ {
            root /code/wordpress;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    EOF
    nginx -t
    systemctl restart nginx
    

    2.下载解压wordpress到代码目录

    rm -rf /code/
    mkdir -p /code
    cd /code/
    wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
    tar xf wordpress-4.9.4-zh_CN.tar.gz 
    chown -R www:www /code/
    

    3.创建数据库

    mysql -uroot -p123 -e 'create database wordpress;'
    mysql -uroot -p123 -e 'show databases;'
    

    4.测试访问

    blog.oldboy.com
    

    05部署问答系统wecenter

    1.nginx配置

    cat > /etc/nginx/conf.d/zh.conf << 'EOF'
    server {
        listen 80;
        server_name what.oldboy.com;
        root /code/zh;
        index index.php index.html;
    
        location ~ \.php$ {
            root /code/zh;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    EOF
    nginx -t
    systemctl restart nginx
    

    2.下载解压wordpress到代码目录

    cd /code/
    mkdir zh
    cd zh
    lz 
    unzip WeCenter_3-6-0.zip
    chown -R www:www /code/
    

    3.创建数据库

    mysql -uroot -p123 -e 'create database zh;'
    mysql -uroot -p123 -e 'show databases;'
    

    4.删除与微博接口通信代码

    sed -i '126,137d' /code/what/install/index.php
    

    4.测试访问

    zh.oldboy.com
    
  • 相关阅读:
    Oracle、Microsoft SQL Server、Mysql
    判断窗口是否最大化或者最小化
    获得桌面长宽
    Cmap的使用
    获取本地IP,并设置到IP控件
    定时器
    %
    ThinkPHP3.2.3 的异常和错误屏蔽处理
    大数据助银行提高征信水平和风险监控能力
    大数据助银行提高征信水平和风险监控能力
  • 原文地址:https://www.cnblogs.com/zhaocheng690/p/15609906.html
Copyright © 2011-2022 走看看