一、配置编译参数,使用默认> cd /usr/local/src/

> tar -xvf openresty-1.19.3.1.tar.gz

> cd openresty-1.19.3.1

> ./configure -j2

1、Can't locate File/Temp.pm in @INC (you may need to install the File::Temp module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at ./configure line 9.yum install perl

2、./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre= option.

ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx ...yum -y install pcre-devel

3、./configure: error: SSL modules require the OpenSSL library.

You can either do not enable the modules, or install the OpenSSL library

into the system, or build the OpenSSL library statically from the source

with nginx by using --with-openssl= option.

ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx ...yum -y install openssl openssl-develConfiguration summary

+ using system PCRE library

+ using system OpenSSL library

+ using system zlib library

nginx path prefix: "/usr/local/openresty/nginx"

nginx binary file: "/usr/local/openresty/nginx/sbin/nginx"

nginx modules path: "/usr/local/openresty/nginx/modules"

nginx configuration prefix: "/usr/local/openresty/nginx/conf"

nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf"

nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid"

nginx error log file: "/usr/local/openresty/nginx/logs/error.log"

nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"

nginx http client request body temporary files: "client_body_temp"

nginx http proxy temporary files: "proxy_temp"

nginx http fastcgi temporary files: "fastcgi_temp"

nginx http uwsgi temporary files: "uwsgi_temp"

nginx http scgi temporary files: "scgi_temp"

cd ../..

Type the following commands to build and install:

gmake

gmake install

二、编译gmake-L/usr/local/src/openresty-1.19.3.1/build/luajit-root/usr/local/openresty/luajit/lib -L/usr/local/src/openresty-1.19.3.1/build/luajit-root/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,--require-defined=pcre_version -Wl,-E -Wl,-E -ldl -lpthread -lcrypt -L/usr/local/src/openresty-1.19.3.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -L/usr/local/src/openresty-1.19.3.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -lpcre -lssl -lcrypto -ldl -lpthread -lz \

-Wl,-E

sed -e "s|%%PREFIX%%|/usr/local/openresty/nginx|" \

-e "s|%%PID_PATH%%|/usr/local/openresty/nginx/logs/nginx.pid|" \

-e "s|%%CONF_PATH%%|/usr/local/openresty/nginx/conf/nginx.conf|" \

-e "s|%%ERROR_LOG_PATH%%|/usr/local/openresty/nginx/logs/error.log|" \

< docs/man/nginx.8 > objs/nginx.8

gmake[2]: Leaving directory '/usr/local/src/openresty-1.19.3.1/build/nginx-1.19.3'

gmake[1]: Leaving directory '/usr/local/src/openresty-1.19.3.1/build/nginx-1.19.3'

三、安装gmake install

这里不知道为啥跟步骤二返回一致,指南里是分步骤命令,但这里好像是gmake和gmake install 同时执行了

四、使用

从官方的入门使用教程中,感觉跟nginx本身单独安装并无二样;

nginx默认装在openresty安装目录下;可以完全看成一个单独的nginx,按照以前的经验使用;

openresty到底增强了nginx什么,需要在后续使用中发现;

安装就到此结束

四、使用

1、配置nginx配置文件

我们可能会建多个项目,因此会用到虚拟主机配置。这里按常规采用一个主配置,加载多个虚拟主机配置的方式user www;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

log_format main '$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;

#虚拟主机配置 自动加载

