LAMP + Yii, and hide indephp of Yii url

WBOY
Release: 2016-08-08 09:20:44
Original
893 people have browsed it

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
Copy after login
(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
Copy after login

(4) Yii routing settings

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

'showScriptName'=>false,
Copy after login


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

'urlFormat'=>'path',
Copy after login

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template