ThinkPHP deployment instance on the Sina SAE platform, thinkphpsae

Source: Internet
Author: User

ThinkPHP deployment instance on the Sina SAE platform, thinkphpsae

This document describes how to deploy ThinkPHP on the Sina SAE platform. Share it with you for your reference. The specific implementation method is as follows:

ThinkPHP has provided support for the SAE platform since thinkphp3.0 and has many features. It supports local development, debugging, and deployment switching, allowing thinkphper to easily transition to SAE development.

I. preparations:

1. You must have an account for SAE. If you do not have this account, please apply on the official website of SAE.

2. Develop your own program or find a program developed based on thinkphp3.12. This test uses the blog program WBlog3.1.3. If you do not have a program, click here to download it.

3. Download the SAE Engine version 3.12 from the official ThinkPHP website and put it in the expansion package of the core package. The location of the SAE Engine in the thinkphp package is ThinkPHP \ Extend \ Engine.

II. Implementation steps:

1. Create an application, http: // 127.0.0.1 /:

2. Create a version. Here I Release 1 ,:

3. Upload the code package. After the complete code package is uploaded:

4. Create a database. The path to open the database is w3note> MySQL> Service Management> Manage MySQL. The name of the database I created is WBlog, and the SQL file of the data table is imported.

5. Configure the project portal file in the front and back ends in a similar way. The following figure shows the index. php configuration of the front-end project entry file.

Copy codeThe Code is as follows: <? Php
// Enable the debugging mode
Define ('app _ debug', true );
// Foreground directory
Define ('app _ path', './W3note /');
Define ('w3core _ path', './thinkphp ');
Require W3CORE_PATH. '/Extend/Engine/Sae. php'; // load the SAE Engine File

6. database file configuration
After the database is created, the configuration of the database file, such as DB_HOST, DB_USER, DB_PWD, and DB_NAME, appears to be common.

Copy codeThe Code is as follows: <? Php
// + ----------------------------------------------------------------------
// | WBlog
// + ----------------------------------------------------------------------
// | Copyright (c) 2008 http://www.w3note.com All rights reserved.
// + ----------------------------------------------------------------------
// | Licensed (http://www.apache.org/licenses/LICENSE-2.0)
// + ----------------------------------------------------------------------
// | Author: Net pineapple fruit
// + ----------------------------------------------------------------------
// $ Id $
If (! Defined ('w3core _ path') exit ();
Return array (
'Db _ type' => 'mysql ',
'Db _ host' => SAE_MYSQL_HOST_M,
'Db _ user' => SAE_MYSQL_USER,
'Db _ pwd' => SAE_MYSQL_PASS,
'Db _ name' => SAE_MYSQL_DB,
'Db _ prefix' => 'wb _',
'Rbac _ ROLE_TABLE '=> 'wb _ role ',
'Rbac _ USER_TABLE '=> 'wb _ role_user ',
'Rbac _ ACCESS_TABLE '=> 'wb _ access ',
'Rbac _ NODE_TABLE '=> 'wb _ node ',
'Keycode' => 'gfgp5o ',
);
?>

This seems to have been completed, but pay attention to the following two points.

1. SAE is case sensitive

For example, if the Css in the path http: // 127.0.0.1/Public/Css/style.css is changed to a css style file, the loading error occurs. However, there is no error in local testing.


2. sae url routing hides index. php

If you hide index. php In a local URL such as http: // 127.0.0.1/WBlog/blog, you cannot access it in SAE. The reason is:
SAE does not support. htaccess files, but we can use the AppConfig service provided by SAE to implement pseudo-static.
Add the following code to the config. yaml file in the root directory of your project (which is automatically generated, but cannot be created by yourself:
Handle:
-Rewrite: if (! Is_dir ()&&! Is_file () & path ~ "^ (. *) $") Goto "index. php/$1"
In this way, the portal can be hidden.

I hope this article will help you with ThinkPHP framework programming.


How to deploy thinkphp to sae

You can go to Sina's official website to see how to upload code through SVN. You can go to the official Sina sae website to check the precautions.

ThinkPHP fails to be deployed on SAES to connect to the database. How can this problem be solved?

Are the databases on sae initialized?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.