搭建LAMP架構
環境:linux、httpd-2.2、mysql-5.5、php-5.3
1、源碼包編譯安裝需要的包:
[[email protected]_158_68_centoshttpd-2.2.17]# yum -y install gcc gcc-c++ make zlib-devel
2、檢查系統有沒有裝httpd rpm包:
[[email protected]_158_68_centos ~]# rpm -qa|grep httpd
[[email protected]_158_68_centos ~]#
3、源碼編譯安裝apache:
....下載httpd源碼包:
....解壓、配置、編譯、安裝:
[[email protected]_158_68_centos~]# tar xf httpd-2.2.17.tar.gz -C /usr/src
[[email protected]_158_68_centos ~]# cd /usr/src/httpd-2.2.17/
[[email protected]_158_68_centoshttpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-cgi --enable-so--enable-charset-lite --enable-deflate--enable-expires --enable-rewrite
[[email protected]_158_68_centos httpd-2.2.17]# make && make install
4、查看有沒有安裝成功:
[[email protected]_158_68_centos httpd-2.2.17]# ls /usr/local/httpd/
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
5、創建軟連接、並查看:
[[email protected]_158_68_centoshttpd-2.2.17]# ln -s /usr/local/httpd/bin/* /usr/local/bin/
[[email protected]_158_68_centos httpd-2.2.17]# ll /usr/local/bin
6、建立配置文件
[[email protected]_158_68_centos httpd-2.2.17]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[[email protected]_158_68_centoshttpd-2.2.17]# chmod +x /etc/init.d/httpd
[[email protected]_158_68_centos httpd-2.2.17]# sed -i -e ‘1a#chkconfig: 35 85 21‘ /etc/init.d/httpd
[[email protected]_158_68_centos httpd-2.2.17]# chkconfig --add httpd
[[email protected]_158_68_centos httpd-2.2.17]# chkconfig --list httpd
7、啟動http服務
[[email protected]_158_68_centoshttpd-2.2.17]# service httpd start
8、查看是否開啟80端口
[[email protected]_158_68_centoshttpd-2.2.17]# netstat -atnpl|grep httpd
9、編譯安裝cmake
[[email protected]_158_68_centos~]# tar xf cmake-2.8.6.tar.gz -C /usr/src
[[email protected]_158_68_centos~]# cd /usr/src/cmake-2.8.6/
[[email protected]_158_68_centos~]# ./configure && make && make install
10、編譯安裝MySQL
.......先安裝ncurses-devel 庫:[[email protected]_158_68_centos~]# yum -y install ncurses-devel
[[email protected]_158_68_centos ~]#useradd -M -s /sbin/nologin mysql
[[email protected]_158_68_centos ~]# tar xf mysql-5.5.22.tar.gz -C /usr/src/
[[email protected]_158_68_centos ~]#cd /usr/src/mysql-5.5.22/
[[email protected]_158_68_centos mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
[[email protected]_158_68_centos mysql-5.5.22]#make && make install
......更改屬主屬組:
[[email protected]_158_68_centosmysql-5.5.22]# chown -R mysql:mysql /usr/local/mysql/
.....創建配置文件:
[[email protected]_158_68_centosmysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf
.....初始化數據庫:
[[email protected]_158_68_centosmysql-5.5.22]# /usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/ \
> --datadir=/usr/local/mysql/data --user=mysql
[[email protected]_158_68_centosmysql-5.5.22]# ls /usr/local/mysql/data/
[[email protected]_158_68_centosmysql-5.5.22]# ln -s /usr/local/mysql/bin/* /usr/local/bin
.....添加為系統:
[[email protected]_158_68_centos mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected]_158_68_centosmysql-5.5.22]# chmod +x /etc/init.d/mysqld
[[email protected]_158_68_centosmysql-5.5.22]# chkconfig --add mysqld
[[email protected]_158_68_centosmysql-5.5.22]# chkconfig --list mysqld
.....啟動數據庫:
[[email protected]_158_68_centosmysql-5.5.22]# /etc/init.d/mysqld start
[[email protected]_158_68_centosmysql-5.5.22]# netstat -atnpl|grep mysqld
.....登錄數據庫:
[[email protected]_158_68_centosmysql-5.5.22]# mysql -u root
....創建數據庫賬戶和密碼:
[[email protected]_158_68_centosmysql-5.5.22]# mysqladmin -u root password ‘123123‘
.....驗證登錄:
[[email protected]_158_68_centosmysql-5.5.22]# mysql -uroot -p‘123123‘
11、編譯安裝php(mcrypt加密、支持gif、png、gd、jpeg類型文件、):
[[email protected]_158_68_centos libmcrypt-2.5.8]# yum -y install libxml2-devel
[[email protected]_158_68_centos ~]# tar xflibmcrypt-2.5.8.tar.gz -C /usr/src
[[email protected]_158_68_centos ~]# cd/usr/src/libmcrypt-2.5.8
[[email protected]_158_68_centos libmcrypt-2.5.8]#./configure && make && make install
[[email protected]_158_68_centoslibmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt* /usr/lib
......mhash安裝:
[[email protected]_158_68_centos ~]# tar xfmhash-0.9.9.9.tar.gz -C /usr/src
[[email protected]_158_68_centos ~]# cd/usr/src/mhash-0.9.9.9/
[[email protected]_158_68_centos mhash-0.9.9.9]#./configure && make &&make install
[[email protected]_158_68_centos mhash-0.9.9.9]#ln -s /usr/local/lib/libmhash.* /usr/lib
Mcrypt安裝:
[[email protected]_158_68_centos ~]# tar xfmcrypt-2.6.8.tar.gz -C /usr/src/
[[email protected]_158_68_centos ~]# cd /usr/src/mcrypt-2.6.8/
[[email protected]_158_68_centos libmcrypt-2.5.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[[email protected]_158_68_centos mcrypt-2.6.8]#./configure && make && make install
[[email protected]_158_68_centos ~]# tar xf php-5.3.28.tar.gz -C /usr/src
[[email protected]_158_68_centos ~]# cd /usr/src/php-5.3.28/
[[email protected]_158_68_centos php-5.3.28]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-mcrypt --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring --with-gd --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/png/
[[email protected]_158_68_centos php-5.3.28]#make && make install
[[email protected]_158_68_centos php-5.3.28]# cpphp.ini-development /usr/local/php5/php.ini
[[email protected]_158_68_centos php-5.3.28]# awk‘/^short_open_tag/{print NR,$0}‘ /usr/local/php5/php.ini
[[email protected]_158_68_centos php-5.3.28]# sed-i ‘226 s/Off/On/‘ /usr/local/php5/php.ini
[[email protected]_158_68_centos php-5.3.28]# awk‘ /default_charset/{print NR,$0}‘ /usr/local/php5/php.ini
[[email protected]_158_68_centos php-5.3.28]# sed -i -e ‘784 s/;// ; s/iso-8859-1/utf-8/‘ /usr/local/php5/php.ini
php優化模塊:
[[email protected]_158_68_centos ~]# tar xf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz –C /usr/src
[[email protected]_158_68_centos~]#cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/
[[email protected]_158_68_centos php-5.3.x]# cpZendGuardLoader.so /usr/local/php5/lib/php/
[[email protected]_158_68_centos php-5.3.x]# echo -e ‘zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so\nzend_loader.enable=1‘ >> /usr/local/php5/php.ini
修改Apache配置文件讓支持php。
[[email protected]_158_68_centos ~]# awk ‘/LoadModule php5_module/{print NR,$0}‘ /usr/local/httpd/conf/httpd.conf
[[email protected]_158_68_centos ~]# sed -i ‘53aAddType application/x-httpd-php .php‘ /usr/local/httpd/conf/httpd.conf
[[email protected]_158_68_centos ~]# awk ‘/DirectoryIndex/{print NR,$0}‘ /usr/local/httpd/conf/httpd.conf
[[email protected]_158_68_centos ~]# sed -i ‘168s/$/ index.php/‘ /usr/local/httpd/conf/httpd.conf
[[email protected]_158_68_centos ~]# httpd –t
[[email protected]_158_68_centos ~]#/etc/init.d/httpd restart
LAMP架構搭建完成:
Php源碼包下載鏈接:
http://php.net/releases/
安裝png、jpeg報錯的解決方法:
http://ixdba.blog.51cto.com/2895551/526435/
安裝gd報錯解決方法(打開連接最下面是)
http://blog.csdn.net/avilifans/article/details/16821017
本文出自 “13271352” 博客,請務必保留此出處http://13281352.blog.51cto.com/13271352/1967292
搭建LAMP架構