企业LAMP+gd + fretds + fastcgi + memcache环境安装配置
admin
2023-06-19 08:21:47
0次

于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 的编译参数


相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...