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
只显示用户名及当前所在的目录