搭建LAMP 筆記

  1. 下載源碼mysql-5.1.58.tar.gz,php-5.2.17.tar.gz ,httpd-2.2.19.tar.gz
  2. 首先安裝mysql (# 爲命令提示符)
  3. 先爲mysql建立用戶和組

#groupadd mysql php

#useradd -g mysql mysqlmysql

用戶和組建立好了,接下來是編譯安裝sql

#tar zxvf mysql-5.1.58.tar.gzshell

#cd mysql-5.1.58數據庫

./configure '--prefix=/opt/mysql5' ' 安裝路徑apache

--with-charset=utf8' ' 默認支持字符集vim

--with-extra-charsets=latin1,gbk' 擴展字符集瀏覽器

'--with-mysqld-user=mysql'安全

'--with-plugins=innodb_plugin,myisam,heap'
app

#make

#make install

#cp support-file/my-medium.cnf /etc/my.cnf //拷貝配置文件

#cd /opt/mysql5

#bin/mysql_install_db --user=mysql //安裝初始化數據庫

#chown -R root .

#chown -R mysql var

#chgrp -R mysql .

啓動mysql

#cp support-files/mysql.server /etc/init.d/mysqld //拷貝啓動腳本

#chmod +x /etc/init.d/mysqld

#cd /etc/init.d

#chkconfig --add mysqld

#/etc/init.d/mysqld start

編譯安裝apache

#tar zxvf httpd-2.2.19.tar.gz

#cd httpd-2.2.19 #編譯和安裝 apr 1.2
#cd srclib/apr
#./configure --prefix=/Data/apps/apr-httpd/
#make
#make install

# 編譯和安裝 apr-util 1.2
#cd ../apr-util
#./configure --prefix=/Data/apps/apr-util-httpd/ --with-apr=/Data/apps/apr-httpd/
#make
#make install

 

# ./configure

--prefix=/Data/apps/apache2

--with-apr=/Data/apps/apr-httpd

--with-apr-util=/Data/apps/apr-util-httpd

--enable-so --enable-rewrite

--enable-vhost-alias

--enable-deflate

--enable-expires

--with-mpm-prefork

#make

#make install

 

編譯安裝PHP

#tar zxvf php-5.2.17.tar.gz

#cd php-5.2.17

 

./configure'

'--prefix=/Data/apps/php/'

'--with-apxs2=/Data/apps/apache2/bin/apxs'

'--with-mysql=/opt/mysql5'

'--enable-mbstring' '--with-curl'

'--disable-debug'

'--enable-inline-optimization'

'--with-jpeg-dir=/usr/lib' (64)

'--with-png-dir=/usr/lib' (64)

'--enable-ctype'

'--with-bz2'

'--with-zlib'

'--with-gd'

'--with-freetype-dir=/usr/'

'--with-kerberos'

'--with-gettext'

'--enable-force-cgi-redirect'

'--with-iconv'

'--enable-gd-native-ttf'

'--enable-sockets'

'--enable-soap'

'--enable-ftp'

'--with-openssl'

'--enable-zip'

若是出現configure: error: libjpeg.(a|so) not found

執行

cp -frp /usr/lib64/libjpeg.* /usr/lib/

cp -frp /usr/lib64/libpng* /usr/lib/

解決 從新配置 #make

#make install

配置php.ini

#cp php.ini.dist /Data/apps/php/bin/php.ini

 

安裝APC 擴展庫

#tar zxvf APC-3.1.9.tgz

#cd APC-3.1.9

#/Data/apps/php/bin/phpize

# ./configure

--with-php-config=/Data/apps/php/bin/php-config

--enable-apc

--enable-apc-filehits

#make

#make install

安裝mcrypt

#tar zxvf libmcrypt-2.5.8.tar.gz

#cd libmcrypt-2.5.8

#./configure

#make

#make install

#ldconfig

#cd //PHP源碼包//

#cd ext/mcrypt

#/Data/apps/php/bin/phpize

#./configure --with-php-config=/Data/apps/php/bin/php-config

#make

#make install

編輯php.ini

更改extension_dir = "/Data/apps/php/lib/php/extensions/no-debug-non-zts-20060613/"
加入extension = "apc.so"
加入extension = "mcrypt.so"

更改include_path = ".:/Data/www/phplibs"

再增長一些安全設置

更改log_errors = On
更改error_log = "/var/log/php-error.log"
更改disable_functions = phpinfo,system,passthru,shell_exec,popen

 

配置httpd.conf

#vim /Data/apps/apache2/conf/httpd.conf

添加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

保存重啓apache

#/Data/apps/apache2/bin/apachectl restart

寫個網頁測試一下

<?php

phpinfo();

?>

保存後綴爲.php 文件

放在/Data/apps/apache2/htdocs 目錄下

瀏覽器訪問 http://IP 能看到PHP配置信息

相關文章
相關標籤/搜索