一站部署騰訊雲

一、註冊騰訊雲不用說。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就行了

相關文章
相關標籤/搜索