ubuntu重新安裝
cmd運(yùn)行:lxrun
C:\Users\27202>lxrun
對 LX 子系統(tǒng)執(zhí)行管理操作
用法:
/install - 安裝子系統(tǒng)
可選參數(shù):
/y - 不提示用戶接受或創(chuàng)建子系統(tǒng)用戶
/uninstall - 卸載子系統(tǒng)
可選參數(shù):
/full - 執(zhí)行完全卸載
/y - 不提示用戶確認(rèn)
/setdefaultuser - 配置將用于啟動(dòng) bash 的子系統(tǒng)用戶晦款。如果該用戶不存在缓溅,則會(huì)創(chuàng)建該用戶赁温。
可選參數(shù):
username - 提供用戶名
/y - 如果提供了用戶名,則不提示創(chuàng)建密碼
/update - 更新子系統(tǒng)的包索引
從windows應(yīng)用商店下載ubuntu時(shí)袜匿,如果一直下載不了毁涉,可選擇用手機(jī)熱點(diǎn)下載,速度很快,總大小為230M左右
設(shè)置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環(huán)境
- 安裝Apache
sudo apt-get install apache2
sudo service apache2 start
測試: 瀏覽器訪問localhost
查看狀態(tài): service apache2 status/start/stop/restart
Web目錄: /var/www
安裝目錄: /etc/apache2/
全局配置: /etc/apache2/apache2.conf
監(jiān)聽端口: /etc/apache2/ports.conf
虛擬主機(jī): /etc/apache2/sites-enabled/000-default.conf
- 安裝MySQL
sudo apt-get install mysql-server mysql-client
測試:mysql -u root -p
查看狀態(tài):service mysql status/start/stop/retart
查看監(jiān)聽端口的情況: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
- 重啟服務(wù)
service apache2 restart
service mysql restart
- 配置虛擬主機(jī)
以www.mine.com
為例:
cp 000-default.conf www.mine.com.conf
vim www.mine.com.conf
www.mine.com.conf 寫入以下內(nèi)容
<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擴(kuò)展
sudo apt-get install php-mbstring
sudo apt-get install php7.0-curl
設(shè)置編碼:解決中文亂碼
sudo vim /etc/default/locale
添加以下內(nèi)容
# 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>
啟動(dòng)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
只顯示用戶名及當(dāng)前所在的目錄