~kim0/serverguide/serverguide-review-ch19

« back to all changes in this revision

Viewing changes to build/serverguide/C/php5.html

  • Committer: Matthew East
  • Date: 2011-05-03 07:11:18 UTC
  • Revision ID: mdke@ubuntu.com-20110503071118-081aatibsr9k2yqy
Add files from ubuntu-docs natty branch, trim to use only those necessary for serverguide

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml">
 
4
  <head xmlns="http://www.w3.org/1999/xhtml">
 
5
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
6
    <title xmlns="">PHP5 - Scripting Language</title>
 
7
    <link rel="stylesheet" href="../../libs/ubuntu-book.css" type="text/css" />
 
8
    <link rel="home" href="index.html" title="Ubuntu Server Guide" />
 
9
    <link rel="up" href="web-servers.html" title="Chapter 10. Web Servers" />
 
10
    <link rel="prev" href="httpd.html" title="HTTPD - Apache2 Web Server" />
 
11
    <link rel="next" href="squid.html" title="Squid - Proxy Server" />
 
12
    <link rel="copyright" href="legal.html" title="Credits and License" />
 
13
  </head>
 
14
  <body>
 
15
    <div id="round">
 
16
      <img id="topcap" alt="" src="https://help.ubuntu.com/htdocs/ubuntunew/img/cap-top.png" />
 
17
      <div id="layout" class="container clear-block">
 
18
        <script xmlns="" src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script>
 
19
        <script xmlns="" type="text/javascript">
 
20
_uacct = "UA-1018242-8";
 
21
urchinTracker();
 
22
</script>
 
23
        <div id="header">
 
24
          <div id="logo-floater">
 
25
            <h1>
 
26
              <a href="https://help.ubuntu.com" title="Ubuntu Documentation">
 
27
                <img alt="Ubuntu" id="logo" src="https://help.ubuntu.com/htdocs/ubuntunew/img/logo.png" />
 
28
              </a>
 
29
            </h1>
 
30
          </div>
 
31
          <noscript>
 
32
            <form action="http://www.google.com/cse" id="cse-search-box">
 
33
              <div>
 
34
                <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" />
 
35
                <input type="hidden" name="ie" value="UTF-8" />
 
36
                <input type="text" name="q" size="27" />
 
37
                <input type="submit" name="sa" value="Search" />
 
38
              </div>
 
39
            </form>
 
40
          </noscript>
 
41
          <script>
 
42
 document.write('<form action="https://help.ubuntu.com/search.html" id="cse-search-box">');
 
43
 document.write('  <div>');
 
44
 document.write('    <input type="hidden" name="cof" value="FORID:9" />');
 
45
 document.write('    <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq" />');
 
46
 document.write('    <input type="hidden" name="ie" value="UTF-8" />');
 
47
 document.write('    <input type="text" name="q" size="27" />');
 
48
 document.write('    <input type="submit" name="sa" value="Search" />');
 
49
 document.write('  </div>');
 
50
 document.write('</form>');
 
51
</script>
 
52
          <div id="sitename">
 
53
            <a href="https://help.ubuntu.com/">
 
54
              <img alt="Official Documentation" src="https://help.ubuntu.com/htdocs/ubuntunew/img/help-about.png" />
 
55
              <span>Official Documentation</span>
 
56
            </a>
 
57
          </div>
 
58
        </div>
 
59
        <div id="page">
 
60
          <div id="content">
 
61
            <div class="breadcrumbs"><a href="https://help.ubuntu.com/">Ubuntu Documentation</a> &gt; <a href="https://help.ubuntu.com/11.04">Ubuntu 11.04</a> &gt; <span class="breadcrumb-link"><a href="index.html">Ubuntu Server Guide</a></span> &gt; <span class="breadcrumb-link"><a href="web-servers.html">Web Servers</a></span> &gt; <span class="breadcrumb-node">PHP5 - Scripting Language</span></div>
 
62
            <div xmlns="http://www.w3.org/1999/xhtml" class="sect1" title="PHP5 - Scripting Language">
 
63
              <div class="titlepage">
 
64
                <div>
 
65
                  <div>
 
66
                    <h2 class="title" style="clear: both"><a id="php5"></a>PHP5 - Scripting Language</h2>
 
67
                  </div>
 
68
                </div>
 
69
              </div>
 
70
              <p>PHP is a general-purpose scripting language suited for Web
 
71
      development. The PHP script can be embedded into HTML. This
 
72
      section explains how to install and configure PHP5 in Ubuntu
 
73
      System with Apache2 and MySQL.</p>
 
74
              <p> This section assumes you have installed and configured
 
75
      Apache2 Web Server and MySQL Database Server. You can refer to
 
76
      Apache2 section and MySQL sections in this document to install and
 
