123

阿里云服务器nginx不用宝塔配置站点流程

2021-09-22 21:40 稿源:网畅天下  4296次访问

1. 首先一定要去阿里云平台找到对应服务器的安全配置规则,查看开放的端口,80330644322SSH  xshell登录 winscp登录等都需要)、21ftp

2. 目录说明
/bstdata  挂载数据盘的目录
/bstdata/ssl  证书所放地
/bstdata/rewrite  伪静态文件所放地
 ----thinkphphideadminphp.conf  thinkphp隐藏admin.php
/home/wwwlog  查看各站点日志
/usr/local/nginx/ 下列下面主要四个文件
   conf 存放配置文件

html 网页文件

logs 存放日志

sbin   shell启动、停止等脚本

3. 常用
cd /usr/local/nginx/conf/vhost  各个站点的配置文件所放地
 ----vi /usr/local/nginx/conf/vhost/zp.yxrcfw.com.conf

cd /usr/local/nginx/sbin 

4. 

创建数据库
1、以管理员身份登录mysql

mysql -u root -p

2、选择mysql数据库

use mysql

3、创建用户并设定密码

create user 'testuser'@'localhost' identified by 'testpassword'

4、使操作生效

flush privileges

5、为用户创建数据库

create database testdb

6、为用户赋予操作数据库testdb的所有权限

grant all privileges on testdb.* to test@localhost identified by '1234'

或者GRANT ALL PRIVILEGES ON cattle.* TO 'mmzx'@'%' WITH GRANT OPTION;

7、使操作生效

flush privileges

8、重启mysql
service mysql restart

参考网址https://blog.csdn.net/cyxinda/article/details/78254154

5. 配置站点 vhost
nginx默认站点 /usr/local/nginx/
方法一我们可以直接运行/usr/local/nginx/conf/nginx.conf文件进行编辑
方法二:一般我们都建议在/usr/local/nginx/conf/vhost/域名.conf   当然要首先在
/usr/local/nginx/conf/nginx.conf http增加配置include vhost/*.conf;
以下实例代码只做参考
 #全局区有一个工作子进程,一般设置为CPU* 核数
 worker_processes  1;   #一般设置为auto
        events {
  # 一般是配置nginx进程与连接的特性
  # 1word能同时允许多少连接,一个子进程最大允许连接1024个连接
  worker_connections  51200;
 }
 # 配置HTTP服务器配置段
   http {
  # 配置虚拟主机段
  server {
   #监听端口
   listen   80;
   #监听域名
   server_name  www.test.com;
   location / {
    #要访问站点的文件路径,可以是相对路径(相对于nginx的根路径),这里我写的是绝对路径
    #root   /var/wwwroot/site1;
    root   /var/wwwroot/site1/public;  #直指项目实际运行目录
    #默认跳转到的页面
    index  index.html index.htm index.php;
   }
  }
 }

6. 配置SSL证书
a.将申请的ssl证书(域名.key和域名.pem)上传服务器,放置/bstdata/ssl 
b./usr/local/nginx/conf/vhost/*.conf  增加server 以下实例代码只做参考
server
{
isten 443 ssl http2;
#listen [::]:443 ssl http2;
server_name zp.rj863.com n;
index index.html index.htm index.php default.html default.htm default.php;
root  /bstdata/wwwroot/zpyxrcfwcom/public;
ssl_certificate /bstdata/ssl/域名.pem;
ssl_certificate_key /bstdata/ssl/域名.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include /bstdata/rewrite/thinkphphideadminphp.conf;
#error_page   404   /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php-pathinfo.conf;

7. 查看端口 添加端口
可以使用iptables -L -n 或者 iptables-save 或者 netstat -anp
或者firewall-cmd --zone=public --list-ports查看端口

8. 修改目录权限
使用命令chmod

9. 修改目录所属用户及用户组
使用命令chown


有好的文章希望朋友们帮助分享推广,猛戳这里河洛伊哥

相关热点

查看更多