企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
[TOC] ### 安装 #### 下载lnmp压缩包 lnmp官网 `https://lnmp.org/download.html` 根据相关命令进行安装 `tar zxf 文件 解压 bunzip2 文件 解压 ` #### 相关目录位置 > php-fpm重启: ` /etc/init.d/php-fpm restart ` > php配置文件: `usr/local/php/etc/php.ini` > nginx配置文件: `/usr/local/nginx/conf/nginx.conf` > > 引入其他目录的站点配置文件: `include /etc/nginx/conf.d/*.conf;` > 站点使用的php:`/usr/local/nginx/conf/enable-php.conf` > 站点使用的路径:`/usr/local/nginx/conf/pathinfo.conf` (默认未使用) > > > fastcgi配置: `/usr/local/nginx/conf/fastcgi.conf` > 目录限制注释掉:`open_basedir=$document_root/:/tmp/:/proc/`(修改后不生效重启php) #### 问题 > 路径问题 `enable-php.conf` 引入 pahtinfo.php 或使用下面的pathinfo #### nginx配置 ``` # 转发 server { listen 80; server_name "dev-api.xxx.cn"; access_log /home/nginx/log/dev-api.bnssz.cn.log main; set $port 38418; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Connection "keep-alive"; proxy_pass http://127.0.0.1:$port/$host_prefix$request_uri; } } # 路径 server { listen 80; server_name dev-api.xxx.cn; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/access.log; } ``` #### pathinfo.conf ``` set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; ``` ### 安装扩展 部分扩展-lnmp包自带: > `./addons.sh install {eaccelerator|xcache|memcached|opcache|redis|imagemagick|ioncube|sg|exif|fileinfo|ldap|bz2|sodium|imap|swoole}` > 安装mongodb: `pecl install mongodb`