Loading... ## lnmp 的一些问题 ## 1. nginx + thinkphp下解决 pathinfo的问题 1. 把 lnmp 下 nginx 的配置文件 nginx.conf 中的 “ include enable-php.conf ” 修改为 “ include enable-php-pathinfo.conf ” 2. 把php配置文件 php.ini 中的 “cgi.fix_pathinfo=0” 修改为 “cgi.fix_pathinfo=1” --- ## 2. lnmp 一键安装之后无法删除虚拟主机的文件夹 在 Linux 里删除目录的时候发现没有办法删除,最后一个一个文件删除,发现是 .user.ini 文件的问题 删除的时候提示 ``` rm: cannot remove `.user.ini': Operation not permitted ``` 无法删除“.user.ini”文件解决方法,运行后 **chattr -i .user.ini** 删除即可 文件可以修改 ``` chattr -i .user.ini ``` 文件不能修改 ``` chattr +i .user.ini ``` chattr 主要提高文件的安全性, chattr 的详细参数查帮助 ## 3. 安装exif模块 安装exif不需要另外安装库,所以省略掉了安装库的步骤。 比如php的源码目录为:``/root/lnmp1.3-full/src/php-5.4.45/`` 则执行:``cd /root/lnmp1.3-full/src/php-5.4.45/ext/`` 我们要安装exif模块,执行``cd exif/`` 再执行``/usr/local/php/bin/phpize``会返回如下信息: ``` Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519 ``` 再执行以下命令: ``` [root@vpser imap]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@vpser imap]# make && make install ``` 执行完返回: ``` Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/ ``` 表示已经成功,再修改``/usr/local/php/etc/php.ini`` 查找:extension = 再最后一个extension= 后面添加上``extension = "exif.so"`` 保存,执行 ``/etc/init.d/php-fpm restart`` 重启。 在 ``/home/wwwroot/`` 下面创建一个 ``exif.php`` 的文件,内容如下: ``` <?php $exif = read_exif_data ('IMG_0001.JPG'); while(list($k,$v)=each($exif)) { echo "$k: $v<br>\n"; } ?> ``` 其中IMG_0001.JPG为照片文件。 ## 4. Lnmp ThinkPHP5 开启pathinfo支持 1. 修改 /usr/local/php/etc/php.ini 文件 ``` 搜索 cgi.fix_pathinfo=0,将其值改为1 ``` 2. 修改/usr/local/nginx/conf/nginx.conf (或者vhost下的)文件,添加 ``` include /usr/local/nginx/conf/enable-php-pathinfo.conf; location / { index index.html index.htm index.php l.php; autoindex off; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } } ``` 3. nginx重新加载配置文件 ``nginx -s relaod`` 修改后的配置文件如下 ``` server { listen 80; server_name www.vm2phplive.io; root "/home/wwwroot/phplive/public"; include /usr/local/nginx/conf/enable-php-pathinfo.conf; location / { index index.html index.htm index.php l.php; autoindex off; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; } } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } ``` 最后修改:2020 年 08 月 28 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 哇卡哇卡