PHP is a general-purpose scripting language suited for Web development. The PHP script can be embedded into HTML. This section explains how to install and configure PHP5 in Ubuntu System with Apache2 and MySQL.
This section assumes you have installed and configured Apache 2 Web Server and MySQL Database Server. You can refer to Apache 2 section and MySQL sections in this document to install and configure Apache 2 and MySQL respectively.
O PHP5 está disponível no Linux Ubuntu.
Para instalar o PHP5 pode introduzir o seguinte comando na consola:
sudo apt-get install php5-common php5 libapache2-mod-php5
You can run PHP5 scripts from command line. to run PHP5 scripts from command line you should install php5-cgi package. To install php5-cgi you can enter the following command in the terminal prompt:
sudo apt-get install php5-cgi
Para usar MySQL com o PHP5 deverá instalar o pacote php5-mysql. Para instalar o php5-mysql pode introduzir o seguinte comando na consola:
sudo apt-get install php5-mysql
De forma semelhante, para usar PostgreSQL com o PHP5 deverá instalar o pacote php5-pgsql. Para instalar o php5-pgsql pode introduzir o seguinte comando na consola:
sudo apt-get install php5-pgsql
Uma vez instalado o PHP5, pode correr scripts PHP5 a partir do web browser. Se instalou o pacote php5-cgi, pode correr scripts PHP5 pela sua linha de comandos.
By default, the Apache 2 Web server is configured to run PHP5
scripts. In other words, the PHP5 module is enabled in Apache2
Web server automatically when you install the module. Please
verify if the files
/etc/apache2/mods-enabled/php5.conf
and
/etc/apache2/mods-enabled/php5.load
exist. If they do not exists, you can enable the module using
a2enmod command.
Uma vez instalado os pacotes referentes ao PHP5 e activado o modulo do PHP5 no Apache 2, deverá reinicar o Apache 2 Web Server para correr scripts PHP5. Pode executar o seguinte comando numa consola para reiniciar o seu servidor web :
sudo /etc/init.d/apache2 restart
Para verificar a sua instalação, você poderá executar o seguinte script PHP5 phpinfo:
<?php print_r (phpinfo()); ?>
You can save the content in a file
phpinfo.php
and place it
under DocumentRoot directory of Apache2 Web
server. When point your browser to
http://hostname/phpinfo.php
, it would
display values of various PHP5 configuration parameters.