• 一站部署腾讯云


    1、注册腾讯云不用说。

    2、再说说需要买的东西,一个服务器一个腾讯云mysql一个域名,所有这些挑最便宜的买的话,大概这些下来应该不到六七十这样子(我都是打折购买的:域名一年6元,服务器19元一个月,mysql50元一个月,服务器选择CentOS 7.0以上)

    3、先说明我是采取linux云服务器再用nginx+php+mysql

    4、先下载远程链接软件Putty:http://www.chiark.greenend.org.uk/~sgtatham/putty/

    5、查看你云服务器的公网ip地址,端口默认的22就可以了,账号root,密码是你自己设的(提示一下输入密码时是不会显示的,输入完直接回车就可以了)

    6、登录成功后,安装nginx,按y安装

    yum install nginx
    

    7、然后简单的测试一下

    service nginx start        //启动服务器
    wget http://127.0.0.1  //测试服务器
    

    8、接着就是安装php5.6(如有需要安装其他版本再另说)

    (1)检查当前安装的PHP包

    yum list installed | grep php 
    

    (2)如果有安装的PHP包,先删除他们

    yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
    

    (3)配置yum源

    yum install epel-release
    rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    

    (4)查看可以安装的包

    yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
    

    (5)yum配置完毕可以安装php了

    yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof
    

    (6)可以查看php的版本看看是否安装成功

    php -v
    

    (7)最后再安装php-fpm 

    yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm  
    

    9、回到我们的ng简单的改一下ng的配置,修改配置用linux修改略麻烦所以建议先下载Filezilla,因为以后传东西也是用Filezilla,下载地址:https://www.filezilla.cn/download/client

    10、点击【文件】-【站点管理器】,点击【新站点】按钮,输入以下内容你的公网ip端口也是22下面协议选择【sftp】,登录类型选择【正常】下面也是输入你的账号root和你的密码

    11、找到你的ng的配置文件,在/etc/nginx/nginx.conf。我的配置文件如下,主要的修改内容都在server,80是http,443https(https需要证书)

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
    
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
    
        server {
    	  listen       80;
    	  root   /usr/share/nginx/html;
    	  server_name  localhost;
    
    	  #charset koi8-r;
    	  #access_log  /var/log/nginx/log/host.access.log  main;
    
    	  location / {
    	      index  index.html index.htm;
    	  }
    
    	  #error_page  404              /404.html;
    
    	  # redirect server error pages to the static page /50x.html
    	  #
    	  error_page   500 502 503 504  /50x.html;
    	  location = /50x.html {
    	      root   /usr/share/nginx/html;
    	  }
    
    	  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    	  #
    	  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;
    	  }
    
        }
    
    # Settings for a TLS enabled server.
    #
        server {
            listen 443;
            server_name  #填写绑定证书的域名
            ssl on;
            ssl_certificate  #绑定的证书
            ssl_certificate_key #绑定的证书
            ssl_session_timeout 5m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
            ssl_prefer_server_ciphers on;
            location / {
                root   html; #站点目录
                index  index.html index.htm;
            }
    	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 #
    	  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;
    	  }
        }
    #    server {
    #        listen       443 ssl http2 default_server;
    #        listen       [::]:443 ssl http2 default_server;
    #        server_name  _;
    #        root         /usr/share/nginx/html;
    #
    #        ssl_certificate "/etc/pki/nginx/server.crt";
    #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
    #        ssl_session_cache shared:SSL:1m;
    #        ssl_session_timeout  10m;
    #        ssl_ciphers HIGH:!aNULL:!MD5;
    #        ssl_prefer_server_ciphers on;
    #
    #        # Load configuration files for the default server block.
    #        include /etc/nginx/default.d/*.conf;
    #
    #        location / {
    #        }
    #
    #        error_page 404 /404.html;
    #            location = /40x.html {
    #        }
    #
    #        error_page 500 502 503 504 /50x.html;
    #            location = /50x.html {
    #        }
    #    }
    
    }
    

    12、修改完成重启ng

    service nginx restart
    

    13、到现在的话就已经可以直接用公网来登录你的网站了,文件放在指定的

    /usr/share/nginx/html
    

    14、接着腾讯云的数据库链接的方式有两种,一种是公网一种是内网,内网的话只要是同一个项目就可以用,更加的快。公网的话都可以使用,点击数据库查看公网网址以及内网的ip即可,公网的账号只能是【cdb_outerroot】,而内网的账号是【root】,密码你自己设定,php链接大致就是

    $conn =@mysqli_connect("***.gz.cdb.myqcloud.com:***","cdb_outerroot","***","test");  //公网
    
    $conn =@mysqli_connect("***:***","root","***","test");       //内网

    15、域名解析你的ip地址,进入域名解析,点新手快速设置,点网站链接ip就可以了,到此输入域名就可以登上你的ip地址了

    16、最后还可以加上https,申请免费的证书,然后输入你的域名,再把证书下载下来放到和ng配置的同一文件下,再配置文件里输入两个证书的名字,以及你的域名的名字,这样就可以https了,如果不需要的话配置那一块可以屏蔽掉。然后再重启ng就好了

  • 相关阅读:
    【zzuli-2276】跳一跳
    哈夫曼编码
    【zzuli-2266】number(二进制处理)
    【51nod-1042】数字0-9的数量
    【51nod-1009】数字1的数量
    数据库第八次实验
    【zzuli-1923】表达式求值
    vue组件父子组件传递引用类型数据
    JS中的call()方法和apply()方法用法总结
    Object.assign()与深拷贝(一)
  • 原文地址:https://www.cnblogs.com/huangqiming/p/6802217.html
Copyright © 2020-2023  润新知