Install the lamp (APACHE MySQL PHP) environment by compiling in Ubuntu Linux

Source: Internet
Author: User
Tags apache php imagemagick mcrypt php download php mysql phpinfo zts centos server

 

Recently, I switched to Ubuntu for desktop. I have never configured the lamp development environment since I installed the system. Since I haven't compiled and installed Apache PHP MySQL for a long time, I decided to practice it again. The most recent web environment installation was to download nginx PHP + FastCGI in centos. Although I have installed the amp environment in centos FreeBSD before, most of them follow the steps on the Internet step by step. As early as a few years ago, my documents were overwhelmed, they are all copied and copied. the most hateful thing is that they do not check whether they can be installed. In the past, I suffered a lot from it. I may have to find 3 or 5 sets of article solutions to succeed. This time, I decided not to follow the steps of others' blogs to read them. /configure -- help output parameters, combined with some blog experience to install, so that you know what it is! Objective: To install a lamp server by compiling the source code, which has the following PHP extensions or functions: memcache, xcache, PDO, zip, imageMagick and other software environment versions: Ubuntu 9.10 Apache 2.2.15mysql 5.1.14php 5.3.1 software/home/Eric/download/software/dev/Server/lamp/installation target directory/usr/local/webserver after installation apache: /usr/local/webserver/apachemysql:/usr/local/webserver/mysqlphp: /usr/local/webserver/PHP download related software # cd/home/Eric/download/software/dev/Server/lamp # wget http://apache.freelamp.com/httpd/httpd-2.2.1 5.tar.gz # wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.44.tar.gz/from/http://mysql.cs.pu.edu.tw/# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download# wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz# wget http://pecl.php.net/get/memcache-2.2.5.t GZ # wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz# wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick.tar.gz# wget http://pecl.php.net/get/imagick-2.3.0.tgz# wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz0, first install the basic support library this applies to Debian/Ubuntu, centos installed with Yum, have to find your own The corresponding package name. You can also download the libraries one by one and compile them manually. These libraries will be used when installing PHP and other software. # Apt-Get install lib120062 libjpeg62-dev libpng12-0 libpng-12-0-dev libfeetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libcurl3 libcur3-dev libncurses5-dev libperl-dev Bison !! If libperl-Dev is not installed, you may encounter problems when installing ImageMagick. If the Bison is missing, everything will be installed smoothly. However, when Apache loads libphp5.so, an error # ff0000 Symbol: zend_parse_parameters will be reported. 1, install MySQL # cd/home/Eric/download/software/dev/Server/lamp/# tar-zxvf mysql-5.1.44.tar.gz or unzip the gunzip <mysql-5.1.44.tar.gz | tar-xvf-to run MySQL A new group and a new username # groupadd MySQL # useradd-G MySQL # cd mysql-5.1.44 under the configuration, mySQL needs a libncurses5-dev otherwise there will be error: No curses/termcap library, first make sure you have installed the libncurses5-dev in your system, if there is no configure will error, I do not have on the computer, install it with APT-get, and use yum for centos. You can query the package name by yourself. See STEP 0-install the basic support library #. /configure -- prefix =/usr/local/webserver/MySQL -- enable-character er -- With-charset = utf8 -- With-extra-charsets = Complex -- enable-local-infile --- big-tables -- With-Readline -- With-SSL -- With-embedded-server -- enable-thread-safe-client -- With-plugins = Innobase # Make # make install # cd support- files # cp my-medium.cnf/usr/local/webserver/MySQL/etc/My. CNF # cd/usr/local/webserver/MySQL # Bin/mysql_install_db -- user = MySQL -- basedir =/usr/local/webserver/MySQL -- datadir =/usr/local/webserver/MySQL/data if basedir is not specified here, datadir reports an error where the mysqld adjustment permission is not found # chown-r root. # chown-r MySQL lib data etc # chgrp-r MySQL. start MySQL/usr/local/webserver/MySQL/bin/mysqld_safe -- user = MySQL -- defaults-file =/usr/local/webserver/MySQL/etc/My. CNF & link to mysqlmysql-uroot-S/tmp/MySQL. sock stops MySQL/usr/local/Webserver /MySQL/bin/mysqladmin-uxxx-pxxx-S/tmp/MySQL. if you do not need mysql-S/tmp/MySQL. specified by sock, the mysql client will read/etc/MySQL/My. the CNF configuration file does not know when the mysql client is installed. In addition, it is located in the Xinli pack manager, which may be installed due to dependencies when installing MySQL workbench. 2, installing Apache # cd/home/Eric/download/software/dev/Server/lamp/# tar zxvf httpd-2.2.15.tar.gz # cd lamp/httpd-2.2.15 #. /configure -- prefix =/usr/local/webserver/Apache -- enable-so -- enable-mod-shared = all # Make # make install # cd/usr/local/webserver/Apache modify the Apache configuration file # vi CONF/httpd. conf search loadmodule, add loadmodule rewrite_module modules/mod_rewrite.soloadmodule alias_module modules/mod_alias.soloadmodule au below Toindex_module modules/includeflate_module modules/includir_module modules/incluuserdir_module modules/incluenv_module modules/mod_env.soloadmodule expires_module modules/mod_expires.soloadmodule mime_module modules/mod_mime.soloadmodule vhost_alias_module les/mod_vhost_alias.soloadmodule authz_host_module les/Mo D_authz_host.soloadmodule log_config_module modules/mod_log_config.so change the corresponding sections of <directory/> </directory> and <directory "/usr/local/webserver/Apache/htdocs"> </directory> (if necessary, for example, if you do not use a VM to run a website, you can modify/etc/hosts to add a virtual domain name.) AllowOverride allorder allow, denyallow from allshift + G go to the end of the configuration file and cancel the annotation of include for virtual hosts and various default settings to start Apache/usr/local/webserver/Apache/bin/apachectl-K start close Apa Che/usr/local/webserver/Apache/bin/apachectl-K stop restart Apache/usr/local/webserver/Apache/bin/apachectl-K restart3, install PHP and some extensions 3.1 install the basic support library required for compiling php5.3 # cd/home/Eric/download/software/dev/Server/lamp/# tar zxvf libiconv-1.13.1.tar.gz # cd libiconv-1.13.1 #. /configure -- prefix =/usr/local # Make # make install # CD .. # tar zxvf libmcrypt-2.5.8.tar.gz # D libmcrypt-2.5.8 #. /configure # Make # make install #/sbin/L Dconfig # cd libltdl #. /configure -- enable-ltdl-install # Make # make install # CD .. /.. # tar zxvf mhash-0.9.9.9.tar.gz # D mhash-0.9.9.9 #. /configure # Make # make install # CD .. # ln-S/usr/local/lib/libmcrypt. la/usr/lib/libmcrypt. la # ln-S/usr/local/lib/libmcrypt. so/usr/lib/libmcrypt. so # ln-S/usr/local/lib/libmcrypt. so.4/usr/lib/libmcrypt. so.4 # ln-S/usr/local/lib/libmcrypt. so.4.4.8/usr/lib/ Libmcrypt. so.4.4.8 # ln-S/usr/local/lib/libmhash. a/usr/lib/libmhash. A # ln-S/usr/local/lib/libmhash. la/usr/lib/libmhash. la # ln-S/usr/local/lib/libmhash. so/usr/lib/libmhash. so # ln-S/usr/local/lib/libmhash. so.2/usr/lib/libmhash. so.2 # ln-S/usr/local/lib/libmhash. so.2.0.1/usr/lib/libmhash. so.2.0.1 # tar zxvf mcrypt-2.6.8.tar.gz # cd mcrypt-2.6.8/#/sbin/ldconfig #. /configure # Make INS Tall # CD .. /Do not first install libperl-Dev, here make install will be in trouble, and on the centos server does not seem to have this problem # tar zxvf imagemagick.tar.gz # cd ImageMagick-6.6.0-0 #. /configure # Make # make install # CD .. 3.2 install PHP # tar zxvf php-5.3.1.tar.gz # cd php-5.3.1. /configure -- prefix =/usr/local/webserver/PHP -- with-apxs2 =/usr/local/webserver/Apache/bin/apxs -- With-config-file-Path =/usr/ local/webserver/PHP/etc -- With-mysql =/usr/local/webserver/mysq L -- With-mysqli =/usr/local/webserver/MySQL/bin/mysql_config -- With-iconv-Dir =/usr/local -- With-FreeType-dir -- With-JPEG- dir -- With-PNG-dir -- With-zlib -- With-libxml-Dir =/usr -- enable-XML -- disable-rpath -- enable-safe-mode -- enable-bcmath -- enable -shmop -- enable-sysvsem -- enable-inline-optimization -- With-curl -- With-curlwrappers -- enable-mbregex -- enable-mbstring -- With-mcrypt -- With-Gd -- enable-G D-native-TTF -- With-OpenSSL -- With-mhash -- enable-pcntl -- enable-sockets -- With-XMLRPC -- enable-zip -- enable-soap # Make zend_extra_libs = '-liconv '# make install # cp PHP. ini-development/usr/local/webserver/PHP/etc/PHP. INI # CD .. 3.3 install PHP extension module # tar zxvf memcache-2.2.5.tgz # cd memcache-2.2.5/#/usr/local/webserver/PHP/bin/phpize #. /configure -- With-PHP-Config =/usr/local/webserver/PHP/bin/PHP-config # m Ake # make install # CD .. # tar zxvf PDO_MYSQL-1.0.2.tgz # cd PDO_MYSQL-1.0.2/#/usr/local/webserver/PHP/bin/phpize #. /configure -- With-PHP-Config =/usr/local/webserver/PHP/bin/PHP-config -- With-PDO-mysql =/usr/local/webserver/MySQL # Make # Make install # CD .. /tar zxvf imagick-2.3.0.tgzcd imagick-2.3.0 // usr/local/webserver/PHP/bin/phpize. /configure -- With-PHP-Config =/usr/local/webserver/PHP/bin/PHP-con Figmakemake installcd .. /install xcache # tar zxvf xcache-1.3.0.tar.gz #/usr/local/webserver/PHP/bin/phpize #. /configure -- enable-xcache-coverager -- With-PHP-Config =/usr/local/webserver/PHP/bin/PHP-config # Make # make install # Cat xcache. INI>/usr/local/webserver/PHP/etc/PHP. INI begins to modify PHP. INI, make sure that xcache. so is loaded before any other zend_extension = *** statement. Find extension_dir and change it to extension_dir = "/usr/local/webserver/PHP/lib/PHP/extensions/no-debug-non-zts-20090626/" and add several lines of extension = "memcache below this line. so "extension =" pdo_mysql.so "extension =" imagick. so "add zend_extension =/usr/local/lib/PHP/extensions/non-debug-non-ZTS-xxx/xcache in [xcache-common. so comment to add a line under it zend_extension =/usr/local/webserver/PHP/lib/PHP/extensions/no-debug-non-zts-20090626/xcache. 4, integrating Apache and PHP

