lnmp lua编译安装

发布时间:2018-05-15 20:22:28 阅读:1065次

https://www.cnblogs.com/xxoome/p/5884063.html

https://blog.csdn.net/remotesupport/article/details/13022935

yum -y install make gcc lua-devel pcre-devel openssl-devel

 cd LuaJIT-2.0.4/
 make
 make install PREFIX=/usr/local/luajit
 cd nginx-1.9.7
 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_realip_module --with-http_sub_module  --with-http_image_filter_module --with-http_gzip_static_module --with-http_addition_module --with-http_geoip_module  --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib --add-module=/root/lnmp/ngx_devel_kit-master/ --add-module=/root/lnmp/lua-nginx-module-master/
 make && make install
 nginx -s reload
 nginx -V

  1 yum update
  2 rpm -Uvh http://mirrors.kernel.org/fedora-epel/epel-release-latest-6.noarch.rpm
  3 yum -y install bzip2-devel curl-devel freetype-devel gcc libjpeg-devel libpng-devel libxslt-devel libxml2-devel openssl-devel pcre-devel pcre-devel zlib-devel
  4 tar -zxvf php-7.2.6.tar.gz
  5 cd php-7.2.6
  6 ./configure --prefix=/usr/local/php7 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-    pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --ena    ble-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip
  7 make
  8 make install
  9 /usr/local/php/bin/php -v
 10 tar -zxvf nginx-1.9.7.tar.gz
 11 tar -zxvf php-5.5.4.tar.gz
 12 cd nginx-1.9.7
 13 yum install gd-devel
 14 yum -y install GeoIP GeoIP-devel GeoIP-data
 15 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_realip_module --with-http_sub_module  --with-http_image_filter_module --with-http_gzip_static_module --with-http_addition_module --with-http_geoip_module
 16 make && make install
 17 cd php-5.5.4
 18 ./configure --prefix=/usr/local/php5 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-    pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --ena    ble-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --with-mysql

如果已经安装了可能会进行升级,版本完全一致则不会进行任何操作。

yum -y install bzip2-devel curl-devel freetype-devel gcc libjpeg-devel libpng-devel libxslt-devel libxml2-devel openssl-devel pcre-devel pcre-devel zlib-devel

http://www.jquerycn.cn/a_16599

 yum install libmcrypt libmcrypt-devel mcrypt mhash

--with-mcrypt 

   1、下载php

下载地址:http://php.net/get/php-7.0.11.tar.gz/from/a/mirror

下载“php-7.0.11.tar.gz”后移动到linux服务器的任意目录下,只在编译时指定安装到的目录。

    2、解压安装包

tar -zxvf php-7.0.11.tar.gz
cd php-7.0.11

    3、配置安装变量

./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

“/usr/local/php”是安装路径,可以改成自己喜欢的安装路径。

    4、编译源码

# 在解压目录执行编译命令:make
cd php-7.0.11 make

编译会花费一些时间,耐心等待即可。编译完成的最后会提示你执行make test命令。就是对上一步 make 的检查,

要确保 make 是没有错误的,也就是这一步的 test、check要全部是 OK 的,error 为0

    5、安装php

make install

   6、配置PHP

将PHP源码包(/usr/local/php-7.0.11)中的php.ini-development文件复制到/usr/local/php/下,更名为php.ini。

cp /usr/local/php-7.0.11/php.ini-development /usr/local/php/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

配置php.ini “cgi.fix_pathinfo=0”

启动php-fpm服务:

/usr/local/php/sbin/php-fpm

启动完毕之后,php-fpm服务默认使用9000端口,使用 netstat -tln | grep 9000 可以查看端口使用情况:

    7、配置nginx

nginx安装教程:http://www.cnblogs.com/xxoome/p/5866475.html

编辑nginx配置文件/usr/local/nginx/conf/nginx.conf,主要修改nginx的server {}配置块中的内容,修改location块,追加index.php让nginx服务器默认支持index.php为首页:  

然后配置.php请求被传送到后端的php-fpm模块,默认情况下php配置块是被注释的,此时去掉注释并修改为以下内容:

这里面很多都是默认的,root是配置php程序放置的根目录,主要修改的就是fastcgi_param中的/scripts为$document_root

修改完这些保存并退出,然后重启nginx:/usr/local/nginx/sbin/nginx -s reload

接下来编辑一个测试的php程序,在nginx下的html目录下创建test.php文件,打印一下php配置:

<?php
    phpinfo();
?>

然后打开浏览器输入对应的地址进行访问,看到输出页面,说明nginx和php都配置成功了

rpm -qf /usr/bin/scp

rpm -ql openssl
php -i | grep configure

nginx

cat /etc/yum.repos.d/epel.repo 
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/7Server/x86_64/
gpgcheck=0
yum -y install make gcc lua-devel pcre-devel openssl-devel
wget http://nginx.org/download/nginx-1.9.7.tar.gz
wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.5.tar.gz
tar -xf nginx-1.9.7.tar.gz
tar -xf LuaJIT-2.1.0-beta2.tar.gz
tar -xf v0.2.19.tar.gz
tar -xf v0.10.5.tar.gz
mkdir /app
cp -r LuaJIT-2.1.0-beta2 lua-nginx-module-0.10.5 ngx_devel_kit-0.2.19 /app
cd LuaJIT-2.1.0-beta2 && make && make install
./configure --prefix=/app/nginx/ --with-ld-opt=-Wl,-rpath,这里编译的luajit的lib路径 --add-module=/app/ngx_devel_kit-0.2.19/ --add-module=/app/lua-nginx-module-0.10.5/ --with-http_ssl_module  --with-http_stub_status_module  --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module  --with-http_degradation_module --with-http_stub_status_module

