sudo passwd //设置当前用户密码直接使用: sudo passwd //好比设置alex用户密码: sudo passwd alex
//切换到root帐户能够直接使用命令: su 或者 su - 或者 su root //切换到普通用户: su 用户名 好比切换到alex帐户: su alex //使用 exit 直接退出到当前帐户
sudo apt-get update //源保存的文件为:/etc/apt/sources.list
sudo apt-get install openssh-server //查看状态: service ssh status/start/stop/restart //或:/etc/init.d/ssh status/start/stop/retsrt //实际上,service命令就是执行/etc/init.d脚本,两者功能是同样的
sudo apt-get install vim
sudo apt-get install tree
sudo apt-get install git
sudo apt-get install apache2
测试: 使用 ubuntu 系统自带火狐浏览器访问 http://ubuntu的IP,出现It Works!网页则算安装成功!php
查看 ubuntu 系统自身ip地址:html
ifconfig 或者 ifconfig -a
查看 Apache2 状态:mysql
service apache2 status/start/stop/restart
Web目录:linux
/var/www
安装目录:git
/etc/apache2/
全局配置:web
/etc/apache2/apache2.conf
监听端口:sql
/etc/apache2/ports.conf
虚拟主机:shell
/etc/apache2/sites-enabled/000-default.conf
sudo apt-get install mysql-server mysql-client
测试:mysql -u root -p数据库
查看 Mysql 状态:apache
service mysql status/start/stop/retart
查看监听端口的状况:
netstat -tunpl 或 netstat -tap
sudo apt-get install php7.0
测试: php -v
sudo apt-get install libapache2-mod-php7.0 sudo apt-get install php7.0-mysql
此时须要重启apache2和mysql :
service apache2 restart service mysql restart
测试 Apache可否解析 PHP
vim /var/www/html/phpinfo.php 文件中写: <?php echo phpinfo(); ?> 浏览器访问: http://ubuntu地址/phpinfo.php
sudo chmod 777 /var/www
sudo apt-get install phpmyadmin
安装:选择 apache2 ,点击肯定。下一步选这是要配置数据库,并输入密码。
建立phpMyAdmin快捷方式:
sudo ln -s /usr/share/phpmyadmin /var/www/html
启用Apache mod_rewrite模块:
sudo a2enmod rewrite
此时须要重启服务:
service php7.0-fpm restart service apache2 restart
测试:浏览器访问:http://ubuntu IP地址/phpmyadmin
使用 vim 编辑器打开 mysqld.cnf 配置文件 注释掉
43 # bind-address = 127.0.0.1
mysql> grant all privileges on *.* to alex@"%" identified by "qazwsx" with grant option; //grant 是受权命令,其中 alex 是咱们链接用的用户名、"qazwsx"是链接密码,用户名后面的 "%" 通用符表示容许各 host 操做。 // 在Mysql安装中,默认的有root用户,可是root用户的默认链接Host也是localhost或者127.0.0.1, // 也就是限制了root用户做为本地链接使用;我我的来讲,创建新帐户也是安全性和更加方便。 //下面是实操例子 // 链接数据库 mysql -u root -p mysql> show databases; // 查看 mysql 数据库 mysql> use mysql; // 查询 mysql 用户表能够发现 用户 alex 的 host 容许各类 host 操做 mysql> select host,user from user;
// 刷新权限(这一步必需要作!) mysql> flush privileges; // 刷新以后可再次查询 user 表
//具体相关方法请自行百度,这里只告诉建立共享文件夹目录为: /mnt/hgfs // 将本身 windows 上面的项目关联到共享文件夹
sudo vim /etc/apache2/apache2.conf
查找关键词 /Directory 找到这一行,将 /var/www 修改为本身项目文件==绝对路径==,好比个人文件目录在 /var/hgfs/www 并将 AllowOverride None 修改成 AllowOverride All
> <Directory /var/www> > Options Indexes FollowSymLinks > AllowOverride None > Require all granted > </Directory>
153 <Directory /> 154 Options FollowSymLinks 155 AllowOverride None 156 Require all denied 157 </Directory> 158 159 <Directory /usr/share> 160 AllowOverride None 161 Require all granted 162 </Directory> 163 //修改下面这一行 164 <Directory /mnt/hgfs/www> 165 Options Indexes FollowSymLinks 166 AllowOverride All 167 Require all granted 168 </Directory> 169 170 #<Directory /srv/> 171 # Options Indexes FollowSymLinks 172 # AllowOverride None 173 # Require all granted 174 #</Directory>
(其实可修改可不修改,本身测试没有修改也能够,但仍是建议修改)
sudo vim /etc/apache2/sites-enabled/000-default.conf
查找关键字 /DocumentRoot 找到这一行,将 /var/www 修改为本身项目文件==绝对路径==,好比个人文件目录在 /var/hgfs/www
ServerAdmin webmaster@localhost
DocumentRoot /var/www
//本人配置文件以下 11 ServerAdmin webmaster@localhost 12 DocumentRoot /mnt/hgfs/www
sudo vim /etc/apache2/sites-available/cake.conf // 我这个项目设置的配置文件是cake.conf // 若是还有其余项目均可以按照本身喜欢来写配置文件的名称
配置文件以下:
<VirtualHost *:80> ServerName demo.alex.com //项目域名 ServerAlias test.alex.com //这个能够没有 DocumentRoot /superdata/www/html/demo.alex.com //项目根目录 ErrorLog "/var/log/apache2/error_log" CustomLog "/var/log/apache2/access_log" common <Directory "/superdata/www/html/demo.alex.com"> //项目根目录 Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
本人项目配置文件以下:(配置文件中必定不能含有中文,否则重启 apache 会失败!)
<VirtualHost *:80> ServerName cake.ubuntu.com DocumentRoot /mnt/hgfs/www/tp ErrorLog "/var/log/apache2/cake.ubuntu.com_error_log" CustomLog "/var/log/apache2/cake.ubuntu.com_access_log" common <Directory "/mnt/hgfs/www/tp"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
sudo ln -s /etc/apache2/sites-available/cake.conf /etc/apache2/sites-enabled/cake.conf
sudo /etc/init.d/apache2 restart 或者 sudo service apache2 restart
// hosts 文件目录 C:\Windows\System32\drivers\etc\hosts // 添加内容为: ubuntu的IP地址 本身的项目域名,好比个人本地添加为: 192.168.137.135 cake.ubuntu.com
VMware虚拟机安装ubuntu系统能够参考:https://blog.csdn.net/iqmae68024/article/details/54772918
ubuntu16.04 搭建 LAMP 开发环境:https://www.linuxidc.com/Linux/2016-10/136327.htm
宿主机 Navicat 链接VMware Ubuntu 虚拟机 的MySQL 实现方法:https://blog.csdn.net/qq_34256348/article/details/78358678
使用Navicat for Mysql链接装在虚拟机Ubuntu16.04上的mysql服务器 https://blog.csdn.net/w410589502/article/details/51767212
Apache2.4项目配置PHP/TP项目方法 https://my.oschina.net/laifuzi/blog/850252