Ubuntu 上编译部署LAMP

httpd-2.2.27
mysql-5.6.10
php-5.4.31



1、安装一些需要的包
sudo apt-get install gcc g++ cpp libncurses5-dev make libssl-dev sysv-rc-conf
sudo apt-get install bison libbz2-dev libcurl3-openssl-dev libjpeg62-dev libpng12-dev libxpm-dev
sudo apt-get install libfreetype6-dev libgmp3-dev libmcrypt-dev libmhash-dev libpspell-dev libsnmp9-dev libmm-dev libtidy-dev libxml2-dev

将apache、mysql、php放在/home/sunzhijie/tool目录中
2、安装apache
mkdir /home/sunzhijie/software/apache
cd /home/sunzhijie/tool/httpd-2.2.27/srclib/apr
./configure --prefix=/home/sunzhijie/software/apache/apr
make
make install

cd /home/sunzhijie/tool/httpd-2.2.27/apr-util/
./configure --prefix=/home/sunzhijie/software/apache/apr-util --with-apr=/home/sunzhijie/software/apache/apr
make
make install


cd /home/sunzhijie/tool/httpd-2.2.27
./configure --prefix=/home/sunzhijie/software/apache --enable-mods-shared=all --with-mysql=/home/sunzhijie/software/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache  --with-apr=/home/sunzhijie/software/apache/apr --with-apr-util=/home/sunzhijie/software/apache/apr-util --enable-rewrite --enable-vhost-alias --with-mpm=prefork --with-ssl --disable-ipv6
make
make install

3、安装mysql
cd
创建用户组mysql
sudo groupadd mysql
在用户组mysql下,创建mysql用户
sudo useradd -g mysql mysql


sudo apt-get install build-essential libncurses5-dev cmake

sudo cmake -DCMAKE_INSTALL_PREFIX=/home/sunzhijie/software/mysql  -DMYSQL_UNIX_ADDR=/home/sunzhijie/software/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/home/sunzhijie/software/mysql/data

sudo make
sudo make install

mysql初始化安装
./scripts/mysql_install_db --defaults-file=/home/sunzhijie/software/mysql/my.cnf --basedir=/home/sunzhijie/software/mysql/ --datadir=/home/sunzhijie/software/mysql/data/ --user=mysql --no-defaults

将/home/sunzhijie/software/mysql/my.cnf修改为:
[mysqld]
basedir=/home/sunzhijie/software/mysql
datadir=/home/sunzhijie/software/mysql/data
user=mysql
pid-file = /home/sunzhijie/software/mysql/mysql.pid

建立mysql.pid
cd /home/sunzhijie/software/mysql
touch mysql.pid
cd /home/sunzhijie/software/mysql
sudo chown -R mysql:mysql mysql

启动mysql
sudo service mysql start  


4、安装php

./configure --prefix=/home/sunzhijie/software/php_5.4.31 --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --enable-mbstring --enable-shmop --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-zip --with-apxs2=/home/sunzhijie/software/apache/bin/apxs --with-bz2 --with-curl --with-freetype-dir --with-gd --with-gettext --with-gmp --with-jpeg-dir --with-libxml-dir --with-mcrypt --with-mhash --with-mm --with-mysql-sock=/home/sunzhijie/software/mysql/mysql.sock --with-mysql=/home/sunzhijie/software/mysql --with-mysqli=/home/sunzhijie/software/mysql/bin/mysql_config --with-openssl --with-openssl-dir --with-pdo-mysql --with-png-dir --with-pspell --with-snmp --with-tllib --with-tidy --with-ttf --with-xpm-dir --with-zlib --with-zlib-dir


提示错误:configure: error: Please reinstall the BZip2 distribution
wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
tar zxvf bzip2-1.0.5.tar.gz
make
make install

提示错误:configure: error: Please reinstall the libcurl distribution -easy.h should be in /include/curl/
sudo apt-get install curl
sudo apt-get install libcurl4-gnutls-dev

提示错误:configure: error: jpeglib.h not found
sudo apt-get install libjpeg-dev

错误提示:configure: error: png.h not found
sudo apt-get install libpng-dev

错误提示:configure: error: libXpm.(a|so) not found.
sudo apt-get  install libxpm-dev
上述方法无效时
sudo find / -name *libXpm* > /home/sunzhijie/result.txt
查询libXpm安装在哪里,并将其软链接到/usr/lib下,一般./configure默认到/usr/lib下寻找库;

错误提示:PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
wget http://pear.php.net/go-pear.phar
#php go-pear.phar

5、配置php
cp ./php.ini-development(php源码中) /home/sunzhijie/software/php_5.4.31/php.ini

6、修改apache 支持 php
找到安装apache 路径/home/sunzhijie/software/apache/conf/httpd.conf
在 原有 AddType 下 增加

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

7、测试
/home/sunzhijie/software/apache/htdocs中创建php文件测试即可。

你可能感兴趣的:(Ubuntu 上编译部署LAMP)