网站建设资讯

NEWS

网站建设资讯

企业LAMP+gd+fretds+fastcgi+memcache环境安装配置

于2017.04.21 从新浪博客搬迁过来

东昌网站建设公司创新互联公司,东昌网站设计制作,有大型网站制作公司丰富经验。已为东昌上千多家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的东昌做网站的公司定做!

----------------------------------------------------------------


现在很多企业线上web环境都在使用lamp+fretds这样的环境的,如果公司正处于发展阶段,那么有时候需要扩大线上环境,或者替换老的机器,在这个时候就需要搭建线上的web环境,如果每次都手动安装环境费时费力;在这里我基于我们公司线上web环境整理了这篇文档。


安装前的准备工作

关闭防火墙和selinux

iptables –F; iptables –X; iptables –Z; service iptables save

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config


卸载掉系统自带的rpm安装包

yum -y remove httpd* MySQLd* php libtool*

 

在安装之前要确认yum工具能正常使用,因为在安装过程中有时候需要使用yum安装一些缺少的包。

 

一、Web环境的安装和配置

1.安装前需要安装的一些环境包

yum install -y  gcc  gcc-c++ libtool-ltdl-devel make sudo gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel bzip2 php-dba.i386 php-dbase.i386 gdbm-devel curl

 

2.apache的安装

1).建立www账户用来供apache使用

useradd -s /sbin/nologin www

 

2).apache的编译安装

cd /data/lamp/

tar zxvf httpd-2.2.22.tar.gz

cd httpd-2.2.22/

./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite

make

make install

#configure这里没有使用太多编译参数可以根据自己公司需要的环境来定义;在这里提醒一下,可以使用echo $? 来查看是否有error 产生,如果结果为0那么就没有error产生,为其他值的时候就有error产生需要检查一下!

 

3).apache的简单配置和启动

简单修改apache的配置文件

sed -i 's/User daemon/User www/g' /usr/local/apache2/conf/httpd.conf

sed -i 's/Group daemon/Group www/g' /usr/local/apache2/conf/httpd.conf

sed -i "/ServerName/s/#ServerName.*/ServerName localhost/g" /usr/local/apache2/conf/httpd.conf

 

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

sed -i '3i #chkconfig:2345 10 90' /etc/rc.d/init.d/httpd

sed -i '4i #description:apache server' /etc/rc.d/init.d/httpd

/sbin/chkconfig --del httpd

/sbin/chkconfig --add httpd

这样操作可以使用service httpd restart的方式来重启httpd

如果不采用这样的方式也可以使用以下方式启动

/usr/local/apache2/bin/apachectl start

 

 

3.mysql的安装

1).先建立mysql账户供mysql程序使用

useradd -M -s /sbin/nologin mysql

 

2).安装ncurses-5.6.tar.gz

cd /data/lamp/

ncurses-5.6.tar.gz

cd ncurses-5.6

./configure --prefix=/usr --with-shared --without-debug

make clean

make

make install

 

提醒:同样可以使用echo $? 来检测是否有错误发生

 

3).安装mysql

cd /data/lam/

tar –zxvf mysql-5.0.27.tar.gz

cd mysql-5.0.27/

./configure --prefix=/usr/local/mysql --with-mysqlduser=mysql

make clean

make

make install

 

mysq简单配置

mv /etc/my.cnf /etc/my.cnf.old

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

/usr/local/mysql/bin/mysql_install_db

chown mysql.mysql /usr/local/mysql/var/ -R

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

chmod 755 /etc/init.d/mysqld

echo "/usr/local/mysql/lib/mysql/" >>/etc/ld.so.conf

ldconfig

chkconfig --add mysqld

service mysqld restart

export PATH=$PATH:/usr/local/mysql/bin/

echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile

 

4.安装php之前需要的一些插件

#安装zlib

cd /data/lamp/

tar -zxvf zlib-1\[1\].2.3.tar.gz

cd zlib-1.2.3/

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

make

make install

 

#安装libtool

cd /data/lamp/

tar zxvf libtool-1.5.26.tar.gz

cd libtool-1.5.26

./configure

make && make install

 

#安装jpeg6

cd /data/lamp

mkdir /usr/local/jpeg6

mkdir /usr/local/jpeg6/bin

mkdir /usr/local/jpeg6/include

mkdir /usr/local/jpeg6/lib

mkdir /usr/local/jpeg6/man

mkdir /usr/local/jpeg6/man/man1

 

tar zxvf jpegsrc.v6b.tar.gz

cd jpeg-6b/

cp /usr/local/share/libtool/config.sub ./

