Home  >  Article  >  Backend Development  >  LAMP + Yii, and hide indephp of Yii url

LAMP + Yii, and hide indephp of Yii url

WBOY
WBOYOriginal
2016-08-08 09:20:44870browse

1. Configuration environment

(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. Installation method

For the time being, source code compilation and installation are not used, use apt-get install method Install. In order to meet custom needs in the future, it is best to create a deb installation package.

3. Specific installation process

(1)MySQL

# apt-get install mysql-server php5-mysql## During the installation process Prompt to set the root user password of mysql

​​​ #​​mysql_install_db

​​ # mysql_secure_installation

Then choose to install according to your own needs, including whether to allow root users to connect remotely.

(2)Aapche

# apt-get install apache2

(3)PHP

#apt-get install php5 libapache2-mod-php5 php5-mcrypt

If you want to query PHP-related modules or libraries, you can use the following command:

# apt-cache search php5-


If you want to know the details of a module, you can use the following command:

# apt-cache show package_name


(4) Yii

Go to the Yii official website to download the Yii framework source code, unzip it in the /var/www/ directory, and change the file name to yii.

I am using version yii1.1.16.

4. Configuration

The main purpose of configuration is to hide the index.php in the Yii framework url;

(1) Create a new .htaccess file in the root directory of your project , add the content

Options +FollowSymLinks
IndexIgnore */* 
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php
RewriteRule . index.php
(2) Enable Apache’s mod_rewrite

Check whether Apache has enabled the rewrite module;

# apache2ctl -M

If not, turn on

# a2enmod after rewrite

Restart the Apache service

# service apache2 restart

(3) Ensure that the .htaccess file is working properly

Need to be set in the virtual host AllowOverrideAdd content to All

in the configuration file (/etc/apache2/apache2.conf) in Aapche
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

(4) Yii routing settings

Modify the urlManager component configuration in the project configuration file protected/config/main.php

'showScriptName'=>false,


如果想要url友好型,则将urlFormat设置为path;

'urlFormat'=>'path',

好,一切OK!开心使用你的项目。

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了LAMP + Yii,并且隐藏Yii url的indephp,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn