Compile and install LAMP

Source: Internet
Author: User
Tags php source code fully qualified domain name

Select Debian as the environment.

1. apache2

If you want Apache to run completely under the root user

# Vi ~ /. Bashrc

Export cflags = '-wall-dbig_security_hole '.

Modify the Apache configuration file after installation.

# Vi/usr/local/apache2/CONF/httpd. conf

Change user and group to root.

 

Install APR:

# Tar xvf httpd-2.2.15.tar.gz

# Cd httpd-2.2.15

# Cd srclib/APR

#./Configure -- prefix =/usr/local/APR

# Make

# Make install

# Make clean

# Make distclean

 

Install Apr-util:

# CD ../APR-util

#./Configure -- prefix =/usr/local/APR-util -- With-Apr =/usr/local/APR

# Make

# Make install

# Make clean

# Make distclean

 

Install Apache:

Finally install Apache

#. /Configure -- prefix =/usr/local/apache2 -- enable-mod-shared = all -- enable-cache -- enable-file-cache -- enable-mem-cache -- enable-disk- cache -- enable-static-support -- enable-static-htpasswd -- enable-static-htdigest -- enable-static-rotatelogs -- enable-static-logresolve -- enable-static-htdbm -- enable- static-AB -- enable-static-checkgid -- disable-cgi -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enable-dav -- enable-so

If you are prompted that the apr-util version is too low, it may be that your Linux release has a built-in apr library, so you can uninstall your own installed apr and apr-util libraries, and -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util in apache configuration parameters, change to -- with-defined ded-apr and -- with-defined ded-apr-util.

If there is a problem with zlib during compilation, install zlib according to the default path/usr/local.

Ubuntu with sudo apt-get install zlib1g-dev

# Make

# Make install

# Make clean

# Make distclean

# Vi/etc/rc. local

Add/usr/local/apache2/bin/apachectl start before exit 0

 

If an error occurs:

/Usr/lib/libexpat. so: cocould not read symbols: File in wrong format

Solution:

When compiling, add the compilation parameter -- with-expat = builtin. It seems that there are some problems when compiling scripts on a 64-bit server to locate the system's expat support. By specifying expat and using the expat provided by the system for compilation, this problem does not exist.

Test

 

/Usr/local/apache2/bin/apachectl start if an error occurs.

Httpd: cocould not reliably determine the server's fully qualified domain name, using 192.168.1.201 for ServerName

Modify the apache configuration file

# Vi/usr/local/apache2/conf/httpd. conf

Find ServerName localhost: 80 and cancel the comment.

------------------------------------------------------------------------------- Apache installation completed ------------------------------------------------------------------------------

2. Install MySQL

# Tar-zxvf mysql-5.1.30.tar.gz

# Cd mysql-5.1.30

# Groupadd-r mysql // Add a mysql user group

# Useradd-m-r-g mysql-d/var/lib/mysql-s/bin/bash-c "MySQL Server" mysql // Add a mysql user

#./Configure -- prefix =/usr/local/mysql -- sysconfdir =/etc -- localstatedir =/var/lib/mysql -- enable-local-infile

Debian: Check for termcap functions library... configure: error: No curses/termcap library found

# Apt-get install libncurses5-dev installation.

# Make

If do_abi_check error occurs,

# Vi Makefile: Comment out all the statements after do_abi_check and make again

# Make

# Make install

# Make clean

# Make distclean

# Cd/usr/local/mysql

#/Bin/mysql_install_db // initialize the system database

# Ls/var/lib/mysql // view the directory content in the database

# Chown-R mysql: mysql/var/lib/mysql // modify the database directory owner

# Cp/usr/local/mysql/share/mysql/my-large.cnf/etc/my. cnf // This file is already available after normal installation, you do not need to copy

# Cp/usr/local/mysql/share/mysql. server/etc/init. d/mysql copy to generate the automatic and stop scripts for the Linux Mysql server

# Chkconfig -- list | grep mysql // query whether the mysql service exists.

# Chkconfig -- add mysql // add mysql service to Server Management

If insserv: FATAL: service network is missed in the runlevels XXX to use service

According to Google's results:

Actual Results:

In default configuration, mysql cannot be enabled as a service to start at boot

Expected Results:

Shocould be able to enable mysql service

Use the following methods:

# Vi/etc/init. d/mysql

Comment out Default-Start.

Then

# Chkconfig -- add mysql

