Debian 7.9 編譯安裝LAMP環境 Apache 2.2 + Mysql 5.5.48 +PHP 5.6.19

編譯環境安裝php

apt-get install build-essential
apt-get install libtoolhtml

默認路徑使用 /data0mysql

安裝cmakelinux

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

tar -zxvf cmake-3.5.0-rc3.tar.gz數據庫

cd cmake-3.5.0-rc3apache

./configure瀏覽器

make && make installapp

 

安裝zlibless

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

相關文章
相關標籤/搜索