近期项目开发项目,为记录本期关于开发相关配置,作此记录
一、开发机安装OpenResty
1.安装编译工具、依赖库
yum -y install readline-devel pcre-devel openssl-devel gcc
2.下载openresty-1.13.6.1.tar.gz源码包,并解压
cd /usr/local/phpsoft#我的安装路径是/usr/local/phpsoft
wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
tar -zxvf openresty-1.13.6.1.tar.gz
3.配置安装模块
1>cd openresty-1.13.6.1
2>./configure --prefix=/usr/local/openresty --with-http_ssl_module
3>gmake && gmake install
4.相关配置与启动
1>配置文件路径 /usr/local/openresty/nginx/conf/nginx.conf
2>在配置文件server块中添加 include /usr/local/openresty/nginx/conf/conf.d/*.conf;
3>新建conf.d目录 mkdir conf.d
4>cd conf.d
5>vim qb-test.conf #并添加内容
server {
listen 8081;
server_name localhost;
location / {
root /data/qb-dev/current; #指定php的根目录
#fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000 带#配置需要配置php后开启
#fastcgi_index index.php;
index index.php index.html;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
}
}
6>将/user/local/openresty/open/sbin目录添加到环境变量 export PATH=$PATH:/usr/local/openresty/nginx/sbin
7>重新启动nginx nginx -s reload 停止 nginx -s stop
8>使用 http://39.106.192.148:8081/index.html 访问即可验证
二、安装php7.2.7
1.下载php7.2.7安装包
//在linux下载 有可能出现的是一个mirror文件 我是要mac中下载 然后上传到linux中的
wget http://cn2.php.net/get/php-7.2.7.tar.gz/from/this/mirror
2.解压php-7.2.7.tar.gz
tar -zxvf php-7.2.7.tar.gz
cd cd php-7.2.7
3.安装相关依赖
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl-devel libxslt-devel
4.配置安装模块
./configure --prefix=/usr/local/php7.2 --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-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make && make install
5.copy相关的配置文件
cp php.ini-production /usr/local/php7.2/etc/php.ini
cp /usr/local/php7.2/etc/php-fpm.conf.default /usr/local/php7.2/etc/php-fpm.conf
cp /usr/local/php7.2/etc/php-fpm.d/www.conf.default /usr/local/php7.2/etc/php-fpm.d/www.conf
6.添加系统变量 vim /etc/profile
export PATH=$PATH:/usr/local/php7.2/sbin/
export PATH=$PATH:/usr/local/php7.2/bin
然后 source /etc/profile
7.检测 配置文件是否正确
php-fpm -t
8.重启php-fpm kill 进程号 然后执行php-fpm
三、相关报错的修改
1.nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
产生原因 端口占用 可更换端口 所以我的配置是8081端口
2.nginx遇上Access Denied提示的解决方法
修改/usr/local/php7.2/etc/php-fpm.conf 或 /usr/local/php7.2/etc/php-fpm.d/www.conf 文件中 把常用的都加上
security.limit_extensions=.php .html .js .css .jpg .jpeg .gif .png .htm
3.如果重启时提示nginx:[error] open() '/usr/local/openresty/nginx/logs/nginx.pid' faild(2:No such file or directory)
修改nginx.conf 去掉pid logs/nginx.pid;前的#号
执行nginx -c /usr/local/openresty/nginx/config/nginx.conf
然后nginx -s reload