Debian 7.9 编译安装LAMP环境 Apache 2.2 + Mysql 5.5.48 +PHP 5.6.19

编译环境安装

apt-get install build-essential
apt-get install libtool

默认路径使用 /data0

安装cmake

wget https://cmake.org/files/v3.5/cmake-3.5.0-rc3.tar.gz

tar -zxvf cmake-3.5.0-rc3.tar.gz

cd cmake-3.5.0-rc3

./configure

make && make install

 

安装zlib

wget http://zlib.net/zlib-1.2.8.tar.gz

tar -zxvf zlib-1.2.8.tar.gz && cd zlib-1.2.8.tar.gz

./configure

make && make install

 

 

Apache 2.2 安装配置

下载apr && apr-util进行编译安装

#apr-1.5.2

wget http://apache.opencas.org//apr/apr-1.5.2.tar.gz

tar -zxvf apr-1.5.2.tar.gz && cd apr-1.5.2

./configure

make && make install

#apr-util-1.5.4

wget http://apache.opencas.org//apr/apr-util-1.5.4.tar.gz

tar -zxvf apr-util-1.5.4.tar.gz && cd apr-util-1.5.4

./configure --with-apr=/usr/local/apr

make && make install

#openssl-1.0.1s

wget http://www.openssl.org/source/openssl-1.0.1s.tar.gz

./configure

make && make install

ln -s /usr/local/ssl/bin/openssl /etc/init.d/openssl

 

下载apache2.2进行编译安装

wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.2.31.tar.gz

tar -zxvf httpd-2.2.31.tar.gz

cd httpd-2.2.31

./configure --enable-module=so --enable-module=rewrite --enable-module=ssl --with-ssl=/usr/local/ssl/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/

make

make install

 

apache2.2 配置

网站文档目录 /data0/wwwroot

mkdir /data0/wwwroot

查看网页用户和用户组(默认用户和组为:www-data)

less /etc/passwd

修改网站目录所属的用户和组为www-data

chown -R www-data:www-data /data0/wwwroot

复制默认主页index.html到自定义目录

cp /usr/local/apache2/htdocs/index.html /data0/wwwroot

修改文档目录权限

chmod -R 755 /data0/wwwroot

修改apache 配置文件httpd.conf

vi /usr/local/apache2/conf/httpd.conf

配置文件修改:

第88行:ServerAdmin you@example.com 改为你的 email
第97行:#ServerName www.example.com:80 改为你的域名,并且去掉“#”号,”:80”可以去掉
第104行:DocumentRoot “/usr/local/apache2/htdocs” 改为:DocumentRoot “/data0/www”
第131行:<Directory “/usr/local/apache2/htdocs”> 改为:<Directory “/data0/www”>

 添加apache2 软连接到/etc/init.d/apache2:

ln -s /usr/local/apache2/bin/apachectl /etc/init.d/apache2

启动apache2服务

/etc/init.d/apache2 start

访问测试

curl localhost 查看回显或直接浏览器访问网站

 

MySQL-5.5.48编译安装

#ncurses

wget ftp://invisible-island.net/ncurses/ncurses.tar.gz

tar -zxvf ncurses.tar.gz && cd ncurses

./configure

make && make install

#MySQL-5.5.48 Install

wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.48.tar.gz

tar -zxvf mysql-5.5.48.tar.gz && cd mysql-5.5.48

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data0/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1

make && make install

安装完成

#添加mysql用户用于数据库访问

groupadd mysql

useradd -r -g mysql -s /bin/false mysql

配置目录权限

程序目录

chown -R mysql:mysql /usr/local/mysql

数据库目录

chown -R mysql:mysql /data0/mysql/data

#配置MySQL

cd /usr/local/mysql

chown -R mysql .

chgrp -R mysql .

scripts-files/mysql_install_db --user=mysql

chown -R root .

chown -R mysql data

cp support-files/my-medium.cnf /etc/my.cnf

./mysqld_safe --user=mysql &

cp support-files/mysql.server /etc/init.d/mysql.server

 

 # echo "/usr/local/mysql/bin/safe_mysqld --user=mysql &" >> /etc/rc.local

 # echo "PATH=$PATH:/usr/local/mysql/bin;export PATH" >> /etc/profile
# source /etc/profile

 

 

#PHP 安装配置

#Install Library

#libxml2 libpng libjpeg libmcrypt4 libmhash2

apt-get install libxml2 libpng12-dev libjpeg8 mcrypt

#libcurl

wget -c https://curl.haxx.se/download/curl-7.47.1.tar.gz

tar -zxvf curl-7.47.1.tar.gz && cd curl-7.47.1

./configure --prefix=/usr/local/curl

make && make install

#Complie PHP

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/local/lib --with-zlib-dir=/usr/local/lib --with-mysql=/usr/local/mysql --with-gd --enable-soap --enable-sockets  --enable-xml --enable-mbstring --with-png-dir=/usr/local/lib --with-curl=/usr/local/curl --enable-bcmath --enable-calendar --enable-zip --enable-maintainer-zts

make

make test

make install

#复制php配置文件到php目录中

cp php.ini-production /usr/local/php5/lib/php.ini

 

#编辑apache配置文件加入php支持

cd /usr/local/apache2/conf

vi httpd.conf

加入:AddType application/x-httpd-php .php

找到DirectoryIndex index.html修改为DirectoryIndex index.php default.php index.html index.htm default.htm default.html

 

重启apache

/etc/init.d/apache2 restart

 

在网站目录中新建一个 info.php

<?php

phpinfo();

?>

访问info.php 查看配置状态是否正常显示。

 

关于数据库访问。可使用第三方客户端远程访问或者下载phpmyadmin

https://files.phpmyadmin.net/phpMyAdmin/4.5.5.1/phpMyAdmin-4.5.5.1-all-languages.zip

 

 

 

参考文章:

http://www.linuxde.net/2011/11/1656.html

http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html

http://www.jb51.net/article/54969.htm

posted @ 2016-03-11 18:01  My_Jin  阅读(875)  评论(0编辑  收藏  举报