CentOS7 编译安装LNMP

LNMP(Linux-Nginx-MysqL-PHP),本文在CentOS7.0上编译LNMP尝尝鲜,全文基本上都是采用手动编译部署...依赖yum帮我安装了GCC和automake..写这个东西耗时有点久了...尼玛 太花时间啦,Linux运维交流群:344177552

主要软件版本:

Nginx-1.6.0 PHP-5.3.5 MysqL-5.5.6

yum源配置(其实没什么改动)

[root@ipython ~]# cat /etc/yum.repos.d/1.repo [1] name=1 baseurl=file:///media enabled=1 gpgcheck=0 [root@ipython ~]# mount /dev/cdrom /media && yum clean all mount: /dev/sr0 is write-protected,mounting read-only Loaded plugins: fastestmirror Cleaning repos: 1 Cleaning up everything

编译工具安装

[root@ipython ~]# yum install gcc-c++ automake autoconf bzip2

zlib库(提供数据压缩用的函式库):

[root@ipython lnmp]# tar zxf zlib-1.2.8.tar.gz [root@ipython lnmp]# cd zlib-1.2.8 [root@ipython zlib-1.2.8]# ./configure --prefix=/software/sharelib [root@ipython zlib-1.2.8]# make && make install

pcre库(rewrite的支持

[root@ipython lnmp]# tar zxf pcre-8.35.tar.gz [root@ipython lnmp]# cd pcre-8.35 [root@ipython pcre-8.35]# ./configure --prefix=/software/pcre --enable-utf8 --enable-unicode-properties [root@ipython pcre-8.35]# make && make install

OpenSSL库(https的支持)

[root@ipython lnmp]# tar zxf openssl-1.0.1h.tar.gz [root@ipython lnmp]# cd openssl-1.0.1h [root@ipython openssl-1.0.1h]# ./config --prefix=/software/openssl [root@ipython openssl-1.0.1h]# make && make install

tcmalloc工具(google内存管理套件)

[root@ipython lnmp]# tar zxf libunwind-1.1.tar.gz [root@ipython lnmp]# cd libunwind-1.1 [root@ipython libunwind-1.1]# CFLAGS=-fPIC ./configure --prefix=/software/google-libunwind [root@ipython libunwind-1.1]# make CFLAGS=-fPIC && make CFLAGS=-fPIC install [root@ipython lnmp]# tar zxf gperftools-2.2.tar.gz [root@ipython lnmp]# cd gperftools-2.2 [root@ipython gperftools-2.2]# LDFLAGS="-L/software/google-libunwind/lib" CPPFLAGS="-I/software/google-libunwind/include" ./configure --prefix=/software/google-perftools [root@ipython gperftools-2.2]# make && make install ###路径加到动态链接库### [root@ipython gperftools-2.2]# echo "/software/google-libunwind/lib/" >> /etc/ld.so.conf [root@ipython gperftools-2.2]# echo "/software/google-perftools/lib/" >> /etc/ld.so.conf [root@ipython gperftools-2.2]# echo "/software/sharelib/lib/" >> /etc/ld.so.conf && ldconfig

Nginx(不解释)

[root@ipython lnmp]# groupadd -g 1500 Nginx [root@ipython lnmp]# useradd -M -u 1500 -g Nginx -s /sbin/nologin Nginx [root@ipython lnmp]# mkdir /var/tmp/Nginx [root@ipython lnmp]# chown Nginx:Nginx /var/tmp/Nginx/ [root@ipython lnmp]# tar zxf Nginx-1.6.0.tar.gz [root@ipython lnmp]# cd Nginx-1.6.0 [root@ipython Nginx-1.6.0]# sed -i 's/CFLAGS="$CFLAGS -g"/#CFLAGS="$CFLAGS -g"/' auto/cc/gcc [root@ipython Nginx-1.6.0]# sed -i "s#/usr/local#/software/google-perftools#" auto/lib/google-perftools/conf ##配置参数有点长## [root@ipython Nginx-1.6.0]# ./configure --prefix=/software/Nginx --user=Nginx --group=Nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-debug --http-client-body-temp-path=/var/tmp/Nginx/client --http-proxy-temp-path=/var/tmp/Nginx/proxy --http-fastcgi-temp-path=/var/tmp/Nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/Nginx/uwsgi --http-scgi-temp-path=/var/tmp/Nginx/scgi --with-pcre=/root/lnmp/pcre-8.35 --with-openssl=/root/lnmp/openssl-1.0.1h --with-zlib=/root/lnmp/zlib-1.2.8 --with-google_perftools_module [root@ipython Nginx-1.6.0]# make && make install [root@ipython Nginx-1.6.0]# mkdir /tmp/tcmalloc [root@ipython Nginx-1.6.0]# chmod 0777 /tmp/tcmalloc/ ###这文件在附件里### [root@ipython Nginx-1.6.0]# cp ../Nginx.conf /software/Nginx/conf/ [root@ipython Nginx-1.6.0]# cp ../fcgi.conf /software/Nginx/conf/ [root@ipython Nginx-1.6.0]# chmod 755 /etc/init.d/Nginx [root@ipython Nginx-1.6.0]# mkdir /data/{logs,www.ipython.me} [root@ipython Nginx-1.6.0]# /software/Nginx/sbin/Nginx [root@ipython Nginx-1.6.0]# iptables -F [root@ipython Nginx-1.6.0]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT [root@ipython Nginx-1.6.0]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT [root@ipython Nginx-1.6.0]# ps aux|grep Nginx root 61291 0.0 0.0 31120 896 ? Ss 15:36 0:00 Nginx: master process /software/Nginx/sbin/Nginx -c /software/Nginx/conf/Nginx.conf Nginx 61293 0.0 0.1 31560 1612 ? S 15:36 0:00 Nginx: worker process

ncurses库(字符终端处理库)

[root@ipython lnmp]# tar jxf ncurses-5.9.tar.bz2 [root@ipython lnmp]# cd ncurses-5.9 [root@ipython ncurses-5.9]# ./configure --prefix=/software/ncurses --with-shared --without-debug [root@ipython ncurses-5.9]# make && make install

MysqL数据库

[root@ipython lnmp]# /usr/sbin/groupadd MysqL [root@ipython lnmp]# /usr/sbin/useradd -s /sbin/nologin -g MysqL MysqL [root@ipython lnmp]# tar zxf MysqL-5.5.6-rc.tar.gz [root@ipython lnmp]# cd MysqL-5.5.6-rc [root@ipython MysqL-5.5.6-rc]# ./configure --prefix=/software/MysqL/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg --with-named-curses-libs=/software/ncurses/lib/libncurses.so.5 [root@ipython MysqL-5.5.6-rc]# make && make install [root@ipython MysqL-5.5.6-rc]# mkdir /data/MysqL/{binlog,relaylog} -p [root@ipython MysqL-5.5.6-rc]# chown -R MysqL:MysqL /data/MysqL [root@ipython MysqL-5.5.6-rc]# /software/MysqL/bin/MysqL_install_db --basedir=/software/MysqL/ --datadir=/data/MysqL/ --user=MysqL ###这文件在附件里### [root@ipython MysqL-5.5.6-rc]# \cp ../my.cnf /etc/my.cnf [root@ipython MysqL-5.5.6-rc]# \cp ../MysqLd /etc/init.d/MysqLd [root@ipython MysqL-5.5.6-rc]# chmod 755 /etc/init.d/MysqLd [root@ipython MysqL-5.5.6-rc]# systemctl enable MysqLd [root@ipython MysqL-5.5.6-rc]# systemctl start MysqLd [root@ipython MysqL-5.5.6-rc]# ps aux | grep MysqLd root 55475 0.1 0.1 115348 1696 ? S 16:07 0:00 /bin/sh /software/MysqL/bin/MysqLd_safe --datadir=/data/MysqL --pid-file=/data/MysqL/MysqL.pid MysqL 56342 2.7 11.9 1918248 120680 ? Sl 16:07 0:01 /software/MysqL/libexec/MysqLd --basedir=/software/MysqL --datadir=/data/MysqL --plugin-dir=/software/MysqL/lib/MysqL/plugin --user=MysqL --log-error=/data/MysqL/MysqL_error.log --open-files-limit=10240 --pid-file=/data/MysqL/MysqL.pid --socket=/tmp/MysqL.sock --port=3306

libiconv库(字符编码转换)

[root@ipython lnmp]# tar zxf libiconv-1.14.tar.gz ###打补丁吧,避免手动修改隐患逻辑错误### [root@ipython lnmp]# gzip -d libiconv-glibc-2.16.patch.gz [root@ipython lnmp]# cd libiconv-1.14/srclib [root@ipython srclib]# patch -p1 < ../../libiconv-glibc-2.16.patch patching file stdio.in.h [root@ipython libiconv-1.14]# cd .. [root@ipython libiconv-1.14]# ./configure --prefix=/software/sharelib/ [root@ipython libiconv-1.14]# make && make install

libxml库(XML库)

[root@ipython lnmp]# tar jxf libxml2-2.8.0.tar.bz2 [root@ipython lnmp]# cd libxml2-2.8.0 [root@ipython libxml2-2.8.0]# ./configure --prefix=/software/sharelib [root@ipython libxml2-2.8.0]# make && make install

libpng库(图片库)

[root@ipython lnmp]# tar jxf libpng-1.6.8.tar.bz2 [root@ipython lnmp]# cd libpng-1.6.8 [root@ipython libpng-1.6.8]# LDFLAGS="-L/software/sharelib/lib/" CPPFLAGS="-I/software/sharelib/include" ./configure --prefix=/software/sharelib [root@ipython libpng-1.6.8]# make && make install

jpeg库(图片库)

[root@ipython lnmp]# tar jxf jpegsrc.v9a.tar.bz2 [root@ipython lnmp]# cd jpeg-9a/ [root@ipython jpeg-9a]# ./configure --prefix=/software/sharelib/ [root@ipython jpeg-9a]# make && make install

freetype(字库)

[root@ipython lnmp]# tar jxf freetype-2.5.2.tar.bz2 [root@ipython lnmp]# cd freetype-2.5.2 [root@ipython freetype-2.5.2]# LIBPNG_CFLAGS="-I/software/sharelib/include/" LIBPNG_LDFLAGS="-L/software/sharelib/lib/" ./configure --prefix=/software/sharelib [root@ipython freetype-2.5.2]# make && make install [root@ipython freetype-2.5.2]# ln -s /software/sharelib/include/freetype2 /software/sharelib/include/freetype2/freetype

libmcrypt库(加密算法)

[root@ipython lnmp]# tar jxf libmcrypt-2.5.8.tar.bz2 [root@ipython lnmp]# cd libmcrypt-2.5.8 [root@ipython libmcrypt-2.5.8]# ./configure --prefix=/software/sharelib [root@ipython libmcrypt-2.5.8]# make && make install

mhash库(加密)

[root@ipython lnmp]# tar jxf mhash-0.9.9.9.tar.bz2 [root@ipython lnmp]# cd mhash-0.9.9.9 [root@ipython mhash-0.9.9.9]# ./configure --prefix=/software/sharelib/ [root@ipython mhash-0.9.9.9]# make && make install

curl库(URL传输)

[root@ipython lnmp]# tar jxf curl-7.36.0.tar.bz2 [root@ipython lnmp]# cd curl-7.36.0 [root@ipython curl-7.36.0]# ./configure --prefix=/software/curl [root@ipython curl-7.36.0]# make && make install

gd库(绘图)

[root@ipython lnmp]# tar zxf gd-2.0.35.tar.gz [root@ipython lnmp]# cd gd-2.0.35 [root@ipython gd-2.0.35]# LDFLAGS="-L/software/sharelib/lib" CPPFLAGS="-I/software/sharelib/include" ./configure --prefix=/software/sharelib --enable-shared --with-png=/software/sharelib --with-freetype=/software/sharelib --with-libiconv-prefix=/software/sharelib --with-jpeg=/software/sharelib [root@ipython gd-2.0.35]# make && make install

libtool(库编译支持

[root@ipython lnmp]# tar zxf libtool-2.4.2.tar.gz [root@ipython lnmp]# cd libtool-2.4.2 [root@ipython libtool-2.4.2]# ./configure --prefix=/software/sharelib/ --enable-ltdl-install [root@ipython libtool-2.4.2]# make && make install

MysqL的库文件加入动态共享

[root@ipython lnmp]# echo "/software/MysqL/lib/MysqL/" >> /etc/ld.so.conf && ldconfig

PHP(一种语言吧)

[root@ipython lnmp]# tar zxf PHP-5.3.5.tar.gz [root@ipython lnmp]# cd PHP-5.3.5 [root@ipython PHP-5.3.5]# sed -i s"#MysqL/psi/psi.h#/software/MysqL/include/MysqL/psi/psi.h#" /software/MysqL/include/MysqL/my_sys.h [root@ipython PHP-5.3.5]# sed -i s"#MysqL/plugin.h#/software/MysqL/include/MysqL/plugin.h#" /software/MysqL/include/MysqL/m_string.h [root@ipython PHP-5.3.5]# sed -i s"#MysqL/services.h#/software/MysqL/include/MysqL/services.h#" /software/MysqL/include/MysqL/plugin.h [root@ipython PHP-5.3.5]# sed -i s"#MysqL/service_my_snprintf.h#/software/MysqL/include/MysqL/service_my_snprintf.h#" /software/MysqL/include/MysqL/services.h [root@ipython PHP-5.3.5]# sed -i s"#MysqL/service_thd_alloc.h#/software/MysqL/include/MysqL/service_thd_alloc.h#" /software/MysqL/include/MysqL/services.h [root@ipython PHP-5.3.5]# ./configure --prefix=/software/PHP --with-config-file-path=/software/PHP/etc --with-MysqL=/software/MysqL --with-MysqLi=/software/MysqL/bin/MysqL_config --with-iconv-dir=/software/sharelib --disable-ipv6 --with-freetype-dir=/software/sharelib/ --with-jpeg-dir=/software/sharelib/ --with-png-dir=/software/sharelib/ --with-zlib=/software/sharelib/ --with-libxml-dir=/software/sharelib/ --disable-rpath --enable-bcmath --enable-safe-mode --enable-shmop --enable-sysvsem --with-curl=/software/curl/ --enable-fpm --enable-mbstring --with-mcrypt=/software/sharelib/ --with-gd=/software/sharelib/ --enable-gd-native-ttf --with-openssl=/software/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-inline-optimization --with-curlwrappers --enable-mbregex --with-gettext [root@ipython PHP-5.3.5]# make install ##创建PHP-FPM配置文件,参数什么的自己根据配置调整## [root@ipython PHP-5.3.5]# cat >> /software/PHP/etc/PHP-fpm.conf <

好了...看图

CentOS7 编译安装LNMP

本文出自 “IT辰逸” 博客,请务必保留此出处http://itchenyi.blog.51cto.com/4745638/1437686

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native