linux下源码包编译安装LAMP环境
1、 下载所需的源码包
Httpd-2.4.10 apr-1.5.1 apr-util-1.5.3 pcre-8.33(这些均可在Apache官网进行下载)
Mysql-5.5.39 php-5.6.0
2、 解压这些压缩包(以上包均为.tar.gz版本的)
使用命令 tar –zxvf 安装包名 –C /usr/local/src (这里统一解压到该目录下)
3、 编译Apache部分
(1).安装apache依赖包pcre
# cd ./pcre-8.33
# ./configure --prefix=/usr/local/pcre
# make
#make install
(2).安装openssl
# yum -y install openssl-devel
(3).移动apr和apr-util到httpd-2.4.10文件夹下srclib内并且重命名
# mv apr-1.5.1/httpd-2.4.3/srclib/apr 移动并需改名字
# mv apr-util-1.5.3/httpd-2.4.10/srclib/apr-util
(4).安装Apache 2.4.10主程序
# cd ./httpd-2.4.10
#./configure --prefix=/usr/local/apache --enable-so --enable-deflate=shared --enable-ssl=shared --enable-expires=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support --with-included-apr --with-mpm=prefork --enable-cache --enable-file-cache --with-pcre=/usr/local/pcre
# make && make install
(5).基本配置让apache自启动。
修改httpd.conf,wq保存退出
# vim /usr/local/apache/conf/httpd.conf
找到“#ServerName www.example.com:80”,在下面加上这一行
加入配置文件实现自启动
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# vim /etc/init.d/httpd
在#!/bin/sh 下面加上这两行,wq保存退出
# chkconfig: 345 90 90
# description: Apache
# chkconfig --add httpd
# service httpd start
到此在浏览器地址栏输入你的IP地址将会显示it works
4、编译mysql-5.5.39
(1).安装cmake (因为新版的mysql必须要用cmake)
# yum -y install cmake make
安装一些其他应用
# yum -y install autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
(3).安装mysql 5.5.39主程序
# cd mysql-5.5.8
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFIGDIR=/usr/local/mysql/etc-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql
# make
#make install
(4).配置mysql 5.5. 39
1. #groupadd mysql
2. #useradd -d /var/lib/mysql -s /bin/bash -g mysql mysql
3. chown -R mysql /usr/local/mysql
4. #chgrp -R mysql /usr/local/mysql
#cp /usr/loacl/mysql/support-files/my-huge.cnf etc/my.cnf
# vim /etc/my.cnf
以下命令为mysql 启动及自启动配置
# cp /usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
#/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
#chkconfig --add mysqld
#chkconfig --level 345 mysqld on
# ln -s /usr/local/mysql/bin/mysql /bin/mysql 创建一个软链接,避免每次启动输入很长的路径
# service mysqld start
(5)设置mysql密码
使用命令 mysql –u root –p 进入数据库
mysql>;USE mysql;
mysql>;UPDATE user SET Password=PASSWORD(‘wangA500821.‘) WHERE user=‘root‘;
mysql>;FLUSH PRIVILEGES;
(6)设置允许远程登录
mysql -uroot -p
EnterPassword: <your new password>
mysql>GRANTALL PRIVILEGES ON *.* TO ‘用户名‘@‘%‘IDENTIFIEDBY ‘密码‘ WITH GRANT OPTION;
完成后就能用mysql-front远程管理mysql了
5、 编译php-5.6.0
(1)安装相关资源及依赖包
# yum –y install bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel
(2)安装php 5.6.0程序
# vim/usr/local/apache/bin/apxs
把#!/replace/with/path/to/perl/interpreter -w 这一行(一般是第一行)更改为"#!/usr/bin/perl -w"。
# cd php-5.46.0
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/include/libxml2 --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-gd-native-ttf --with-zlib --with-mcrypt --with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm --enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/
# make && make install
6、 整理lamp
(1)php配置,编译安装时我的php.ini文件目录指向/usr/local/apache/conf
# cd php-5.6.0
# cpphp.ini-production /usr/local/apache/conf/php.ini
(2).apache配置文件httpd.conf相关修改以支持PHP
# vim /usr/local/apache/conf/httpd.conf
添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
保存httpd.conf配置,然后再执行以下两行命令
# chown -R nobody. /usr/local/apache/htdocs/
# chmod -R 777 /usr/local/apache/htdocs/
# service httpdrestart
7、测试
我在/usr/local/apache/htdocs新建了一个info.php
<?phpphpinfo();?>
在浏览器地址栏输入154.87.1.127/info.php运行了下
8、测试php和mysql的连通性
在/usr/local/apache/htdocs下创建index.php 内容是
<?php
$link=MySQL_connect(‘localhost‘,‘root‘,‘wangA500821.‘);
if(!$link) echo"Error !";
else echo"Ok!";
MySQL_close();
?>
在在浏览器地址栏输入154.87.1.127/index.php,正确则显示ok
本文出自 “WXL博客” 博客,请务必保留此出处http://ddwxl.blog.51cto.com/9480879/1564472
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。