首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >win10下配置linux子系统

win10下配置linux子系统

作者头像
章鱼喵
发布2018-06-27 15:15:25
2.2K0
发布2018-06-27 15:15:25
举报
文章被收录于专栏:codingcoding

ubuntu重新安装

cmd运行:lxrun

C:\Users\27202>lxrun
对 LX 子系统执行管理操作

用法:
    /install - 安装子系统
        可选参数:
            /y - 不提示用户接受或创建子系统用户
    /uninstall - 卸载子系统
        可选参数:
            /full - 执行完全卸载
            /y - 不提示用户确认
    /setdefaultuser - 配置将用于启动 bash 的子系统用户。如果该用户不存在,则会创建该用户。
        可选参数:
            username - 提供用户名
            /y - 如果提供了用户名,则不提示创建密码
    /update - 更新子系统的包索引

从windows应用商店下载ubuntu时,如果一直下载不了,可选择用手机热点下载,速度很快,总大小为230M左右

设置root用户密码

senlong@DESKTOP-T0249TH:~$ sudo passwd root
输入新的 UNIX 密码: 
重新输入新的 UNIX 密码: 
passwd: password updated successfully

查看版本

senlong@DESKTOP-T0249TH:~$ cat /etc/issue Ubuntu 16.04.2 LTS \n \l

senlong@DESKTOP-T0249TH:~$ sudo lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial

更换软件源

  • 备份原来的源文件
cd /etc/apt/  
sudo cp sources.list sources.list.bak 
  • 替换源
sudo vim sources.list
# 替换成以下的阿里云源
# deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
# deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
# deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
# deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
  • 更新源和软件
sudo apt-get update # 更新源  
sudo apt-get upgrade # 更新软件 

lamp环境

  • 安装Apache
sudo apt-get install apache2
sudo service apache2 start

测试: 浏览器访问localhost

查看状态: service apache2 status/start/stop/restart

Web目录: /var/www

安装目录: /etc/apache2/

全局配置: /etc/apache2/apache2.conf

监听端口: /etc/apache2/ports.conf

虚拟主机: /etc/apache2/sites-enabled/000-default.conf

  • 安装MySQL
sudo apt-get install mysql-server mysql-client

测试:mysql -u root -p 查看状态:service mysql status/start/stop/retart 查看监听端口的情况:netstat -tunpl 或 netstat -tap

  • 安装PHP
sudo apt-get install php7.0

测试:php7.0 -v

  • 安装其他模块
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql
  • 重启服务
service apache2 restart
service mysql restart
  • 配置虚拟主机

www.mine.com为例:

cp 000-default.conf www.mine.com.conf
vim www.mine.com.conf

www.mine.com.conf 写入以下内容

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName www.mine.com

        ServerAdmin webmaster@localhost
        DocumentRoot /mnt/e/root/mine

        <Directory /mnt/e/root/mine>
            Options FollowSymLinks
            AllowOverride All
            Order deny,allow
            Allow from all
            Require all granted
        </Directory>


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

建立软链接

ln -s /etc/apache2/sites-available/www.mine.com.conf ../sites-enabled/

重启apache

service apache2 restart
  • 开启apache重写url
sudo a2enmod rewrite

安装php扩展

sudo apt-get install php-mbstring
sudo apt-get install php7.0-curl

设置编码:解决中文乱码

sudo vim /etc/default/locale

添加以下内容

#  File generated by update-locale
LANG=zh_CN.UTF-8
LANGUAGE=”zh_CN:zh:en_US:en”

安装redis

senlong@DESKTOP-T0249TH:/etc/redis$ sudo apt-get install redis-server 
senlong@DESKTOP-T0249TH:/etc/redis$ sudo /etc/init.d/redis-server status
 * redis-server is not running
senlong@DESKTOP-T0249TH:/etc/redis$ sudo /etc/init.d/redis-server start
Starting redis-server: redis-server.
senlong@DESKTOP-T0249TH:/etc/redis$ sudo /etc/init.d/redis-server status
 * redis-server is running
senlong@DESKTOP-T0249TH:/etc/redis$ redis-cli
127.0.0.1:6379> 

启动sublime text

alias subl='"/mnt/c/Program Files/Sublime Text 3/subl.exe"'

命令行提示符

修改 ~/.bashrc

if [ "$color_prompt" = yes ]; then                                       
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:
[\033[01;34m\]\W\[\033[00m\]\$ '                                         
else                                                                     
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '                     
fi                                                                       

只显示用户名及当前所在的目录

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.05.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ubuntu重新安装
  • 设置root用户密码
  • 查看版本
  • 更换软件源
  • lamp环境
  • 安装php扩展
  • 设置编码:解决中文乱码
  • 安装redis
  • 启动sublime text
  • 命令行提示符
相关产品与服务
轻量应用服务器
轻量应用服务器(TencentCloud Lighthouse)是新一代开箱即用、面向轻量应用场景的云服务器产品,助力中小企业和开发者便捷高效的在云端构建网站、Web应用、小程序/小游戏、游戏服、电商应用、云盘/图床和开发测试环境,相比普通云服务器更加简单易用且更贴近应用,以套餐形式整体售卖云资源并提供高带宽流量包,将热门开源软件打包实现一键构建应用,提供极简上云体验。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档