您好,登錄后才能下訂單哦!
于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 “<?php” >/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 的編譯參數
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。