# Chkconfig -- list | grep mysql // query the startup status of the mysql server.

# Chkconfig -- level 35 mysql on // It is set to be self-started at the runtime level of 3 and 5

# Service mysql start or/etc/init. d/mysql start

If the mysql command cannot be used normally

# Vi ~ /. Bashrc

Add alias MySQL = '/usr/local/MySQL/bin/mysql'

 

When compiling the PHP source code, some MySQL library files and header files will be used. If the server still needs to provide PHP dynamic web services, the corresponding files will not be found, the solution is to create a symbolic connection for the directory. The operation commands are as follows:

 

# Ln-S/usr/local/MySQL/lib/MySQL/usr/lib/MySQL

 

# Ln-S/usr/local/MySQL/include/MySQL/usr/include/MySQL


Starting mysql. Manager of PID-file quit without updating fi [failed] the solution is to comment out the Skip federated in/etc/My. CNF.

------------------------------------------------------------------------------- Apache installation completed ------------------------------------------------------------------------------

3. install PHP

Install the iis8 Library

# Tar-xvf restart src.v8b.tar.gz

# Cd jpeg-8b

#./Configure -- prefix =/usr/local/route 8/-- enable-shared -- enable-static

# Make

# Make install

# Make clean

# Make disclean


Install libpng library

# Tar-xvf libpng-1.2.42.tar.gz

# Cd libpng-1.2.42

#./Configure

# Make

# Make install

# Make clean

# Make distclean


Install freetype Library

# Tar-xvf freetype-2.3.12.tar.gz

# Cd freetype-2.3.12

#./Configure -- prefix =/usr/local/freetype

# Make

# Make install

# Make clean

# Make distclean


Install the gd library

# Tar-xvf gd-2.0.35.tar.gz

# Cd gd-2.0.35

#. /Configure -- prefix =/usr/local/gd2 -- with-jpeg =/usr/local/release 8/-- with-png -- with-zlib -- with-freetype =/usr/local /freetype/

# Make

# Make install

# Make clean

# Make distclean


Install php

# Tar-xvf php-5.2.13.tar.gz

# Cd php-5.2.13

Install unixODBC to/usr/local/unixODBC #. /configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache2/bin/apxs -- with-pear =/usr/share/php -- with-zlib- dir -- with-bz2 -- with-libxml-dir -- with-gd =/usr/local/gd2 -- enable-gd-native-ttf -- enable-gd-jis-conv -- with-freetype -dir =/usr/local/freetype -- with-jpeg-dir =/usr/local/defaults 8 -- with-png-dir -- enable-mbstring -- with-unixODBC =/usr/ local/unixODBC -- with-config-file-path =/etc -- with-iconv -- disable-ipv6 -- enable-static -- enable-maintainer-zts -- enable-zend-multibyte -- enable-inline -optimization -- enable-zend-multibyte -- enable-sockets -- enable-soap -- mysql-with =/usr/local/mysql

If a problem occurs in BZip2, recompile and install bzip2 by default.

# Make

# Make install

Modify php configurations

# Vim php. ini-recommended

Find register_globals = Off and change it to: register_globals = On.

Find short_open_tag = off and change it to: short_open_tag = on

Locate error_reporting = e_all and change it to error_reporting = e_all &~ E_notice

Locate date. timezone =, and add Asia/Chongqing.

Finally, copy PHP. ini-recommanded to/etc/PHP. ini.

If the installed version is 5.3.x, the PHP configuration file also becomes PHP. ini-development in addition to the above directory name becoming php-5.3.X


If an error occurs during PHP make: libbz2.a needs to re-Add the parameter-FPIC to compile

# Tar-xvf bzip2-1.0.5.tar.gz

# Cd bzip2-1.0.5

# Make clean

# Vim makefile

Locate cflags and add-FPIC

# Make

# Make install


Integrate Apache with PHP

# Vi/usr/local/apache2/CONF/httpd. conf

Add the following to the last line:

Addtype application/X-httpd-PHP. php

Search: (set the Web default file)

Directoryindex index.html

Replace:

DirectoryIndex index. php index.html index.htm // if the default file is not found in the WEB directory, httpd will execute/var/www/error/noindex.html

Find this section:

# AllowOverride controls what directives may be placed in. htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride none

Change to AllowOverride all (apache rewrite allowed)

Save httpd. conf and exit.

#/Usr/local/apache2/bin/apachectl restart // restart Apache




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.