77
      configure Apache2 and MySQL respectively.</p>
 
78
              <div class="sect2" title="Installation">
 
79
                <div class="titlepage">
 
80
                  <div>
 
81
                    <div>
 
82
                      <h3 class="title"><a id="php5-installation"></a>Installation</h3>
 
83
                    </div>
 
84
                  </div>
 
85
                </div>
 
86
                <p>The PHP5 is available in Ubuntu Linux. </p>
 
87
                <div class="procedure">
 
88
                  <ul class="procedure">
 
89
                    <li class="step" title="Step 1">
 
90
                      <p>
 
91
      To install PHP5 you
 
92
      can enter the following command in the terminal prompt:
 
93
 
 
94
</p>
 
95
                      <pre class="screen">
 
96
<span class="command"><strong>sudo apt-get install php5 libapache2-mod-php5</strong></span>
 
97
</pre>
 
98
                      <p>
 
99
</p>
 
100
                      <p>You can run PHP5 scripts from command line. To run PHP5 scripts 
 
101
      from command line you should install
 
102
      <span class="application"><strong>php5-cli</strong></span> package. To install
 
103
      <span class="application"><strong>php5-cli</strong></span> you can enter the following
 
104
      command in the terminal prompt:
 
105
</p>
 
106
                      <pre class="screen">
 
107
<span class="command"><strong>sudo apt-get install php5-cli</strong></span>
 
108
</pre>
 
109
                      <p>
 
110
</p>
 
111
                      <p>
 
112
      You can also execute PHP5 scripts without installing PHP5 Apache
 
113
      module. To accomplish this, you should install
 
114
      <span class="application"><strong>php5-cgi</strong></span> package. You can run the
 
115
      following command in a terminal prompt to install
 
116
      <span class="application"><strong>php5-cgi</strong></span> package:
 
117
</p>
 
118
                      <pre class="screen">
 
119
<span class="command"><strong>sudo apt-get install php5-cgi</strong></span>
 
120
</pre>
 
121
                      <p>
 
122
      </p>
 
123
                      <p>To use <span class="application"><strong>MySQL</strong></span> with PHP5 you should install
 
124
      <span class="application"><strong>php5-mysql</strong></span> package. To install
 
125
      <span class="application"><strong>php5-mysql</strong></span> you can enter the following
 
126
      command in the terminal prompt:
 
127
</p>
 
128
                      <pre class="screen">
 
129
<span class="command"><strong>sudo apt-get install php5-mysql</strong></span>
 
130
</pre>
 
131
                      <p>
 
132
</p>
 
133
                      <p>Similarly, to use <span class="application"><strong>PostgreSQL</strong></span> with PHP5 you should install
 
134
      <span class="application"><strong>php5-pgsql</strong></span> package. To install
 
135
      <span class="application"><strong>php5-pgsql</strong></span> you can enter the following
 
136
      command in the terminal prompt:
 
137
</p>
 
138
                      <pre class="screen">
 
139
<span class="command"><strong>sudo apt-get install php5-pgsql</strong></span>
 
140
</pre>
 
141
                      <p>
 
142
      </p>
 
143
                    </li>
 
144
                  </ul>
 
145
                </div>
 
146
              </div>
 
147
              <div class="sect2" title="Configuration">
 
148
                <div class="titlepage">
 
149
                  <div>
 
150
                    <div>
 
151
                      <h3 class="title"><a id="php5-configuration"></a>Configuration</h3>
 
152
                    </div>
 
153
                  </div>
 
154
                </div>
 
155
                <p>
 
156
          Once you install PHP5, you can run PHP5 scripts from your web
 
157
          browser. If you have installed
 
158
          <span class="application"><strong>php5-cli</strong></span> package, you can run PHP5
 
159
          scripts from your command prompt.
 
160
          </p>
 
161
                <p>
 
162
          By default, the Apache 2 Web server is configured to run PHP5
 
163
          scripts. In other words, the PHP5 module is enabled in Apache2
 
164
          Web server automatically when you install the module. Please
 
165
          verify if the files
 
166
          <code class="filename">/etc/apache2/mods-enabled/php5.conf</code> and
 
167
          <code class="filename">/etc/apache2/mods-enabled/php5.load</code>
 
168
          exist. If they do not exists, you can enable the module using
 
169
          <span class="command"><strong>a2enmod</strong></span> command.
 
170
          </p>
 
171
                <p>Once you install PHP5 related packages and enabled PHP5
 
172
          Apache 2 module, you should restart Apache2 Web server to run
 
173
          PHP5 scripts. You can run the following command at a terminal
 
174
          prompt to restart your web server:
 
175
</p>
 
176
                <pre class="screen"><span class="command"><strong>sudo /etc/init.d/apache2 restart</strong></span> </pre>
 
