• 云服务器搭建


    云服务器服务搭建


    安装服务

    yum install net-tools vim tree htop iftop gcc gcc-c++ glibc iotop lrzsz sl wget unzip telnet nmap nc psmisc dos2unix bash-completion bash-completion-extra sysstat rsync nfs-utils httpd-tools -y
    

    安装nginx服务和PHP服务

    #上传
    [root@daiyacheng ~/software]# ll
    total 20180
    -rw-r--r-- 1 root root 20663838 Aug 20 09:45 nginx_php.tar.gz
    
    #解压
    [root@daiyacheng ~/software]# tar xf nginx_php.tar.gz 
    [root@daiyacheng ~/software]# ll
    total 20184
    -rw-r--r-- 1 root root 20663838 Aug 20 09:45 nginx_php.tar.gz
    drwxr-xr-x 2 root root     4096 Aug 20 17:12 php
    
    #安装
    [root@daiyacheng ~]# yum localinstall *.rpm
    

    创建统一用户

    [root@daiyacheng ~]# groupadd www -g 666
    [root@daiyacheng ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
    [root@daiyacheng ~]# id www
    uid=666(www) gid=666(www) groups=666(www)
    

    更改 nginx和php的启动用户

    [root@daiyacheng ~]# vim /etc/nginx/nginx.conf 
    user  www;
    
    [root@daiyacheng ~]# vim /etc/php-fpm.d/www.conf 
    user = www
    group = www
    

    启动并加入开机自启

    [root@daiyacheng ~]# systemctl start nginx
    [root@daiyacheng ~]# systemctl enable nginx
    Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
    
    [root@daiyacheng ~]# systemctl start php-fpm
    [root@daiyacheng ~]# systemctl enable php-fpm
    Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
    

    查看端口,确认是否启动

    [root@daiyacheng ~]# netstat -lntup |grep nginx
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      16029/nginx: master 
    [root@daiyacheng ~]# netstat -lntup |grep php
    tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      16056/php-fpm: mast 
    

    测试nginx 与 php 是否通畅

    #编辑配置文件
    [root@daiyacheng /etc/nginx/conf.d]# vim /etc/nginx/conf.d/php.conf 
      
    server {
            listen 80;
            server_name _;
            root /code;
            index index.php index.html index.htm;
    
            location ~ .php$ {
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
            }
    }
    
    #检查启动
    [root@web01 /etc/nginx/conf.d]# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    [root@web01 /etc/nginx/conf.d]# nginx -s reload
    
    
    #根据配置文件创建目录
    [root@daiyacheng ~]# mkdir /code
    
    #编辑测试文件
    [root@daiyacheng /code]# vim index.php
    <?php
            phpinfo();
    ?>
    
    #授权
    [root@daiyacheng /code]# chown -R www.www /code/
    [root@daiyacheng /code]# ll /code/
    total 4
    -rw-r--r-- 1 www www 28 Nov 16 15:40 index.php
    

    安装数据库

    #安装
    yum install -y mariadb-server
    
    #启动并加入开机自启
    [root@daiyacheng ~]# systemctl start mariadb
    [root@daiyacheng ~]# systemctl enable mariadb
    Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
    
    #登录数据库并设置密码
    MariaDB [(none)]>
    MariaDB [(none)]> grant all on *.* to root@'%' identified by 'gjy123' with grant option;
    
    #创建数据库
    [root@daiyacheng ~]# mysql -uroot -pgjy123 -h47.101.218.170
    MariaDB [(none)]> create database wordpress;
    Query OK, 1 row affected (0.01 sec)
    
    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    | wordpress          |
    +--------------------+
    5 rows in set (0.01 sec)
    

    部署wordpress

    #上传软件包
    [root@daiyacheng /code]# rz -E
    rz waiting to receive.
    [root@daiyacheng /code]# ll
    total 10840
    -rw-r--r-- 1 root root 11098483 Aug 20 21:37 wordpress-5.0.3-zh_CN.tar.gz
    
    #解压
    [root@daiyacheng /code]# tar xf wordpress-5.0.3-zh_CN.tar.gz 
    [root@daiyacheng /code]# ll
    total 4
    drwxr-xr-x 5 1006 1006 4096 Jan 11  2019 wordpress
    
    #授权
    [root@daiyacheng /code]# chown -R www.www /code/
    [root@daiyacheng /code]# ll
    total 4
    drwxr-xr-x 5 www www 4096 Jan 11  2019 wordpress
    
    #编辑配置文件
    [root@daiyacheng /etc/nginx/conf.d]# vim wordpress.conf 
    server {
            listen 80;
            server_name _;
            root /code/wordpress;
            index index.php index.html index.htm;
    
            location ~ .php$ {
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
            }
    }
    
    #检查并平滑启动
    [root@daiyacheng /etc/nginx/conf.d]# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    [root@daiyacheng /etc/nginx/conf.d]# nginx -s reload
    

    浏览器创建流程

  • 相关阅读:
    Django组件之cookie与session
    广商14级软件工程分数:第五回合
    广商14级软件工程分数:第四回合
    Oracle Flashback和RMAN示例
    广商14级软件工程分数:第三回合
    广商14级软件工程分数:第二回合
    《学习进度条》博客
    广商14级软件工程分数:第一回合
    学生博客列表-广商14级软件工程
    源代码管理的一些问题
  • 原文地址:https://www.cnblogs.com/gongjingyun123--/p/12547802.html
Copyright © 2020-2023  润新知