手动编译装置LNMP环境,建立wordpress博客51CTO博客 - 牛牛娱乐

手动编译装置LNMP环境,建立wordpress博客51CTO博客

2019-03-06 10:19:59 | 作者: 忆香 | 标签: 装置,编译,环境 | 浏览: 504

2013年—编译装置LNMP环境,建立wordpress博客

装置目录:

1.体系环境:.........................................2

2.装置前体系设置:...................................2

3.装置gcc编译器及相关东西和依靠库......................2

     3.1装置pcre库...................................3

3.2装置PHP所需的支撑库................................3

     3.2.1装置freeType...............................3

     3.2.2装置jpeg...................................3

     3.3.3装置fontconfig.............................3

     3.3.4装置libpng..................................4

     3.3.5装置zlib....................................4

     3.3.6装置ncurses.................................4

     3.3.7装置libmcrypt...............................4

     3.3.8装置libxml..................................4

     3.3.9装置libiconv.................................5

     3.3.10装置gd库..................................5

4.装置nginx............................................5

     测验nginx的web是否可用...........................5

5.装置mysql数据库......................................5

6.装置php..............................................7

     6.1装备php-fp.....................................8

7.整合nginx和php........................................9

     7.1测验php......................................12

     7.2测验mysql.....................................12

操作过程:

体系环境:

1.看下主机名、内核版别以及体系版别的信息

[root@tyk ~]# uname -a
Linux tyk 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@tyk ~]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 5.8 (Final)
Release:        5.8
Codename:       Final

2.装置条件环境:

装备网络yum源

[root@tyk ~]# cd /etc/yum.repos.d/
[root@tyk yum.repos.d]# /bin/mv CentOS-Base.repo CentOS-Base.repo.ori
[root@tyk yum.repos.d]# wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
[root@tyk yum.repos.d]# /bin/mv CentOS-Base-sohu.repo CentOS-Base.repo

做下时刻同步:

[root@tyk ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1

留意:最好封闭iptables防火墙和selinux否则后边有或许呈现问题。

##晋级一下yum源

[root@tyk ~]# yum update -y yum

装置gcc编译器及相关东西和依靠库:

[root@tyk ~]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

编译装置pcre库

PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正规表达式。Pcre的效果主要是使nginx支撑HTTP rewrite模块。

创立一个指定放置紧缩包的目录

[root@tyk ~]# mkdir -p /taokey/tools
[root@tyk ~]# cd /taokey/tools/
[root@tyk tools]# unzip pcre-8.33.zip
[root@tyk tools]# cd pcre-8.33
[root@tyk pcre-8.33]# ./configure
[root@tyk pcre-8.33]# make && make install

装置PHP所需的支撑库:

编译装置FreeType

FreeType库是一个完全免费(开源)的、高质量的且可移植的字体引擎,它供给一致的接口来拜访多种字体格式文件。

[root@tyk tools]# tar -jxvf freetype-2.4.12.tar.bz2
[root@tyk tools]# cd freetype-2.4.12
[root@tyk freetype-2.4.12]# ./configure --prefix=/usr/local/freetype
[root@tyk freetype-2.4.12]# make && make install

编译装置jpeg

Jpeg是一个根本的图画紧缩方法。

[root@tyk tools]# tar -zxvf jpegsrc.v7.tar.gz
[root@tyk tools]# cd jpeg-7/
[root@tyk jpeg-7]# mkdir /usr/local/jpeg
[root@tyk jpeg-7]# mkdir /usr/local/jpeg/bin
[root@tyk jpeg-7]# mkdir /usr/local/jpeg/lib
[root@tyk jpeg-7]# mkdir /usr/local/jpeg/include
[root@tyk jpeg-7]# mkdir /usr/local/jpeg/man
[root@tyk jpeg-7]# mkdir /usr/local/jpeg/man/man1
[root@tyk jpeg-7]# ./configure --prefix=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-shared --enable-static
[root@tyk jpeg-7]# make && make install

装置fontconfig

fontconfig是供给体系范围内字体设置,定制和答应应用程序拜访的函数库,Fontconfig担任字体的装置承认和匹配。

[root@tyk tools]# tar -zxvf fontconfig-2.4.2.tar.gz
[root@tyk tools]# cd fontconfig-2.4.2
[root@tyk fontconfig-2.4.2]# ./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config  --with-expat-lib=/usr/lib64
[root@tyk fontconfig-2.4.2]#make && make install

留意:在这儿要是64位体系,就有必要加上参数” --with-expat-lib=/usr/lib64 ”

装置libpng:

ibpng软件包包括 libpng 库.这些库被其他程式用于读写png文件

[root@tyk tools]# tar -jxf libpng-1.4.3.tar.bz2
[root@tyk tools]# cd libpng-1.4.3
[root@tyk libpng-1.4.3]# ./configure --prefix=/usr/local/libpng --enable-static --enable-shared
[root@tyk libpng-1.4.3]# make && make install

装置zlib:

zlib能运用一个gzip数据头,zlib数据头或许不运用数据头紧缩数据。

[root@tyk tools]# tar -zxvf zlib-1.2.3.tar.gz
[root@tyk tools]# cd zlib-1.2.3
[root@tyk zlib-1.2.3]# ./configure --prefix=/usr/local/zlib
[root@tyk zlib-1.2.3]# make && make install

装置ncurses:

NCURSES不仅仅仅仅封装了底层的终端功用,而且供给了一个适当安定的作业结构(Framework)用 以发生美丽的界面。它包括了一些创立窗口的函数。

[root@tyk tools]# tar -zxf ncurses-5.6.tar.gz
[root@tyk tools]# cd ncurses-5.6
[root@tyk ncurses-5.6]# ./configure --prefix=/usr/local/ncurses
[root@tyk ncurses-5.6]# make && make install

装置libmcrypt

libmcrypt是加密算法扩展库。支撑DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。

[root@tyk tools]# tar -zxvf libmcrypt-2.5.7.tar.gz
[root@tyk libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt --enable-shared --enable-static --enable-dynamic-loading
[root@tyk libmcrypt-2.5.7]# make && make install

装置libxml

libxml是一个用来解析XML文档的函数库。它用C言语写成, 而且能为多种言语所调用,例如C言语,C++,XSH。C#,Python,Kylix/Delphi,Ruby,和PHP等。Perl中也能够运用XML::LibXML模块。libXML 代码可移植性非常好,由于它根据规范的ANSI C库, 并选用MIT许可证。

[root@tyk tools]# tar -zxvf libxml2-2.7.8.tar.gz
[root@tyk tools]# cd libxml2-2.7.8
[root@tyk libxml2-2.7.8]# ./configure --prefix=/usr/local/libxml2 --enable-shared --enable-static
[root@tyk libxml2-2.7.8]# make && make install

装置libiconv

对文本进行编码间的转化,用它来处理中文各种编码之间的转化。

[root@tyk tools]# tar -zxvf libiconv-1.14.tar.gz
[root@tyk tools]# cd libiconv-1.14
[root@tyk libiconv-1.14]# ./configure --prefix=/usr/local/libiconv-1.14
[root@tyk libiconv-1.14]# make && make install

装置gd库

[root@tyk tools]# tar -zxvf gd-2.0.33.tar.gz
[root@tyk tools]# cd gd-2.0.33
[root@tyk gd-2.0.33]# ./configure --prefix=/usr/local/gd --with-zlib=/usr/local/zlib --with-png=/usr/local/libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/fontconfig
[root@tyk gd-2.0.33]# make && make install


4.装置nginx
[root@tyk tools]# useradd -s /sbin/nologin -M nginx
[root@tyk tools]# groupadd ngnix
[root@tyk tools]# tar -zxvf nginx-1.3.1.tar.gz
[root@tyk tools]# cd nginx-1.3.1
[root@tyk nginx-1.3.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.3.1 --with-http_stub_status_module --with-http_ssl_module --with-pcre=/taokey/tools/pcre-8.33
[root@tyk nginx-1.3.1]# make && make install
[root@tyk nginx-1.3.1]# ln -s /usr/local/nginx-1.3.1 /usr/local/nginx
[root@tyk nginx-1.3.1]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.3.1/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.3.1/conf/nginx.conf test is successful
[root@tyk nginx-1.3.1]# netstat -anpt | grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      15988/nginx
[root@tyk nginx-1.3.1]# ps -ef | grep nginx
root     15988     1  0 23:13 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx    15989 15988  0 23:13 ?        00:00:00 nginx: worker process     
root     15995 26971  0 23:14 pts/1    00:00:00 grep nginx
5.装置mysql数据库
首要创立mysql用户和组
[root@tyk tools]# groupadd mysql
[root@tyk tools]# useradd -s /sbin/nologin -g mysql -M mysql
[root@tyk tools]# tar -zxvf mysql-5.1.65.tar.gz
[root@tyk tools]# cd mysql-5.1.65
删去configure目录下的第52297行$RM "$cfgfile",否则会报错。
[root@tyk mysql-5.1.65]# ./configure --prefix=/application/mysql5.1.65 --with-unix-socket-path=/application/mysql5.1.65/tmp/mysql.sock --localstatedir=/application/mysql5.1.65/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-plugin-PLUGIN --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
[root@tyk mysql-5.1.65]# make && make install
需求仿制一个mysql的主装备文件,这个是有必要仿制的,我这儿仿制了一个small
[root@tyk mysql-5.1.65]# cp support-files/my-small.cnf /etc/my.cnf
[root@tyk mysql-5.1.65]# ln -s /application/mysql5.1.65 /application/mysql
[root@tyk mysql-5.1.65]# mkdir -p /application/mysql/data
[root@tyk mysql-5.1.65]# /application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
[root@tyk mysql-5.1.65]# cp support-files/mysql.server /etc/init.d/mysqld
[root@tyk mysql-5.1.65]# chmod 700 /etc/init.d/mysqld
[root@tyk mysql-5.1.65]# chown -R root.mysql /application/mysql/bin/mysql
[root@tyk mysql-5.1.65]# echo "/application/mysql/lib/mysql" >> /etc/ld.so.conf
[root@tyk mysql-5.1.65]# ldconfig
[root@tyk mysql-5.1.65]# /application/mysql/bin/mysqld_safe --user=mysql &
[root@tyk mysql-5.1.65]# netstat -anpt | grep mysqld
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      26725/mysqld
[root@tyk mysql-5.1.65]# chmod +x /etc/init.d/mysqld
[root@tyk mysql-5.1.65]# chkconfig --add mysqld
[root@tyk mysql-5.1.65]# chkconfig mysqld on
[root@tyk mysql-5.1.65]# export PATH=$PATH:/application/mysql/bin
[root@tyk mysql-5.1.65]# echo "PATH=$PATH:/application/mysql/bin" >>/etc/profile
[root@tyk mysql-5.1.65]# source /etc/profile
[root@tyk mysql-5.1.65]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.65 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type help; or \h for help. Type \c to clear the current input statement.
mysql> exit
Bye
6.装置php环境
[root@tyk tools]# tar -jxvf php-5.4.6.tar.bz2
[root@tyk php-5.4.6]# ./configure  --prefix=/usr/local/php5.4.6  --with-mysql=/application/mysql  --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir=/usr/local/freetype --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-iconv=/usr/local/libiconv-1.14 --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir=/usr/local/libxml2 --enable-gd-native-ttf --enable-zip --enable-fastcgi --enable-fpm
[root@tyk php-5.4.6]# make && make install
在make编译时,呈现报错:
In file included from /usr/local/src/php-5.4.6/ext/gd/gd.c:103:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_stream_putc’中:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:51: 过错:‘struct gdIOCtx’没有名为‘data’的成员
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_stream_putbuf’中:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:58: 过错:‘struct gdIOCtx’没有名为‘data’的成员
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_stream_ctxfree’中:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:67: 过错:‘struct gdIOCtx’没有名为‘data’的成员
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:68: 过错:‘struct gdIOCtx’没有名为‘data’的成员
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:69: 过错:‘struct gdIOCtx’没有名为‘data’的成员
In file included from /usr/local/src/php-5.4.6/ext/gd/gd.c:103:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c: 在函数‘_php_p_w_picpath_output_ctx’中:
/usr/local/src/php-5.4.6/ext/gd/gd_ctx.c:153: 过错:‘gdIOCtx’没有名为‘data’的成员
make: *** [ext/gd/gd.lo] 过错 1
解决方法:
修正gd装置目录下的include/gd_io.h文件。
[root@spp php-5.4.15]# vi /usr/local/gd/include/gd_io.h修正为文件中的结构体为:
 typedef struct gdIOCtx
{
  int (*getC) (struct gdIOCtx *);
  int (*getBuf) (struct gdIOCtx *, void *, int);
                                                                                       
  void (*putC) (struct gdIOCtx *, int);
  int (*putBuf) (struct gdIOCtx *, const void *, int);
                                                                                       
                                                                                       
  int (*seek) (struct gdIOCtx *, const int);
                                                                                       
  long (*tell) (struct gdIOCtx *);
                                                                                       
  void (*gd_free) (struct gdIOCtx *);
  void (*data);
}
gdIOCtx;
其间赤色部分为增加的修正,其他不变。

5.1 装备php-fpm:

[root@tyk php-5.4.6]# cd /usr/local/php5.4.6/etc/
[root@tyk etc]# cp php-fpm.conf.default php-fpm.conf
[root@tyk etc]# egrep -v ";|^$" php-fpm.conf
[global]
error_log = /var/log/php-fpm.log
log_level = notice
pid = /var/log/php/php-fpm.pid
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
[root@tyk etc]# mkdir /var/log/php
[27-Jun-2013 00:17:06] NOTICE: configuration file /usr/local/php5.4.6/etc/php-fpm.conf test is successful
[root@tyk etc]# ../sbin/php-fpm
[root@tyk etc]# ps -ef | grep php-fpm
root     19087     1  0 00:17 ?        00:00:00 php-fpm: master process (/usr/local/php5.4.6/etc/php-fpm.conf)
nginx    19088 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19089 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19090 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19091 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19092 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19093 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19094 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19095 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19096 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19097 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19098 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19099 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19100 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19101 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19102 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19103 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19104 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19105 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19106 19087  0 00:17 ?        00:00:00 php-fpm: pool www
nginx    19107 19087  0 00:17 ?        00:00:00 php-fpm: pool www
root     19109 26971  0 00:18 pts/1    00:00:00 grep php-fpm

整合nginx和php.

[root@tyk local]# cat nginx/conf/nginx.conf
user  nginx;
worker_processes  8;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
error_log /app/logs/nginx_error.log crit;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  commonlog  $remote_addr - $remote_user [$time_local] "$request" 
                           $status $body_bytes_sent "$http_referer" 
                           "$http_user_agent" "$http_x_forwarded_for";
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       80;
        server_name  www.beyond.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   /data/www/www;
            index  index.php index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ .*\.(php|php5)?$ {
        root /data/www/www;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
      }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
        # deny access to .htaccess files, if Apaches document root
        # concurs with nginxs one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_timeout  5m;
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}
[root@tyk local]# nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx-1.3.1/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.3.1/conf/nginx.conf test is successful
[root@tyk local]# nginx/sbin/nginx -s reload
[root@tyk php-5.4.6]# grep short_open_tag /usr/local/php5.4.6/php.ini
; short_open_tag
short_open_tag = On
测验下php和数据库是否成功
[root@tyk www]# cat test.php
<?
phpinfo();
?>
[root@tyk www]# cat testdb.php
<?php
$link=mysql_connect(localhost,root,);
if ($link)
echo "successful";
else
echo "Faile";
mysql_close();
?>
[root@tyk nginx]# sbin/nginx -s reload
此刻页面会呈现successful的字样,阐明成功了。
下载wordpress,然后解压,在数据库上创立一个数据库,账号和暗码,然后给用户赋予权限,就能够装置wordpress博客了。

如图所示:


看下Curl头部信息:


到此试验完毕,谢谢我们阅览!!!

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表牛牛娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章