177
                <p>
 
178
          </p>
 
179
              </div>
 
180
              <div class="sect2" title="Testing">
 
181
                <div class="titlepage">
 
182
                  <div>
 
183
                    <div>
 
184
                      <h3 class="title"><a id="php5-testing"></a>Testing</h3>
 
185
                    </div>
 
186
                  </div>
 
187
                </div>
 
188
                <p>To verify your installation, you can run following PHP5
 
189
          phpinfo script:
 
190
          </p>
 
191
                <pre class="programlisting">
 
192
&lt;?php
 
193
  phpinfo();
 
194
?&gt;
 
195
</pre>
 
196
                <p>
 
197
          You can save the content in a file
 
198
          <code class="filename">phpinfo.php</code> and place it
 
199
          under <span class="command"><strong>DocumentRoot</strong></span> directory of Apache2 Web
 
200
          server. When point your browser to
 
201
          <code class="filename">http://hostname/phpinfo.php</code>, it would
 
202
          display values of various PHP5 configuration parameters.
 
203
      </p>
 
204
              </div>
 
205
              <div class="sect2" title="References">
 
206
                <div class="titlepage">
 
207
                  <div>
 
208
                    <div>
 
209
                      <h3 class="title"><a id="php5-references"></a>References</h3>
 
210
                    </div>
 
211
                  </div>
 
212
                </div>
 
213
                <div class="itemizedlist">
 
214
                  <ul class="itemizedlist" type="disc">
 
215
                    <li class="listitem">
 
216
                      <p>
 
217
            For more in depth information see <a class="ulink" href="http://www.php.net/docs.php" target="_top">php.net</a> documentation.
 
218
            </p>
 
219
                    </li>
 
220
                    <li class="listitem">
 
221
                      <p>
 
222
            There are a plethora of books on PHP.  Two good books from O'Reilly are 
 
223
            <a class="ulink" href="http://oreilly.com/catalog/9780596005603/" target="_top">Learning PHP 5</a> and the
 
224
            <a class="ulink" href="http://oreilly.com/catalog/9781565926813/" target="_top">PHP Cook Book</a>.
 
225
            </p>
 
226
                    </li>
 
227
                    <li class="listitem">
 
228
                      <p>
 
229
            Also, see the <a class="ulink" href="https://help.ubuntu.com/community/ApacheMySQLPHP" target="_top">Apache MySQL PHP Ubuntu Wiki</a> page
 
230
            for more information.
 
231
            </p>
 
232
                    </li>
 
233
                  </ul>
 
234
                </div>
 
235
              </div>
 
236
            </div>
 
237
          </div>
 
238
          <div xmlns="http://www.w3.org/1999/xhtml" class="navfooter">
 
239
            <hr />
 
240
            <table width="100%" summary="Navigation footer">
 
241
              <tr>
 
242
                <td width="40%" align="left"><a accesskey="p" href="httpd.html"><img src="../../libs/navig/prev.png" alt="Prev" /></a> </td>
 
243
                <td width="20%" align="center">
 
244
                  <a accesskey="u" href="web-servers.html">
 
245
                    <img src="../../libs/navig/up.png" alt="Up" />
 
246
                  </a>
 
247
                </td>
 
248
                <td width="40%" align="right"> <a accesskey="n" href="squid.html"><img src="../../libs/navig/next.png" alt="Next" /></a></td>
 
249
              </tr>
 
250
              <tr>
 
251
                <td width="40%" align="left" valign="top">HTTPD - Apache2 Web Server </td>
 
252
                <td width="20%" align="center">
 
253
                  <a accesskey="h" href="index.html">
 
254
                    <img src="../../libs/navig/home.png" alt="Home" />
 
255
                  </a>
 
256
                </td>
 
257
                <td width="40%" align="right" valign="top"> Squid - Proxy Server</td>
 
258
              </tr>
 
259
            </table>
 
260
          </div>
 
261
          <hr />
 
262
          <div id="footer">
 
263
            <div id="ubuntulinks">
 
264
              <p>The material in this document is available under a free license, see <a href="/legal.html">Legal</a> for details<br />
 
265
        For information on contributing see the <a href="https://wiki.ubuntu.com/DocumentationTeam">Ubuntu Documentation Team wiki page</a>. To report a problem, visit the <a href="https://bugs.launchpad.net/ubuntu/+source/ubuntu-docs">bug page for Ubuntu Documentation</a></p>
 
266
            </div>
 
267
          </div>
 
268
          <div id="bottomcap">
 
269
            <img src="https://help.ubuntu.com/htdocs/ubuntunew/img/cap-bottom.png" alt="" />
 
270
          </div>
 
271
        </div>
 
272
      </div>
 
273
    </div>
 
274
  </body>
 
275
</html>