搭建LAMP架构
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建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源码包下载链接:
安装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架构的主要内容,如果未能解决你的问题,请参考以下文章