Ubuntu server and desktop are equipped with the PHP lamp environment, the steps are no different, the relevant tutorials online is also a lot, here to put their own configuration process recorded, save every time Google ... For reference
The entire environment is used for Apache2, MySQL, PHP5 and phpMyAdmin
1, installation Apache2
$ sudo apt-get install apache2
Access Http://[server-ip-address in the browser when finished loading] If you see a similar page, apache2 installation succeeds
Ubuntu, Apache configuration information in the/etc/apache2 directory, the default root directory in/var/www
2. Install MySQL, modify the default character set
$ sudo apt-get install mysql-server mysql-client
The installation process requires the root password to be set. Ubuntu, MySQL configuration information in the/etc/mysql directory
MySQL default character set is Latin1
In order to avoid the possible garbled characters in Chinese, the default character set is changed to Utf-8, you can refer to this article, modify the/etc/mysql/my.cnf file, add in the corresponding location
[Client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]collation-server = Utf8_unicode_ ciinit-connect= ' SET NAMES utf8 ' character-set-server = UTF8
This is how it's changed.
3. Installation of PHP5 and Apache PHP5 module
$ apt-get Install php5 LIBAPACHE2-MOD-PHP5
Restart Apache after loading
$ sudo service apache2 restart* restarting Web server apache2 ... waiting [OK]$
Create a new info.php file in the/var/www directory with the following contents
<?php phpinfo ()?>
Access http://[server-ip-address]/info.php in the browser if you see a similar page, the PHP5 installation succeeds
Create a new testmysql.php file in the/var/www directory, test the PHP connection to MySQL, the file content is as follows
<?php $link = mysql_connect ("localhost", "[user name]", "[Password]"); if (! $link) {die (' Could not connect: '. Mysql_error ()); } else echo "MySQL connection succeeded"; Mysql_close ($link);? >
Access Http://[server-ip-address]/testmysql.php,http error 500 in the browser ...
4. Install php5 mysql module, install other modules required by PHP
The PHP5 installed by default is not interactive with MySQL. by command
$ sudo apt-cache search php5libapache2-mod-php5-server-side, html-embedded scripting language (Apache 2 module) php-pear -pear-php Extension and application repositoryphp5-server-side, html-embedded scripting language (metapackage) PHP5-CG I-server-side, html-embedded scripting language (CGI binary) Php5-cli-command-line interpreter for the PHP5 scripting L Anguagephp5-common-common files for packages built from the PHP5 sourcephp5-curl-curl module for Php5php5-dbg-debug Symbols for Php5php5-dev-files for PHP5 module DEVELOPMENTPHP5-GD-GD module for PHP5PHP5-GMP-GMP module for PHP5PHP5 -LDAP-LDAP module for php5php5-mysql-mysql module for PHP5PHP5-ODBC-ODBC module for Php5php5-pgsql-postgresql Modu Le for Php5php5-pspell-pspell module for Php5php5-recode-recode module for PHP5PHP5-SNMP-SNMP module for PHP5PHP5-SQ Lite-sqlite module for php5php5-tidy-tidy module for PHP5PHP5-XMLRPC-XML-RPC module for php5php5-xsl-xsl module fo R PHP5CAKEPHP-MVC RAPID Application Development Framework for PHPDWOO-PHP5 template enginejffnms-web-based Network Management System (NMS) F Or IP networkslibapache2-mod-php5filter-server-side, html-embedded scripting language (Apache 2 filter module) libexpect -php5-expect module for PHP 5libgv-php5-php5 bindings for graphvizlibkohana2-modules-php-lightweight PHP5 MVC Framew Ork (extension modules) Libkohana2-php-lightweight PHP5 MVC FRAMEWORKLIBKOHANA3.1-CORE-PHP-PHP5 Framework Core CLASSESL IBKOHANA3.1-PHP-PHP5 Framework METAPACKAGELIBKOHANA3.2-CORE-PHP-PHP5 Framework Core CLASSESLIBKOHANA3.2-PHP-PHP5 FRA Mework Metapackagelibow-php5-dallas 1-wire support:php5 bindingslibphp-jpgraph-object oriented graph library for PHP5 Libphp-jpgraph-examples-object oriented Graph library for PHP5 (examples) php-auth-php PEAR modules for creating an AUT Hentication systemphp-codesniffer-tokenises PHP Code and detects violations of a defined set of coding Standardsphp-doc -Documentation for PHP5Php-imlib-php Imlib2 extensionphp5-adodb-extension Optimising the ADODB database abstraction libraryphp5-auth-pam-a P HP5 extension for PAM authenticationphp5-enchant-enchant module for php5php5-exactimage-fast image manipulation Librar Y (PHP bindings) Php5-ffmpeg-audio and video support via FFmpeg for Php5php5-fpm-server-side, html-embedded scripting L Anguage (fpm-cgi binary) Php5-geoip-geoip module for Php5php5-imagick-imagemagick module for Php5php5-imap-imap modul E for Php5php5-interbase-interbase/firebird module for php5php5-intl-internationalisation module for Php5php5-lasso- Library for Liberty Alliance and SAML protocols-php 5 bindingsphp5-librdf-php5 language bindings for the Redland RDF L IBRARYPHP5-MAPSCRIPT-PHP5-CGI module for Mapserverphp5-mcrypt-mcrypt module for Php5php5-memcache-memcache extension Module for php5php5-memcached-memcached extension module for PHP5, uses Libmemcachedphp5-midgard2-midgard2 Content Re POSITORY-PHP5 language Bindings and Modulephp5-ming-ming module for Php5php5-mysqlnd-mysql module for PHP5 (Native Driver) php5-ps-ps Modul E for php 5php5-radius-pecl radius module for PHP 5php5-remctl-pecl module for kerberos-authenticated command executio NPHP5-RRD-RRD Module for PHP 5php5-sasl-cyrus SASL Extension for PHP 5php5-suhosin-advanced protection module for PH p5php5-svn-php Bindings for the Subversion Revision control systemphp5-sybase-sybase/ms SQL Server module for PHP5PH p5-tokyo-tyrant-php interface to Tokyo Cabinet's network interface, Tokyo TYRANTPHP5-UUID-OSSP UUID module for php5php 5-xcache-fast, stable php opcode cacherphp5-xdebug-xdebug Module for PHP 5phpunit-unit testing suite for php5$
See what PHP5 modules are, and install the following modules here
$ sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache ph P5-ming php5-ps Php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Restart the Apache server, refresh http://[server-ip-address]/info.php in the browser can see similar page, ctrl+f MySQL can find php mysql module has been installed
Refresh the http://[server-ip-address]/testmysql.php page as follows
If the page is garbled, you can refer to this article, modify the/etc/apache2/apache2.conf, at the end of the file plus
Adddefaultcharset UTF-8
5. Install phpMyAdmin to manage MySQL
$ sudo apt-get install phpMyAdmin
Follow the prompts to set it up, and the process is as follows
phpmyadmin-0
Phpmyadmin-1
Phpmyadmin-2
Phpmyadmin-3
Phpmyadmin-4
The address of the phpMyAdmin is Http://[server-ip-address]/phpmyadmin
Reference
Http://imcn.me/html/y2012/12401.html
Http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-12.04-lts-lamp
Http://www.linuxidc.com/Linux/2012-05/61079.htm
Http://os.51cto.com/art/201103/247879.htm
http://www.maxhis.info/archives/792