一站部署腾讯云

一、注册腾讯云不用说。javascript

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

三、先说明我是采起linux云服务器再用nginx+php+mysqlhtml

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

五、查看你云服务器的公网ip地址,端口默认的22就能够了,帐号root,密码是你本身设的(提示一下输入密码时是不会显示的,输入完直接回车就能够了)node

六、登陆成功后,安装nginx,按y安装mysql

yum install nginx

七、而后简单的测试一下linux

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

八、接着就是安装php5.6(若有须要安装其余版本再另说)nginx

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

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  

九、回到咱们的ng简单的改一下ng的配置,修改配置用linux修改略麻烦因此建议先下载Filezilla,由于之后传东西也是用Filezilla,下载地址:https://www.filezilla.cn/download/client

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

十一、找到你的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 {
#        }
#    }

}

十二、修改完成重启ng

service nginx restart

1三、到如今的话就已经能够直接用公网来登陆你的网站了,文件放在指定的

/usr/share/nginx/html

1四、接着腾讯云的数据库连接的方式有两种,一种是公网一种是内网,内网的话只要是同一个项目就能够用,更加的快。公网的话均可以使用,点击数据库查看公网网址以及内网的ip便可,公网的帐号只能是【cdb_outerroot】,而内网的帐号是【root】,密码你本身设定,php连接大体就是

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

1五、域名解析你的ip地址,进入域名解析,点新手快速设置,点网站连接ip就能够了,到此输入域名就能够登上你的ip地址了

1六、最后还能够加上https,申请免费的证书,而后输入你的域名,再把证书下载下来放到和ng配置的同一文件下,再配置文件里输入两个证书的名字,以及你的域名的名字,这样就能够https了,若是不须要的话配置那一块能够屏蔽掉。而后再重启ng就行了

相关文章
相关标签/搜索