nginx php fpm mysql_centos编译安装nginx+php-fpm+mysql

centos编译安装nginx+php-fpm+mysql

post by rocdk890 / 2012-6-24 21:28 Sunday

linux技术

本来不是很想写这篇文章的,毕竟网上都有很多人都写了编译安装lnmp的教程,更有一键安装包来方便大家,这是我个人的特色编译,记录下来方便自己,也方便有很多人跟我一样奇怪的需求的.

系统:centos 5.5

需要的软件包:libiconv-1.14.tar.gz nginx-1.2.1.tar.gz php-5.2.17.tar.gz php-5.2.17-fpm-0.5.14.diff.gz mysql-5.1.63.tar.gz

1.安装前准备

yum -y install gcc  gcc-c++ libtool-libs autoconf freetype-devel \

gd libjpeg-devel  libpng-devel libxml2-devel pcre-devel ncurses-devel \

zlib-devel zip unzip curl-devel wget crontabs file bison libmcrypt libmcrypt-devel \

patch mlocate flex diffutils automake make kernel-devel cpp readline-devel \

openssl-devel vim-minimal sendmail glibc-devel  glib2-devel vixie-cron mcrypt \

bzip2-devel e2fsprogs-devel libidn-devel  gettext-devel expat-devel libmhash libmhash-devel \

libcap-devel libtool libtool-ltdl-devel pam-devel logrotate

useradd -M -r -s /sbin/nologin www

useradd -M -r -s /sbin/nologin mysql

tar zxf libiconv-1.14.tar.gz && cd libiconv-1.14

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

make && make install

2.安装mysql

tar zxf mysql-5.1.63.tar.gz && cd mysql-5.1.63

autoreconf --force --install

libtoolize --automake --force

automake --force --add-missing

CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp" \

./configure --prefix=/usr/local/mysql/ --localstatedir=/var/lib/mysql --without-debug \

--with-unix-socket-path=/var/lib/mysql/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static \

--enable-assembler --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all \

--with-readline --enable-local-infile --enable-thread-safe-client --with-big-tables

make && make install

/usr/local/mysql/bin/mysql_install_db --user=mysql

chown -R root /usr/local/mysql

chgrp -R mysql /usr/local/mysql

chown -R mysql.mysql /var/lib/mysql/

chmod 755 /var/lib/mysql/

/usr/local/mysql/bin/mysqld_safe  --user=mysql &

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

chown root.root /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig  mysqld on

cat > /etc/ld.so.conf.d/mysql.conf<

/usr/local/mysql/lib/mysql

/usr/local/lib

EOF

ldconfig

ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/mysql/bin/mysql /usr/bin

ln -s /usr/local/mysql/bin/mysqladmin /usr/bin

ln -s /usr/local/mysql/bin/mysqldump /usr/bin/

上传my.cnf到/etc或cp support-files/my-medium.cnf /etc/my.cnf

service mysqld start

3.安装php

tar zxf php-5.2.17.tar.gz

gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1

cp php-5.2.17-max-input-vars.patch php-5.2.17

cd php-5.2.17

patch -p1 < php-5.2.17-max-input-vars.patch

yum install autoconf213 -y

vi /etc/profile

在/etc/profile最后加上

export  PHP_AUTOCONF=/usr/bin/autoconf-2.13

export  PHP_AUTOHEADER=/usr/bin/autoheader-2.13

保存退出

source /etc/profile

./buildconf --force

./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --with-fpm-log=/var/log/php-fpm.log \

--with-fpm-conf=/etc/php-fpm.conf --with-fpm-pid=/var/run/php-fpm.pid --with-config-file-path=/etc \

--with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl \

--enable-ftp --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-gettext --with-mhash \

--enable-mbstring --with-mcrypt --enable-soap --enable-zip --with-iconv=/usr/local/libiconv \

--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --without-pear

make && make install

ln -s /usr/local/php/bin/php /usr/bin/php

ln -s /usr/local/php/bin/phpize /usr/bin/phpize

ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm

ln -s /usr/local/php/bin/php-cgi /usr/bin/php-cgi

做完这些,上传php-fpm到/etc/init.d

上传php-fpm.conf和php.ini到/etc

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

mkdir /etc/php.d

service php-fpm start

4.安装nginx

tar zxf nginx-1.2.1.tar.gz && cd nginx-1.2.1

./configure --user=www --group=www  --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx \

--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy \

--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --pid-path=/var/run/nginx.pid \

--lock-path=/var/lock/subsys/nginx --with-http_secure_link_module --with-http_random_index_module \

--with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module \

--with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module \

--with-http_perl_module --with-http_geoip_module --with-mail --with-mail_ssl_module --with-cc-opt='-O3' \

--with-cpu-opt=pentium

make && make install

然后上传nginx到/etc/init.d

chmod +x /etc/init.d/nginx

chkconfig --add nginx

chkconfig nginx on

mkdir -p /var/lib/nginx/tmp/client_body 以前一直忘了写上这步了,不然启动nginx的时候会提示让你去创建

service nginx start

好了,我个人的nginx+php-fpm+mysql环境就搭建成功了.

夜空- 本站版权

1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权

2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意

3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责

4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意

5、原文链接:blog.slogra.com/post-217.html

post-217.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值