AWS-Ubuntu18.04-Web服务器环境

  1. 查看Ubuntu版本
    ubuntu@ip-172-31-36-119:~$ cat /proc/version

    Linux version 5.4.0-1029-aws (buildd@lcy01-amd64-021)  :linux内核版本号

    (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) :gcc编译器版本号

    #30~18.04.1-Ubuntu SMP Tue Oct 20 11:09:25 UTC 2020: Ubuntu版本号

  2. 创建www用户
    ubuntu@ip-172-31-36-119:~$ sudo useradd -m www -d /home/www -s /bin/bash
    ubuntu@ip-172-31-36-119:~$ sudo passwd www
    
    ubuntu@ip-172-31-36-119:~$ sudo chmod -v u+w /etc/sudoers
    ubuntu@ip-172-31-36-119:~$ sudo vim /etc/sudoers
    
    www ALL=(ALL) PASSWD:ALL
    
    ubuntu@ip-172-31-36-119:~$ sudo chmod -v u-w /etc/sudoers
    ubuntu@ip-172-31-36-119:~$ 
    

     

  3. 安装MySQL
    # 查看有没有安装MySQL:
    www@ip-172-31-36-119:~$ dpkg -l | grep mysql
    # 更新服务器上的包索引并安装默认包
    www@ip-172-31-36-119:~$ sudo apt-get update
    www@ip-172-31-36-119:~$ sudo apt install mysql-server
    # 检查mysql-server服务是否开启
    www@ip-172-31-36-119:~$ sudo netstat -tap | grep mysql
    # 初始化配置
    #(1)安装验证密码插件。
    
    #(2)设置root管理员在数据库中的专有密码。
    
    #(3)随后删除匿名账户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。
    
    #(4)删除默认的测试数据库,取消测试数据库的一系列访问权限。
    
    #(5)刷新授权列表,让初始化的设定立即生效。
    www@ip-172-31-36-119:~$ sudo mysql_secure_installation
    [sudo] password for www: 
    
    Securing the MySQL server deployment.
    
    Connecting to MySQL using a blank password.
    
    VALIDATE PASSWORD PLUGIN can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. 
    # 要安装验证密码插件吗?
    Would you like to setup VALIDATE PASSWORD plugin?
    
    Press y|Y for Yes, any other key for No: N
    # 请在这里设置root用户的密码。
    Please set the password for root here.
    
    New password: 
    
    Re-enter new password: 
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.
    # 删除匿名用户?
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    
    Normally, root should only be allowed to connect from
    'localhost'. This ensures that someone cannot guess at
    the root password from the network.
    # 禁止根用户远程登录?
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
    
     ... skipping.
    By default, MySQL comes with a database named 'test' that
    anyone can access. This is also intended only for testing,
    and should be removed before moving into a production
    environment.
    
    # 删除测试数据库并访问它?
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
     - Dropping test database...
    Success.
    
     - Removing privileges on test database...
    Success.
    
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.
    # 现在重新加载特权表?
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done! 
    
    # 查看mysql-server运行状态
    www@ip-172-31-36-119:~$ sudo systemctl status mysql
    
    # 设置mysql普通登陆账号
    www@ip-172-31-36-119:~$ sudo mysql -uroot -p
    mysql> CREATE USER 'prod'@'localhost' IDENTIFIED BY 'Prod123456,';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT INSERT,UPDATE, SELECT,DELETE ON *.* TO 'prod'@'localhost' identified by 'Prod123456,';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> CREATE USER 'lmy'@'%' IDENTIFIED BY 'Lmy123456,';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT INSERT,UPDATE, SELECT,DELETE,INDEX,CREATE,ALTER,DROP ON *.* TO 'lmy'@'%' identified by 'Lmy123456,' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> GRANT CREATE USER ON *.* TO 'lmy'@'%' identified by 'Lmy123456,' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> CREATE USER 'lg'@'%' IDENTIFIED BY 'Lg123456,';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT SELECT ON *.* TO 'lg'@'%' identified by 'Lg123456,';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> CREATE USER 'hyl'@'%' IDENTIFIED BY 'Hyl123456,';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> GRANT SELECT ON *.* TO 'hyl'@'%' identified by 'Hyl123456,';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> exit
    
    
    # 查看当前模式
    mysql> select @@global.sql_mode;
    
    # 修改mysql配置文件
    www@ip-172-31-36-119:/etc/mysql/mysql.conf.d$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
    
    # 聚合函数宽松模式
    sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    
    # 系统默认时区
    default-time-zone='+08:00' 
    
    # 重启mysql服务使配置文件生效
    www@ip-172-31-36-119:~$ sudo service mysql restart

     

  4. 修改系统时区
    www@ip-172-31-36-119:~$ sudo tzselect
    www@ip-172-31-36-119:~$ sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    www@ip-172-31-36-119:~$ date
    

     

  5. 修改JVM时区
    www@ip-172-31-36-119:~$ sudo dpkg-reconfigure tzdata

     

  6. 修改MySql时区
    # 查看当前MySQL的默认时区
    mysql> SELECT @@global.time_zone;
    +--------------------+
    | @@global.time_zone |
    +--------------------+
    | SYSTEM             |
    +--------------------+
    # 显示 SYSTEM 说明当前使用的是操作系统时区
    mysql> SELECT @@global.system_time_zone;
    +---------------------------+
    | @@global.system_time_zone |
    +---------------------------+
    | UTC                       |
    +---------------------------+
    # 系统时区用的是UTC。
    
    # 方案一
    # 修改配置文件
    default-time-zone='+08:00' 
    
    # 方案二
    # 仅限当前会话
    SET time_zone = "+08:00";
    
    #方案三
    # 查看mysql系统时间
    select now();
    # 设置时区更改为东八区
    set global time_zone = '+8:00';
    # 刷新权限
    flush privileges;

     

  7. 安装GIT
    # 安装GIT
    www@ip-172-31-36-119:~$ sudo apt install git
    # 配置GIT 用户名
    www@ip-172-31-36-119:~$ git config --global user.name crumb
    # 配置GIt 邮箱
    www@ip-172-31-36-119:~$ git config --global user.email open@limeyu.club
    # 生成密钥对
    www@ip-172-31-36-119:~$ ssh-keygen -t rsa -C open@limeyu.club
    # 复制公钥到Git服务器
    www@ip-172-31-36-119:~$ cat .ssh/id_rsa.pub
    

     

  8. 安装Maven
    www@ip-172-31-36-119:~$ sudo apt-get install maven

     

  9. 安装Redis
    # 安装Redis服务
    www@ip-172-31-36-119:~$ sudo apt-get install redis-server
    # 修改Redis配置文件
    www@ip-172-31-36-119:~$ sudo vim /etc/redis/redis.conf
    # 修改登陆密码
    requirepass
    

     

  10. 安装nginx
    www@ip-172-31-36-119:~$ sudo apt-get install nginx
    
    www@ip-172-31-36-119:~$ sudo vim /etc/hosts
    23.44.51.8 ocsp.int-x3.letsencrypt.org
    www@ip-172-31-36-119:~$ sudo vim /etc/nginx/nginx.conf
    user www;
    
        charset utf-8;
    
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
        # 启用OCSP订书机功能
        ssl_stapling on;
        ssl_stapling_verify on;
    
    
             #后端平台管理系统接口
            location ^~ /admin/api-v1/ {
                proxy_pass http://127.0.0.1:18080/admin/api-v1/;
            }
            #后端门店管理系统接口
            location ^~ /branch/api-v1/ {
                proxy_pass http://127.0.0.1:18081/branch/api-v1/;
            }
            #后端客户端app接口
            location ^~ /carowner/api-v1/ {
                proxy_pass http://127.0.0.1:18082/carowner/api-v1/;
            }
            #后端技师端app接口
            location ^~ /mechanic/api-v1/ {
                proxy_pass http://127.0.0.1:18083/mechanic/api-v1/;
            }
            #移动端h5页面
            location  /carapp/ {
                try_files $uri $uri/;
                root /home/www/src/das-front_en/;
                index /serve/serve-apply.html;
            }
            # 体验卡活动h5页面
            location  /wxh5/ {
                try_files $uri $uri/;
                root /home/www/src/das-front_en/;
                index /experienceCard/experience-card.html;
            }
    
            #动静分离,前端静态页面
            location / {
                try_files $uri $uri/ /index.html;
                root /home/www/src/www.bba.vip/dist/;
                index index.html;
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
    
    
            #车主端h5的后台接口请求
            location ^~ /carowner/api-v1/ {
                proxy_pass  http://127.0.0.1:18082/carowner/api-v1/;
            }
            #后端技师端app接口
            location ^~ /mechanic/api-v1/ {
                proxy_pass  http://127.0.0.1:18083/mechanic/api-v1/;
            }
            #移动端h5页面
            location / {
                try_files $uri $uri/ /index.html;
                root /home/www/src/das-front_en/;
                index index.html;
            }
    
    
    www@ip-172-31-36-119:~$ sudo nginx -t
    www@ip-172-31-36-119:~$ sudo systemctl start nginx.service
    www@ip-172-31-36-119:~$ sudo nginx -s reload
    www@ip-172-31-36-119:~$ systemctl status nginx.service
    www@ip-172-31-36-119:~$ 
    www@ip-172-31-36-119:~$ 
    www@ip-172-31-36-119:~$ sudo chown www -R /var/lib/nginx/

     

  11. 安装Java1.8
    # 卸载自带的OpenJDK
    www@ip-172-31-36-119:~$ sudo apt-get remove openjdk*
    # 安装JDK1.8
    www@ip-172-31-36-119:~$ sudo apt install openjdk-8-jdk

     

  12. 安装NodeJs
    www@ip-172-31-36-119:~$ sudo apt install nodejs
    www@ip-172-31-36-119:~$ sudo apt install npm

     

  13. 配置SSL
    www@ip-172-31-36-119:~$ sudo apt-get install python-certbot-nginx
    www@ip-172-31-36-119:~$ sudo certbot –-nginx

     

  14. 安装ZIP
    www@ip-172-31-23-156:~$ sudo apt install zip

     

  15. 上传element-ui.zip
    liangmydeMacBook-Pro:tw liangmy$ scp -i 'autox3-tw-key-pairs.pem' ~/Documents/kangxiaoli/element-ui.zip ubuntu@www.limeyu.club:~/element-ui.zip

     

  16. 修改文件拥有者
    www@ip-172-31-23-156:~/src/das-front_en/www.bba.vip/node_modules$ sudo chown www:www element-ui.zip 

     

  17. 啦啦啦
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值