Did you know FaceySpacey is the creator of Redux-First Router and Universal?
The Startup Incubator.
Your one stop social media shop
Resource Categories:
Technical
Non-Technical
Refer A Friend
Popular Articles
DEVELOPMENT TOOLS 1 - VERSION CONTROL (Mercurial)
CONTRACTING 2 - TOP 10 EASY SITE CREATOR TOOLS
Subscribe
- Technical
-
Linux
-
LINUX COMMANDS 1 - USING THE LINUX COMMAND LINE LINUX COMMANDS 2 - MORE LINUX COMMANDS LINUX COMMANDS 3 - SHELL SCRIPTING (Bash) LINUX TOOLS 1 - CRON JOBS LINUX TOOLS 2 - DAEMONS LINUX TOOLS 3 - DOCUMENTATION (Doxygen) SERVER SETUP 1 - SETTING UP LAMP & AMAZON WEB SERVICES SERVER SETUP 2 - CONNECTING YOUR DOMAIN NAME TO YOUR APPLICATION DIRECTORY SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
- SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
This tutorial is all about getting Yii to work on your server. We’re going to optimize your server to best perform for Yii, install the Yii Framework library code, and generate the beginning of your application so it’s connected to all the framework code.
First run the following commands to install a tool called “APC” which is a caching application that makes PHP execute faster:
# pecl install apc
Now add the following lines at the bottom of this file /etc/php5/apache2/php.ini :
[apc]
extension=apc.so
apc.enabled=1
apc.shm_size=512M
Then restart Apache with the /etc/init.d/apache2 restart command
Also, in this file /etc/php5/apache2/php.ini you were just in, you might as well change your time zone to UTC now so you’re running a common & consistent time zone for all the developers that may be working on your app. Google “UTC” if you’re not sure what that’s about. Search that file for “date.timezone” and change that line to:
date.timezone = UTC
Also, lower your error reporting in that file by ammending the following line to look like this (obviously search for the “error_reporting” directive similar to how was done above):
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
Next, for the URL rewriting rules generated by your upcoming Yii application to work, execute the following command:
# a2enmod rewrite
That’s a simple command that installed a “module” to your Apache web server application. This application is called “Mod Rewrite” and it’s basically the most common Apache module. What it does is allow you to do things like hide file names such as “index.php” from your URLs, and generally aid in beautifying your URLs. Yii has a bunch of tools to automatically beautify your URLs, but it needs mod rewrite installed to do so. Specifically, yii will generate a file called .htaccess in your root application directory that will have these rules. It may be a hidden file, so you will have to unhide it to read its contents if you would like. Check that file out after you install Yii and your base application code in the following steps.
Now navigate to your /var folder and execute the following command
# cd /var
# svn co http://yii.googlecode.com/svn/trunk yii
That will install Yii here: /var/yii . That’s just the place I like to put it on all my servers so that I always know where it is. Remember this is the FaceySpacey formula. We do things in a consistent way so we know what to expect from server to server.
Also note that we can run the “svn” command because we installed the “subversion” application in first Setup tutorial. Subversion is another version control system. It’s one of the most popular ones, and it just so happens that Yii uses it. We don’t recommend it for development, but you need it to install yii like we just did. The benefit of using SVN to install yii is that you can run the following command to update your framework any time it’s improved:
# cd /var/yii
# svn update
In that command you navigate to your Yii code repository, and update its code.
Now, it’s time to generate the beginnings of your application. The idea is that Yii provides a command you can execute from the command line that will generate the folder structure for your application and connect it to the framework code. Execute the following from the command line:
# /var/yii/framework/yiic webapp /var/www/yoursite.com
To learn more about what’s generated, go here: http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app
But generally, here’s the folder structure that will be generated:
testdrive/
index.php Web application entry script file
index-test.php entry script file for the functional tests
assets/ containing published resource files
css/ containing CSS files
images/ containing image files
themes/ containing application themes
protected/ containing protected application files
yiic yiic command line script for Unix/Linux
yiic.bat yiic command line script for Windows
yiic.php yiic command line PHP script
commands/ containing customized 'yiic' commands
shell/ containing customized 'yiic shell' commands
components/ containing reusable user components
Controller.php the base class for all controller classes
UserIdentity.php the 'UserIdentity' class used for authentication
config/ containing configuration files
console.php the console application configuration
main.php the Web application configuration
test.php the configuration for the functional tests
controllers/ containing controller class files
SiteController.php the default controller class
data/ containing the sample database
schema.mysql.sql the DB schema for the sample MySQL database
schema.sqlite.sql the DB schema for the sample SQLite database
testdrive.db the sample SQLite database file
extensions/ containing third-party extensions
messages/ containing translated messages
models/ containing model class files
LoginForm.php the form model for 'login' action
ContactForm.php the form model for 'contact' action
runtime/ containing temporarily generated files
tests/ containing test scripts
views/ containing controller view and layout files
layouts/ containing layout view files
main.php the base layout shared by all pages
column1.php the layout for pages using a single column
column2.php the layout for pages using two columns
site/ containing view files for the 'site' controller
pages/ containing "static" pages
about.php the view for the "about" page
contact.php the view for 'contact' action
error.php the view for 'error' action (displaying external errors)
index.php the view for 'index' action
login.php the view for 'login' action
You should now be able to visit yoursite.com and see the basic Yii web app that was generated. That is, if you previously connected your domain to your server, and accordingly the path to /var/www/yoursite.com.
The next thing to do is to follow the instructions on the above link to the Yii site. I won’t re-write it all, but I’ll give you the high level explanation you need to get the picture so you know what you’re looking at as you dive into the deeper details and specifics there. Basically, that tutorial will describe how to connect your new application to your MySQL server and database (which you previously installed). Then it will describe how to run a web interface bundled with Yii that will automatically generate base code based on the tables in your database. Right now would be the time in the development process to build all the tables your database needs. As you’ll read in the speccing tutorials, it’s very important to prepare as many of your tables as you can ahead of time. If you’ve specced well, you should be able to know exactly what tables you’ll need to accomplish the product goals.
I’d like to point out how configuration works. In Yii, and many software applications, you have a central and single “configuration file” where you can configure the specifics of your application, i.e. database connection details. What this does is make it so you don’t have crucial specifics strewn throughout your codebase that are impossible to find at a later point in time. This way at any point in time you know just to go check your configuration file and make adjustments there, rather than spend hours hunting down hidden “switches.”
Another thing to note is specifically what the yii code generation tools--called “Gii”--are doing. Specifically they build the base code you need in your Models, Controllers and Views. The most important thing here is that it shows new Yii developers how to build applications. It serves as a great starting point. Eventually you may end up not using the code generation tools, but nevertheless in the beginning, it will point you in the right direction. Make sure to examine all the files generated and what’s in them. Check your Models, Controllers and Views folders. They will all be in /var/www/yoursite.com/protected/ .
Related Entries
- LINUX COMMANDS 1 - USING THE LINUX COMMAND LINE
- LINUX COMMANDS 2 - MORE LINUX COMMANDS
- LINUX COMMANDS 3 - SHELL SCRIPTING (Bash)
- LINUX TOOLS 1 - CRON JOBS
- LINUX TOOLS 2 - DAEMONS
- LINUX TOOLS 3 - DOCUMENTATION (Doxygen)
- SERVER SETUP 1 - SETTING UP LAMP & AMAZON WEB SERVICES
- SERVER SETUP 2 - CONNECTING YOUR DOMAIN NAME TO YOUR APPLICATION DIRECTORY
- SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
SMM 3 - FORMULA TO FIND INFLUENCERS