# Vi/usr/local/webserver/Apache/CONF/httpd. conf

Find <ifmodule dir_module> directoryindex index.html </ifmodule> and change it to <ifmodule dir_module> directoryindex index. for PHP index.html index.htm </ifmodule>, find addtype application/X-gzip. tgz adds a line of addtype application/X-httpd-PHP under it. phP5, create a virtual host for testing # vi/etc/hosts add two lines 127.0.0.1test.local127.0.0.1www.test.local Add a virtual host for Apache # cd/usr/local/webserver/Apache/CONF/extra/# vi the httpd-vhosts.conf first two configuration notes in the configuration file for demonstration Drop, add the following command <virtualhost *: 80> serveradmin greathqy@gmail.com DocumentRoot "/home/Eric/projects/PHP/testing" servername www. test. local errorlog "logs/testing-error_log" customlog "logs/testing-access_log" common <directory "/home/Eric/projects/PHP/testing"> options indexes followsymlinks AllowOverride all order deny, allow allow from all </directory> </virtualhost> Save and close 6, start Apache MySQL #/usr/local/Webs Erver/MySQL/bin/mysqld_safe -- defaults-file =/usr/local/webserver/MySQL/etc/My. CNF & #/usr/local/webserver/Apache/bin/apachectl-K start to/home/Eric/projects/PHP/testing to create a new file test. PHP input <? PHP phpinfo ()?> In the browser, input extensions and support such as Ghost, Gd, iconv, imagick, mbstring, memcache, mcrypt, MySQL, mysqli, PDO MySQL, xcache, and zip. You can try using PHP to link MySQL and change test. php to <? PHP
// Phpinfo ();

$ Handle = mysql_connect ("localhost", "root", "") or die ("Unable connect to MySQL ");

If ($ handle ){
Mysql_select_db ("test", $ handle) or die ("can't select DB ");
}

Echo "connected to MySQL <br/> ";

$ SQL = "CREATE TABLE if not exists 'user' ('username' varchar (50) not null, 'Password' varchar (32) not null) engine = MyISAM default charset = utf8 ";

Mysql_query ($ SQL, $ handle) or die ("can't query database ");

Echo "data table created ";

Echo mysql_info ();
?>

 

Save and refresh test. php. The output is connected to MySQL DATA table created.

 

So far, a lamp for the development environment is successfully configured.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.