1.下载yii2
https://www.yiichina.com/download
2.将解压后的文件放在指定的位置,这里是/home/www/yii/
3.安装apache2
sudo apt-get iinstall apache2
3.启动和查看apache2
启动:
sudo /etc/init.d/apache2 start
查看:
ps -ef |grep "apache"
4.配置虚拟主机 www.feiquan.com
sudo touch /etc/apache2/sites-enabled/www.feiquan.com.conf
sudo vim/etc/apache2/sites-enabled/www.feiquan.com.conf
<virtualhost *:80> servername www.feiquan.com documentroot /home/www/yii/web <directory " /home/www/yii/web"> require all granted allow from all rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . index.php </directory> </virtualhost>
5.配置hosts文件(记得这里是hosts不是host)
ifconfig
得到ip地址 192.168.0.100
sudo vim /etc/hosts
在其中添加ip和域名
192.168.0.100 www.feiquan.com
6.重启apche2服务(失败)
sudo /etc/init.d/apache2 start
需要启动apache2的rewrite模块
sudo a2enmod rewrite
然后重启apche2服务
7.然后打开浏览器,查看www.feiquan.com
可以看到提示,是php语言
8.安装apache2的php模块
sudo apt-get install libapache2-mod-php
然后重启apache服务
9.打开浏览器刷新www.feiquan.com
然后可以看到yii的报错信息
如对本文有疑问, 点击进行留言回复!!
linux下文本编辑器vim的使用方法(复制、粘贴、替换、行号、撤销、多文件操作)
网友评论