cp /usr/local/share/libtool/config.guess ./

./configure --prefix=/usr/local/jpeg6/   --enable-shared --enable-static

make

make install-lib

make install

 

提醒:如果是手动安装在这里最好检查一下是否有错误发生,这里安装出现错误几率非常高。

 

#安装libpng

cd /data/lamp/

tar -zxvf libpng-1\[1\].2.26.tar.gz

cd libpng-1.2.26/

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

make

make install

 

#安装freetype

cd /data/lamp/

tar -zxvf freetype-2\[1\].3.5.tar.gz

cd freetype-2.3.5/

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

make

make install

 

#安装gd

cd /data/lamp/

tar -zxvf gd-2.0.33.tar.gz

cd gd-2.0.33

./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6/ --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype/  --with-png=/usr/local/libpng

make

make install

 

#安装libxml

cd /data/lamp/

tar -zxvf libxml2-2.6.26.tar.gz

cd libxml2-2.6.26

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

make

make install

 

5.freetds的安装

cd /data/lamp/

tar zxvf freetds-stable.tgz

cd freetds-0.82

./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-static

make

make install

touch /usr/local/freetds/include/tds.h

touch /usr/local/freetds/lib/libtds.a

 

6.php的安装

cd /data/lamp/

tar -zxvf php-5.2.6.tar.gz

cd php-5.2.6

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/xml2 --with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg6 --with-zlib --with-freetype-dir=/usr/local/freetype --enable-pdo --with-pdo-sqlite --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-pdo-dblib=/usr/local/freetds/ --with-gd=/usr/local/gd --with-curl --with-mssql=/usr/local/freetds/ --disable-debug --enable-sockets --enable-force-cgi-redirect --enable-calendar --enable-magic-quotes --enable-ftp --enable-gd-native-ttf --with-ttf --with-gdbm --with-iconv --enable-mbstring=all

make

make test

make install

cp php.ini-recommended /usr/local/php/lib/php.ini

#sed -i '/LoadModule php5_module/ aAddType application/x-httpd-php-source .phps' /usr/local/apache2/conf/httpd.conf

sed -i '/LoadModule php5_module/ aAddType application/x-httpd-php .php' /usr/local/apache2/conf/httpd.conf

 

#第一条不加好像也正常,但是请重启浏览器,清除缓存

 

7.memcache的安装

Cd /data/lamp/

tar -zxvf libevent-2.0.8-rc.tar.gz

cd libevent-2.0.8-rc

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

make

make install

ln -s /usr/local/libevent/lib/libevent.so /usr/lib64/libevent-2.0.so.2

 

cd /data/lamp/

tar zxvf  m4-1.4.9.tar.gz

cd m4-1.4.9

./configure

make && make install

 

cd /data/lamp/

tar zxvf autoconf-2.62.tar.gz

cd autoconf-2.62

./configure

make && make install

 

cd /data/lamp/

tar -zxvf memcached-1.4.5.tar.gz

cd memcached-1.4.5

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

make

make test

make install

cd /usr/local/bin/

./memcached -d -m 1024 -p 12000 -u root

 

cd /data/lamp/

tar -zxvf memcache-2.1.2.tg

cd memcache-2.1.2

/usr/local/php/bin/pecl install memcache

/usr/local/php/bin/phpize

./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config -with-zlib-dir

make

make test

make install

 

cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"#' /usr/local/php/lib/php.ini

 

8.fastcgi的安装

cd /data/lamp/

tar zxvf mod_fastcgi-2.4.6.tar.gz

cd mod_fastcgi-2.4.6

cp Makefile.AP2 Makefile

chmod 777 Makefile

sed -i 's#/usr/local/apache2#/usr/local/apache2#g ' Makefile

make

make install

sed -i '55i LoadModule fastcgi_module     modules/mod_fastcgi.so' /usr/local/apache2/conf/httpd.conf

 

 

至此,web环境就安装结束了,可以自己测试一下

echo “/usr/local/apache/htdocs/phpinfo.php

echo “phpinfo();” >>/usr/local/apache/htdocs/phpinfo.php

echo “?>” >>/usr/local/apache/htdocs/phpinfo.php

 

service httpd restart

service mysqld restart

 

浏览器打开

http://server_ip/phpinfo.php

 

参考链接

http://www.cnblogs.com/z-ping/archive/2012/07/17/2594990.html apache/mysql/php 的编译参数


分享标题:企业LAMP+gd+fretds+fastcgi+memcache环境安装配置
当前链接:http://cdweb.net/article/ghceii.html