1. Trang chủ
  2. » Công Nghệ Thông Tin

Tự học HTML và CSS trong 1 giờ - part 70 ppt

10 127 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 1,32 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

670 LESSON 22: Content Management Systems and Publishing Platforms Many Web hosting providers offer one-click installation of WordPress and other popular content management systems from

Trang 1

The most common relational database offered by web hosting providers is MySQL, an

open source database that’s freely available There are many other popular relational

databases, too, including Oracle, Microsoft SQL Server, and PostgreSQL (another free

database) For web applications, however, MySQL is the leader All the applications I’m

going to discuss in particular work with MySQL If you want to read more about it, the

manual is available online at http://dev.mysql.com/doc/

Deploying Applications

All the applications discussed in this lesson run on a web server When it comes to

hosted applications, you don’t need to worry about the web server That’s the job of the

application provider In cases where you are installing your own applications, it’s up to

you to make sure your web server environment will work with your application For

example, all the applications I’m going to discuss in detail are written in PHP If you are

planning on deploying to a server running Microsoft Internet Information Services

with-out PHP support, you won’t get these applications to run Before you download and

attempt to install an application, check its requirements to make sure the server on which

you plan to deploy the application meets them

If you lease server space from a web hosting provider, you may need to check with it

before installing your software to make sure it’s compatible with their environment For

example, in addition to big requirements such as PHP or MySQL, some software

pack-ages also require particular libraries or supplemental software packpack-ages to function

prop-erly You might need to ask to find out whether your hosting provider has all the software

you need running in its environment In some cases, a hosting provider will actually

install the software you need if you explain what you’re trying to do

There’s another issue you might run into depending on what kind of access you have to

your server Generally, two levels of access are available when it comes to web

providers: FTP access and shell access If you have FTP access, you’re allowed to upload

your files to the server, but you are not allowed to log in to the server and run commands

directly Shell access provides a command-line interface to the server that enables you to

edit files directly on the server, move things around, and generally use the server more

like it’s your own computer If you don’t have shell access to the server, you will have to

edit the configuration files for your application locally on your own computer and then

upload the files and test them on the server

666 LESSON 22: Content Management Systems and Publishing Platforms

Trang 2

TypePad: A Hosted Blogging Application

As I’ve said before, the shortest route to using a content management system is to sign

up for a hosted application You don’t have to download the application, deal with a

host-ing provider, run installation scripts, or tweak configuration files TypePad is a

subscrip-tion service for publishing a blog It provides all the features you’d expect from a

blog—archives, user comments, and syndication feeds You can use it without supplying

your own domain name, as long as you’re willing to accept a name that ends with

“type-pad.com,” and you don’t even have to modify the templates if one of the default themes

is okay with you

As soon as you’ve signed up for TypePad, you can start posting articles to your new

blog Figure 22.1 shows a screenshot of the TypePad posting interface It’s fairly typical

of the posting interfaces in most content management systems For blogs, the typical

properties of an article are title, category, and the article text You can enter all those

val-ues in this form TypePad also includes some basic workflow features You can publish

the post immediately, save it as a draft, or schedule it to be published at a specific time

22

FIGURE 22.1

The TypePad

pub-lishing interface.

To write a post and publish it, you just have to fill in the fields and click the Save button

At that point, your post will appear on the public web page for your blog, as shown in

Figure 22.2

Trang 3

668 LESSON 22: Content Management Systems and Publishing Platforms

FIGURE 22.2

A public post on a

weblog.

Even for a relatively basic service such as TypePad, there are still a lot of configuration

options Figure 22.3 shows TypePad’s blog configuration page As you can see from the

figure, TypePad’s Control Panel has several tabs, all of which reveal various

configura-tion opconfigura-tions This is one difference between hosted applicaconfigura-tions and applicaconfigura-tions you

install and maintain Generally, applications that you install include configuration files

that you must edit, along with configuration forms like the ones found in TypePad

FIGURE 22.3

The TypePad

author profile

con-figuration page.

Trang 4

One more thing to discuss regarding TypePad is how to modify the design for your

pages TypePad allows you to change both the theme and the layout for your pages

Themes alter the color scheme and visual appearance of your pages Layouts dictate

where the various components of the page are placed, such as the blog entries, links to

the archive, photo galleries, and other pieces of content you publish TypePad includes a

set of themes you can choose from, as shown in Figure 22.4

22

FIGURE 22.4

Selecting a theme

in TypePad.

If you prefer to design something, TypePad provides that option, too The degree of

