本文主要是介绍Ubuntu14.04LTS(64)编译安装lamp环境,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.首先检查安装的编译工具
C编译器,C++编译器,make
检查软件是否安装命令:
dpkg -l | grep gcc #检查C
dpkg -l | grep g++ #检查C++
dpkg -l | grep make #检查make
2.检查是否已经有默认安装的软件(apache,mysql,php)
如果安装就先卸载
apt-get remove -purge apache #卸载apache
dpkg -r apache.deb
apt-get remove -purge mysql #卸载mysql
dpkg -r mysql.deb
apt-get remove -purge php #卸载php
dpkg -r php.deb
3.文件下载
下载完成后请保存在
http://pan.baidu.com/s/1qWTcFyW
/usr/local/src/目录下
4.编译安装libxml2(主要是用在php LibXml函数)
cd /usr/local/src
tar -zvxf libxml2-2.9.0.tar.gz
cd libxml2-2.9.0
./configure -prefix=/usr/local/libxml2
make && make install
5.编译安装libmcrypt(libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法)
cd /usr/local/src
tar -zvxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make && make install
6.编译安装zlib(zlib类库提供了很多种压缩和解压缩的方式)
cd /usr/local/src
tar -zvxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure #不需要指定安装路径
make && make install
7.安装libpng(主要用来读写png图片文件)
cd /usr/local/src
tar -zvxf libpng-1.6.7.tar.gz
cd libpng-1.6.7
./configure --prefix=/usr/local/libpng
make && make install
8.安装jpeg6(使php可以支持jpeg)
cd /usr/local/src
tar -zvxf jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure
make && make install
9.安装freetype(完全免费(开源)的、高质量的且可移植的字体引擎)
cd /usr/local/src
tar -zvxf freetype-2.4.10.tar.gz
cd freetype-2.4.10
./configure --prefix=/usr/local/freetype
make && make install
10.安装autoconf
需要安装m4
cd /usr/local/src
tar -zvxf m4-1.4.9.tar.gz
cd m4-1.4.9./configure
make && make install
cd /usr/local/src
tar -zvxf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure
make && make install
11.安装gd库
cd /usr/local/src
tar -zvxf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
make && make install
如果找不到png库
找到/usr/local/gd-2.0.33/gd_png.c文件并修改
找到#include "png.h"
修改为#include "/usr/local/libpng/include/png.h"
然后重新编译
12.安装apr
cd /usr/local/src
tar -zvxf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr --enable-threads --enable-other-child USE=ipv6
make && make install
13.安装apr-util
cd /usr/local/src
tar -zvxf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make && make install
14.安装pcre
cd /usr/local/src
unzip pcre-8.10.zip
cd pcre-8.10
./configure --prefix=/usr/local/pcre --enable-so --enable-rewrite
make && make install
编译可能会出错,执行
sudo apt-get install build-essential
然后重新编译
15.安装Apache服务器
cd /usr/local/src
tar -zvxf httpd-2.4.20.tar.gz
cd httpd-2.4.20
./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make && make install
启用apache服务
cp /usr/local/apache/bin/apachectl /sbin/
vim /usr/local/apache/conf/httpd.conf
把ServerName www.example.com:80 前的注释去掉
apachectl start
netstat -tnl | grep 80
16.安装mysql数据库
cd /usr/local/src
tar -zvxf mysql-5.0.56.tar.gz
cd mysql-5.0.56
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=complex --localstatedir=/usr/local/mysql/data --sysconfdir=/usr/local/mysql/etc --with-mysqld-user=mysql --with-unix-socket-path=/usr/local/mysql/var/mysql.sock
make && make install
创建配置文件
cp support-files/my-medium.cnf /etc/my.cnf
启动mysql服务
bin/mysql_safe --user=mysql&
netstat -tnl | grep 3306
配置mysql服务
cp support-files/mysql.server /etc/init.d/mysql
sudo update-rc.d mysql defaults
chkconfig --add mysql
chkconfig mysql on
用户账户控制
bin/mysql -uroot
mysql> DELETE mysql.user WHERE Host='localhost'AND User='';
mysql>SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');
启动报错:无法启动Couldn't find MySQL server (/usr/bin/mysqld_safe)”
sudo rm /etc/mysql/my.cnf
17.安装php
cd /usr/local/src
tar -jvxf php-5.4.38.tar.bz2
cd php-5.4.38
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd2 --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-mbstring=all --enable-sockets
make && make install
因为安装的是php5.4 可能会出现一个问题
修改gd库/usr/local/gd2/include/gd_io.h
在gdlOCtx结构中添加void *data;
格式如下:
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}
gdIOCtx;
创建PHP配置文件
cp php.ini-development /usr/local/php/etc/php.ini
修改apache对php的支持
vi /usr/local/apache/conf/httpd.conf
Addtype application/x-httpd-php .php .html
sudo apachectl -k restart
修改web根目录为/var/WWW目录
找到DocumentRoot 并修改后面的路径 "/var/WWW/"
找到Directory 并修改后面的路径 "/var/WWW/"
并把入口文件修改
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
在/var/www目录下新建一个文件01.php
<?php
phpinfo();
?>
然后访问localhost/01.php
就会出现php信息。安装成功!
这篇关于Ubuntu14.04LTS(64)编译安装lamp环境的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!