include /usr/local/openresty/nginx/conf/nginx.conf.vhost/*.conf;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index 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;

}

# 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 Apache's document root

# concurs with nginx's 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 ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

}

虚拟主机配置# another virtual host using mix of IP-, name-, and port-based configuration

#

server {

charset utf-8;

listen 80;

server_name blog.54skyer.cn;

set $root /home/www/blog.54skyer.cn/public;

root $root;

#root /home/www/blog.54skyer.cn/public;

index index.php index.html;

# 指定某个目录可以被直接访问

location /54skyer/ {

autoindex on;

}

location / {

# 如果根目录下匹配不是脚本 默认在根目录后拼一个index.php 这是为了在url中省略index.php

if (!-e $request_filename){

rewrite ^(.*) /index.php/$1 last;

break;

}

}

#pathinfo配置 使支持tp5的标准url

location ~ .+\.php($|/) {

fastcgi_pass 127.0.0.1:9000;

fastcgi_split_path_info ^((?U).+.php)(/?.+)$;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;

include fastcgi_params;

}

# 匹配到php扩展名的url

#location ~\.php$ {

# include /usr/local/openresty/nginx/conf/fastcgi.conf;

# fastcgi_intercept_errors on;

# #转发给php-fpm,其端口是9000;

# fastcgi_pass 127.0.0.1:9000;

#}

}

# HTTPS server

#

#server {

# listen 443 ssl;

# server_name localhost;

# ssl_certificate cert.pem;

# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;

# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;

# ssl_prefer_server_ciphers on;

# location / {

# root html;

# index index.html index.htm;

# }

#}

2、配置开机自启动> vim /etc/init.d/nginx

# 复制粘贴脚本代码,保存退出

> chmod a+x /etc/init.d/nginx # 设置可执行权限

> chkconfig --add nginx # 注册成服务

> chkconfig nginx on # 设置开机自启动

> reboot # 重启检测自否开机自启动

> ps aux | grep nginx

#或 netstat -nplt | grep nginx

复制粘贴自启脚本如下#! /bin/bash

# Startup script for the nginx Web Server

# chkconfig: - 85 15

# description: nginx is a World Wide Web server. It is used to serve

PATH=/usr/local/openresty/nginx

DESC="nginx daemon"

NAME=nginx

DAEMON=$PATH/sbin/$NAME

CONFIGFILE=$PATH/conf/$NAME.conf

PIDFILE=$PATH/logs/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME

set -e

[ -x "$DAEMON" ] || exit 0

do_start() {

$DAEMON -c $CONFIGFILE || echo -n "nginx already running"

}

do_stop() {

$DAEMON -s stop || echo -n "nginx not running"

}

do_reload() {

$DAEMON -s reload || echo -n "nginx can't reload"

}

case "$1" in

start)

echo -n "Starting $DESC: $NAME"

do_start

echo "."

;;

stop)

echo -n "Stopping $DESC: $NAME"

do_stop

echo "."

;;

reload|graceful)

echo -n "Reloading $DESC configuration..."

do_reload

echo "."

;;

restart)

echo -n "Restarting $DESC: $NAME"

do_stop

do_start

echo "."

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2

exit 3

;;

esac

exit 0

openresty 支持php,从零搭建php环境-openresty相关推荐

  1. 从零搭建gitlabci环境

    从零搭建gitlabci环境 学习途径 搭建环境 将gitlab镜像拉到服务器上跑起来. 1]拉取镜像 使用docker拉取gitlab/gitlab-ce的镜像 docker拉取nginx镜像 #查 ...

  2. fastdfs 吗 支持windows_从零搭建分布式文件系统MinIO比FastDFS要更合适

    前两天跟大家分享了一篇关于如何利用FastDFS组件来自建分布式文件系统的文章,有兴趣的朋友可以阅读下<用asp.net core结合fastdfs打造分布式文件存储系统>.通过留言发现大 ...

  3. 从零搭建WNMP环境

    WNMP环境搭建步骤 三大件安装 Nginx安装 PHP安装 MySQL安装 三大件配置 Nginx配置 PHP配置 MySQL配置 三大件联调 PHP连接Nginx PHP连接MySQL 常用脚本和 ...

  4. 8uftp如何创建php,从零搭建php环境-php8

    一.下载 1.https://www.php.net/distributions/php-8.0.0.tar.gz下载到本地,文件传输上传到 /usr/local/src/ 2.wget -P /us ...

  5. Mac从零搭建开发环境

    原文来自我的博客 手上一台几乎闲置的mbp mid 2015,最近升级了Big Sur,感觉焕然一新,想作为主力机使用了,毕竟硬件配置比公司给的低配mbp还好一截.按照现在习惯的开发环境,重新装了一遍 ...

  6. 从零搭建angular环境和初项目

    打开CMD, 第一步,确认电脑是否安装node.js               输入  node -v 第二步,确认是否安装git    git version 若没安,访问   https://w ...

  7. 从零搭建LNMP环境(三) - 安装MySQL数据库服务器

    2019独角兽企业重金招聘Python工程师标准>>> 废话不多说,虽然可以通过yum直接安装MySQL,但是为了能够对安装过程有一个比较清晰的认识, 我们这里还是使用源码编译安装. ...

  8. visual studio学习python_python3从零学习-开发环境搭建之Visual Studio Code篇

    开发环境搭建之Visual Studio Code篇 上一节讲了Python环境的安装和开发环境的安装,本节再重点讲下Visual Studio Code的配置.安装 请看我上一篇文章<pyth ...

  9. 从零搭建一个 Spring Boot 开发环境!Spring Boot+Mybatis+Swagger2 环境搭建

    从零搭建一个 Spring Boot 开发环境!Spring Boot+Mybatis+Swagger2 环境搭建 本文简介 为什么使用Spring Boot 搭建怎样一个环境 开发环境 导入快速启动 ...

最新文章

  1. 精解C++的switch语句
  2. Ubantu使用笔记
  3. 程序员:我用代码给女朋友P图
  4. python可以调用windows资源吗_在Windows中使用Python设置文件夹权限
  5. Nginx之二:nginx.conf简单配置(参数详解)
  6. css常见样式命名思想
  7. API函数简介 转自洪恩在线
  8. LCD12864图形点阵液晶显示模块中文资料介绍
  9. SHOPEX网店系统测试 50万家网站的安全令人担忧
  10. 批量合并工作簿,包含三种合并方式,Excel技能演示
  11. Linux 克隆虚拟机以及克隆之后引起的“Device eth0 does not seem to be present, delaying initialization”问题解决...
  12. 好玩免费的api接口
  13. 空域图像增强-图像灰度变换
  14. 复旦java_复旦大学
  15. SEO培训: 《搜索引擎优化知识完全手册》
  16. LoRa 节点侧学习笔记_汇总
  17. 理光R5445系列 单节锂电池保护芯片,内置驱动器高位Nch FET开关温度保护
  18. codemirror 常见操作
  19. 天地图JSAPI4.0切换地图事件
  20. F-投入产出练习的A + B(VI)

热门文章

  1. 【Linux】Supervisor使用详解
  2. Jenkins Pipeline 小试牛刀以及引入指定的环境变量
  3. 北京时间与UTC时间转换
  4. 哔咔漫画无响应,无法安装正确的应用
  5. 评委打分表模板_系高中英语作文模板——邀请信
  6. 什么是克鲁斯卡尔算法?
  7. 幼儿抽象逻辑思维举例_幼教科目二丨幼儿认知的发展(思维)
  8. 编程逻辑性思维的重要性
  9. 2022 年最受欢迎的 19个 VS Code 主题排行榜
  10. VR全景开发学习链接Three.js