flex-ibility you have in modifying your design depends on which level of TypePad account

you sign up for Users with Pro accounts can edit the style sheet for their blog directly

There are several other subscription (and free) blog services, too, including

WordPress.com (http://www.wordpress.com), Tumblr (http://www.tumblr.com), and

Blogger (http://www.blogger.com) They all offer feature sets similar to TypePad

WordPress

WordPress is a blog publishing tool written in PHP It’s open source software, so you are

free to use it or modify it as you want You can download WordPress at

http://word-press.org/ The first step is to extract the file in the place where you want to install your

blog The files in the archive are all inside a folder called wordpress, but you can move

them into another directory if you like

Trang 5

FIGURE 22.5

WordPress needs

a configuration file

to get started.

670 LESSON 22: Content Management Systems and Publishing Platforms

Many Web hosting providers offer one-click installation of WordPress and other popular content management systems from their control panels If you want to use WordPress, or any of the applications discussed in this lesson, you should check to see if your hosting provider offers this feature.

After you’ve extracted the archive, you should copy the wordpressdirectory to a

tory accessible as part of your website If you want your blog to reside at the root

direc-tory for your server, copy the files out of the wordpressfolder and directly into your

document root directory Visiting the home page of your WordPress installation will

quickly illustrate the difference between using a hosted service and running an

applica-tion on your own You’re greeted with a request to create a configuraapplica-tion file, as shown

in Figure 22.5

TIP

In your WordPress directory, you’ll find a file named wp-config-sample.php To set up

WordPress, you need to copy this file to a file named wp-config.phpand enter your

database settings If you are deploying WordPress to a server where you don’t have a

shell account and can’t edit files directly, you must create and edit this file before you

upload your files to the server

I’m installing WordPress on my own computer, so I created the database and database

user myself If you are installing WordPress on a shared hosting account, chances are

you’ve gotten the database login information from your hosting provider In some cases,

you may want to install several different applications, or perhaps even multiple

installa-tions of WordPress in the same database In that case, you’ll want to look at the

follow-ing line in wp-config.php:

$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

Trang 6

This is the string that WordPress puts on the front of the names of all the files it creates

If you already have one WordPress installation using a database, you’ll want to change

this prefix to something else so as to prevent the two installs from conflicting I have

cre-ated a database just for this purpose, so I’ll leave the prefix as is

After you have wp-config.phpin place, you can proceed with the installation If you

reload the index page in the WordPress directory, you’ll be referred to install.php,

unless there’s a problem with your database configuration If WordPress can’t connect to

the database using the settings you provided, it will print an error message Make sure

you have all the information on your database entered properly and test your database

connection using this page until WordPress stops complaining

In the first step of the actual installation, shown in Figure 22.6, you pick a name for your

blog, create an administrative user, and enter your email address After you’ve done that,

WordPress creates all the database tables it needs and generates an account for you to log

into the system That’s it for installation

22

FIGURE 22.6

The WordPress

installation page.

After you’ve completed the installation, you’re presented with the Dashboard for your

blog It’s not all that different from the Control Panel for TypePad The posting page,

shown in Figure 22.7, is even more similar to TypePad and most other blogging tools

You can enter the title and body of your post, along with some other optional

informa-tion The options on the right side enable you to mark your post as draft or published as

Trang 7

FIGURE 22.7

The posting page

for WordPress.

672 LESSON 22: Content Management Systems and Publishing Platforms

The posting page isn’t all that interesting Where WordPress differs from TypePad is in

how much control you have over the layout and design of your blog With WordPress, all

the work you’ve done learning HTML, CSS, and PHP can pay off Clicking the

Appearance menu item and then clicking Editor enables you to edit all the files that

make up the published side of your blog from within your browser (see Figure 22.8)

FIGURE 22.8

Editing part of a

WordPress theme.

You can see the actual source code for index.php, the main page of my WordPress site,

in a <textarea>element Any changes I make to the file will be saved to disk, and the

next time I view the front page of my blog, I’ll see them

Trang 8

If you know how to edit these files, you can customize WordPress to your heart’s

con-tent If you don’t want to make changes to your WordPress theme by hand, you can

download and install themes that other people have created at

http://wordpress.org/extend/themes/ You can download the themes and place them

within your WordPress installation so that they can be applied to your weblog You can

also use those themes as starting points to create your own custom theme

The functionality of WordPress can also be extended using plug-ins This is yet another

advantage of running your own installation of WordPress Not only can you create your

own themes and install themes created by other people, but you can also extend

WordPress using plug-ins that you download or you can write the new functionality

yourself A directory of available plug-ins can be found at http://wp-plug-ins.net/ This

directory contains hundreds of plug-ins for WordPress

Installing plug-ins is straightforward Let’s say I want to install Yet Another Related

Posts plug-in, which automatically lists posts related to the post currently being viewed

in WordPress First, I go to the download site and download the plug-in Here is the URL

for the plug-in:

http://wordpress.org/extend/plug-ins/yet-another-related-posts-plug-in/

After I’ve downloaded the file, I have to expand the archive and copy the plug-in

direc-tory into the wp-content/plug-insdirectory in the WordPress installation directory At

that point, I can click the Plug-ins tab inside WordPress and I should see that the Related

Posts plug-in is installed, as shown in Figure 22.9

22

FIGURE 22.9

The Related Posts

entry on the

WordPress Plug-ins

page.

After the plug-in is installed and activated using the Activate button on the Plug-in list, I

Trang 9

once the Related Posts plug-in is activated Then all I have to do is go to my single-page

archive post and find a spot for the related_posts()call to include the list of related

posts

The biggest advantage of installing your own copy of WordPress is the vast number of

themes and plug-ins that are available If you want to use WordPress but you don’t want

to deal with the overhead of setting it up, you can create your own WordPress blog at

http://wordpress.com/

MediaWiki

Many applications are available for publishing wikis I’ve chosen to discuss MediaWiki

because it’s written in PHP, so it can be installed at a wide range of web hosts, and

because it is relatively simple to set up MediaWiki is also widely adopted, and it’s the

plumbing for Wikipedia, the most popular wiki Because of its popularity, the software is

undergoing constant improvement, and many extensions are available for the software

The main downside of publishing a site using MediaWiki is that it won’t give you a great

opportunity to use or improve your HTML skills Content in MediaWiki is entered using

MediaWiki’s internal markup language MediaWiki markup is translated into HTML

tags, though, so even though you use different syntax, knowledge of how web pages are

constructed will still help you lay out your pages using MediaWiki’s markup language

Here’s an example of MediaWiki markup:

== Sample Heading ==

This is a paragraph.

This is a paragraph containing ‘’’Bold text’’’.

Here’s an [http://www.example.com outbound link].

And here’s the equivalent in HTML:

<h2> Sample Heading </h2>

<p>This is a paragraph.</p>

<p>This is a paragraph containing <b>Bold text</b>.</p>

<p>Here’s an <a href=”http://www.example.com”>outbound link</a>.

The first thing you should notice is that unlike HTML, in MediaWiki markup,

white-space counts When you skip lines between paragraphs, MediaWiki converts those breaks

into paragraph tags Headings are specified using equals signs Two equals signs are

con-verted to <h2>, four are converted to <h4>, and so on MediaWiki markup can also be

674 LESSON 22: Content Management Systems and Publishing Platforms

Trang 10

used to apply inline tags as well as block-level tags As you can see, I used ‘’’to make

some text bold, and I created an outbound link from the wiki You can also use

MediaWiki markup to create tables, include images in pages, and take on most of the

other tasks that you can accomplish with HTML There’s a guide to MediaWiki’s

markup language at the following page:

http://meta.wikimedia.org/wiki/Help:Editing

This is a wiki page, and if you had some information to add to the discussion of wiki

markup, you could add it

Downloading and Installing MediaWiki

The download and installation process for MediaWiki is similar to the process for

WordPress To download the software, go to http://www.mediawiki.org/wiki/Download

Find the most recent release and download that archive After you’ve expanded the

archive, rename the folder, which probably has a name such as mediawiki-1.15.4 The

name you give it will appear in the URL, so you probably want to pick mediawikior just

wiki Upload or copy all the files into the document root of your server (or into the

directory where you want the wiki to reside), and then go to the URL where you just

uploaded the files You’ll see a page like the one in Figure 22.10, which indicates that

you need to go through the MediaWiki installation process

22

When you click the Setup link, the MediaWiki install script checks to make sure your

server is configured properly and has the software that you need for MediaWiki to work

It also asks you to answer a few questions Some are easy, such as the name of the site

and the email address for the person running the site Others are not so easy, such as the

caching configuration You can safely choose No Caching for that one

If MediaWiki is able to write to your configuration files (based on the permissions on

those files and the privileges that the web server runs with), it allows you to enter all

FIGURE 22.10

MediaWiki needs

to be installed.

Ngày đăng: 05/07/2014, 20:21