make && make install

/data/dev.www --> /data/dev.www/
/ngx_conf/   --> /ngx_conf/

/data/www/项目名
/data/www/logs

 宿主机目录

*********************************************************************
 redis
 redis.so 2.2.5

yum -y install redis
********************************************************************
php5

yum -y install libxml2-devel libcurl-devel libjpeg-devel  libpng-devel  freetype-devel openldap-devel libmcrypt-devel
cp -frp /usr/lib64/libldap* /usr/lib/

./configure --prefix=/app/php5 --with-curl=/app/local/curl --with-curlwrappers --enable-calendar --with-libxml-dir=/app/local/libxml2/ --with-xsl=/app/local/libxslt --with-libexpat-dir=/app/local/expat --with-gd --with-jpeg-dir=/app/local/jpeg6/ --with-zlib --with-zlib-dir=/app/local/zlib/ --with-mhash --with-openssl --enable-zip --with-ldap --enable-sqlite-utf8 --with-xmlrpc --with-png-dir=/app/local/libpng --with-freetype-dir=/app/local/freetype/ --with-mcrypt=/usr/local/lib/ --with-iconv-dir=/app/local/libiconv/ --enable-soap --enable-sockets --enable-fd-setsize=65535 --enable-mbstring=cn --enable-fastcgi --enable-fpm --enable-safe-mode --enable-inline-optimization --enable-force-cgi-redirect --enable-discard-path --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --with-pdo-mysql --with-mysqli --with-mysql

------------------------------------添加扩展
yum -y install autoconf
cd /opt/php-5.5.4/ext/pcntl/
/app/php5/bin/phpize
./configure  --with-php-config=/app/php5/bin/php-config
make
cp modules/pcntl.so /app/php5/lib/php/extensions/no-debug-non-zts-20121212/

wget http://pecl.php.net/get/redis-2.2.5.tgz
tar -xf redis-2.2.5.tgz

cd redis-2.2.5

[root@lnmp redis-5.0.0]# cp /root/lnmp/php-7.2.6/ext/openssl/config0.m4 ./config.m4
[root@lnmp redis-5.0.0]# /usr/local/php/bin/phpize

/app/php5/bin/phpize
./configure  --with-php-config=/app/php5/bin/php-config
make
cp  modules/redis.so  /app/php5/lib/php/extensions/no-debug-non-zts-20121212/
**********************************************************************
php7

libicu-devel gcc gcc-c++
./configure  --prefix=/app/php7 --with-config-file-path=/app/php7/etc --with-config-file-scan-dir=/app/php7/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl

***********************************************************************
提交
启动容器
docker run --privileged -ti --name test  docker.io/centos:7  /usr/sbin/init

docker run -it -d --name guojianlong_test -v /docker_mount/app_www/dev.guojianlong:/data/www -v /docker_mount/ngx_conf/:/data/ngx_conf zm-dev-base:v1.1 '/bin/bash'
启动进程

docker exec -d guojianlong_test /bin/bash /app/shell/start_dev.sh

docker commit -a 'kongxiangwen' -m 'nginx+php5.5+php7.0+redis3.2' zm-dev-base zm-dev-base:v1.2

**************************************************************************
添加用户

useradd ${name}
ssh-keygen -q -f /home/${name}/.ssh/id_rsa-dev-docker_${name} -N ''
touch /home/${name}/.ssh/authorized_keys
chmod 600 /home/${name}/.ssh/authorized_keys
cat /home/${name}/.ssh/id_rsa.pub >> /home/${name}/.ssh/authorized_keys

echo "${name} 你的dev环境账户已创建,请下载私钥并保存好。" | mailx -s "dev环境账户创建" -a /home/${name}/.ssh/id_rsa-dev-docker_${name} ${name}@shtest.com

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '"$http_x_forwarded_for" - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" $remote_addr';

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80 default_server;
        server_name yansiyu.test-zhifu.test.com;
        root /data/dev.www/yansiyu.dev.test.com/public;
        access_log  /data/dev.www/logs/access.log main;
        error_log /data/dev.www/logs/error.log;
        index index.html index.php;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            if ($host !~ (.*news\.test\.com$|.*test\.com$|.*test\.com$)) {
                        fastcgi_pass 127.0.0.1:9055;
                }
                if ($host ~ .*news\.test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }
                if ($host ~ .*test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }

                if ($host ~ .*test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }

                if ($host ~ .*test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }

        }
    }

}


nginx.conf

worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '"$http_x_forwarded_for" - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" $remote_addr';

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80 default_server;
        root /data/dev.www/${host}/public;
        access_log  /data/dev.www/logs/access.log main;
        error_log /data/dev.www/logs/error.log;
        index index.html index.php;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            if ($host !~ (.*news\.test\.com$|.*test\.com$)) {
                        fastcgi_pass 127.0.0.1:9055;
                }
                if ($host ~ .*news\.test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }
                if ($host ~ .*test\.com$) {
                        fastcgi_pass 127.0.0.1:9072;
                }


        }
    }

}

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:lnmp lua编译安装 出自老鄢博客 | 欢迎分享