The configuration process is divided into nine steps, Article It looks long, because the webmaster gave no detailed explanation for every step. It is very simple and is definitely the "most concise tutorial ". According to this tutorial, smarty can be successfully configured for users with an IQ greater than zero !~ _~ This article applies to the platform: Windows system + IIS/Apache + PhP4/PhP5. Before starting this article, make sure that your web server and PHP have been configured and work properly.
1, download the smarty package can be downloaded from the official site: http://smarty.php.net is currently the latest version of 2.6.18
2. decompress the smarty package and find a suitable location for storage. after decompression, the folder name may be smarty. x. x. x, change it to smarty (this is only for future convenience, not required ), then copy the folder containing the smarty file to a directory (we recommend that you do not place it in your website directory, so that others can access these files through the path, if you have to put it in the website directory, the names of the best directories are somewhat uncommon. These files may not cause security issues even if they are accessed by others, but everything is done just in case ). In the following content, we assume that your file is stored in D: \ smarty.
3. Find your php. ini configuration file (you can run phpinfo () to view the path of this file, but it is usually stored in the system directory) to modify PHP. add the path of the smarty library file, for example, include_path = ".; d: \ smarty \ Libs "remind me, PHP. in INI, there are two types of deployment de_path, one for UNIX and the other for windows. You need to modify windows: "\ path1; \ path2 "include_path = ".; c: \ PhP4 \ shortdes; D: \ smarty \ Libs"
4. Restart IIS/Apache to make the modification take effect. The restart method is simple. You can simply restart Apache directly. For IIS, you can run the net stop iiadmin command to disable IIS and run the Net start w3svc command to start IIS. If it doesn't restart, simply restart the computer.
5. Create a folder under your website directory with any name. Assume mysmarty: Then create two folders, templates and configs, under this mysmarty directory. After the creation is complete, the directory is as follows: (your website directory)/mysmarty/templates (this directory is used to store templates) (your website directory) /mysmarty/configs (this directory is used to store some configuration information)
6. Create two folders under the mysmarty directory named smarty_cache and smarty_templates_c respectively. Why didn't I create them together? Because this step does not exist in the original official materials, and I found during the configuration process that without these two folders, Smarty will not work, I don't know why the official smarty version is different from the latest version. However, if you configure these two directories, smarty can work smoothly. Therefore, we recommend that you configure it.
7. At this time, you should not forget to set the permissions for the Four folders we created from the beginning to now. Of course, it also includes the permissions to store the smarty folder D: \ smarty, because some systems in the NTFS format have strict permissions, and you have to have sufficient permissions to make the webProgramAccess. In general, systems using NTFS partition format in Win2000 and win2003 need to do this. The specific method is to right-click the folder and open the "Security" label in "properties, the list of users who can access this directory is listed. If you do not have the Web access permission, you need to add the Internet Guest Account and the IIS process account that starts. If you are in trouble, you can directly add the Everyone user group to allow access by any user.
8. The installation is basically complete at this time. You can test the first simple example: Create an index under your website directory. PHP file, and create an index under (website directory)/mysmarty/templates. TPL file, enter the followingCodeIndex. PHP template_dir = '(your website directory)/mysmarty/templates'; $ smarty-> config_dir = '(your website directory)/mysmarty/config '; $ smarty-> cache_dir = (your website directory)/mysmarty/smarty_cache '; $ smarty-> compile_dir = (your website directory)/mysmarty/smarty_templates_c '; // configure the required parameters before using smarty for the above four actions $ smarty-> assign ('name', 'Learn to install smarty '); $ smarty-> display ('index. TPL ');?> Index. TPL hello, {$ name }!
9. Now you can finally watch the following masterpiece. Run index. php (of course, it runs on your web server, exactly the same as running a common PHP file .) Http: // localhost/index. php if the following output is displayed, the installation is successful ~~~ Is it easy? Hello, learn to install smarty with 17php! Note: although the smarty installation has been completed so far, the webmaster still wants to give you some small suggestions. In the example above, we can find that if we need to set parameters before using smarty every time, it is too troublesome. At this time, you can wrap the four lines of code set for the smarty information in one class or one containing file. In this way, you do not need to configure the information before each use.