2018.7.3 lnmp一键安装包无人值守版本 php7.2 + nginx1.14.0 + mariadb5.5 + centos7.1(1503) 环境搭建 + Thinkphp5.1.7 配置

给自己练习用的,整个过程追求一个简单粗暴,没有配置虚拟主机,现在记录一下过程.

lnmp安装包下载地址:https://lnmp.org/

首先安装好centos,并且在/home/wwwroot/default/

1. cd /usr/local/src 随后 wget xxxxxxxxxxxxxxxxxxxxx    (xxx为一键安装包地址)

2. 等待安装完毕

3. 进入web根目录,使用composer或者github拉一个项目的原始文件,文件夹命名为tp5,现在是这样的 /home/wwwroot/default/tp5

4. 进入到解压缩后的原配置conf文件夹中 cd /user/local/src/lnmp解压缩目录(蓝字)/conf/rewrite

5. 看到一个thinkphp.conf

6. 将其复制一份到nginx配置文件的同级目录下 cp thinkphp.conf /usr/local/nginx/conf/thinkphp.conf

7. 进入到nginx配置文件目录当中 vim /usr/local/nginx/conf/nginx.conf

8. 因为我这里只是个试验机,所以将root直接改为了 /home/wwwroot/default/tp5/public,如果要管理多个网站的话,还是要配置虚拟主机,然后该掉/usr/local/nginx/conf/vhost/对应网站的conf,这个先撇下不谈.

9. 在同一目录 vim fastcgi.conf 将最后一行前面写上#,注释掉.

10. 将include enable-php.conf;替换为include enable-php-pathinfo.conf; 然后在下一行添加include thinkphp.conf; 

11. vim /home/wwwroot/default/.user.ini 打开web根目录的.user.ini文件,看到只有一行base_dir,改成open_basedir=/home/wwwroot/default/tp5/:/tmp/:/proc/

12. 这时我们来到tp5目录下,使用命令自动生成一个模块 第一步 cd /home/wwwroot/default/tp5 第二步 php think build --module test (test为要创建的模块名)

13. 修改一下新生成的控制器文件 vim application/test/controller/Index.php 将操作中原有的代码替换为 return '测试test模块';

14. 回到tp5/public下面,并修改index.php入口文件,将最后一行改为Container::get('app')->bind('test')->run()->send();

好了,重启一下nginx服务器 service nginx restart,使用浏览器输入localhost/index.php/Index/index 出现"测试test模块",大功告成.至于隐藏index.php这步我还没做,回头再说.

 参考了这两篇文章,感谢其作者.

https://www.cnblogs.com/richerdyoung/p/6514382.html

https://www.augsky.com/998.html

猜你喜欢

转载自www.cnblogs.com/fyydcxy/p/9260575.html