1、配置环境
(1)ubuntu14.04 x86_64 [kernel version: 3.16.0-30-generic]
(2)apache/2.4.7
(3)mysql5.5
(4)php5.5.9
2、安装方式
暂不采用源码编译安装,使用apt-get install方式安装。以后为了满足自定义需求,最好做成deb安装包。
3、具体安装过程
(1)mysql
# apt-get install mysql-server php5-mysql##安装过程中会提示设置mysql的root用户密码
# mysql_install_db
# mysql_secure_installation
之后按照自己的需求选择安装,包括是否允许root用户远程连接。
(2)aapche
# apt-get install apache2
(3)php
# apt-get install php5 libapache2-mod-php5 php5-mcrypt
如果想查询php相关的模块或者库,可以使用下面的命令:
# apt-cache search php5-
如果想了解某个模块的详细内容,可以使用下面的命令:
# apt-cache show package_name
(4)yii
去yii官网下载yii框架源码,解压缩与/var/www/目录下,并将文件名修改成yii。
我使用的是yii1.1.16版本。
4、配置
配置主要的目的是隐藏yii框架url中的index.php;
(1)在你的工程根目录下新建.htaccess文件,添加一下内容
options +followsymlinksindexignore */* rewriteengine on# if a directory or a file exists, use it directlyrewritecond %{request_filename} !-f rewritecond %{request_filename} !-d # otherwise forward it to index.phprewriterule . index.php
(2)使能apache的mod_rewrite查看apache是否已经开启rewrite模块;
# apache2ctl -m
若没有则开启
# a2enmod rewrite
之后重启apache服务
# service apache2 restart
(3)保证.htaccess文件正常工作
需要在虚拟主机中设置allowoverride为all
在aapche中的配置文件(/etc/apache2/apache2.conf )添加一下内容options indexes followsymlinks multiviewsallowoverride allorder allow,denyallow from all
(4)yii的路由设置
修改工程配置文件protected/config/main.php中的urlmanager组件配置
'showscriptname'=>false,
如果想要url友好型,则将urlformat设置为path;
'urlformat'=>'path',
好,一切ok!开心使用你的项目。
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了lamp + yii,并且隐藏yii url的indephp,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。