LNMP配置+yii环境
1、配置环境
(1)Ubuntu14.04 x86_64 [Kernel Version: 3.16.0-30-generic]
(2)Nginx1.4.6
(3)MySQL5.5
(4)PHP5.5.9
2、安装方式
暂不采用源码编译安装,使用apt-get install方式安装。以后为了满足自定义需求,最好做成deb安装包。
3、具体安装过程
(1)MySQL
# apt-get install mysql-server php5-mysql ##安装过程中会提示设置mysql的root用户密码
(2)Nginx
(3)PHP # apt-get install php5-fpm php5-cli (4)Yii 去Yii官网下载Yii框架源码,解压缩与/var/www/目录下,并将文件名修改成yii。 我是用的是yii1.1.16版本。 4、配置 配置主要的目的是隐藏Yii框架url中的index.php;对于Nginx与PHP的配置,网上资料繁多。
server { listen 80 default_server; #listen [::]:80 default_server ipv6 ## listen for ipv6 root /var/www/; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name localhost; set $yii_bootstrap "index.php"; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. #try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules try_files $uri $uri/ /$yii_bootstrap?$args; } #avoid processing of calls to unexisting static files by yii location ~ ^/(protected|framework|themes/\w+/views) { deny all; } location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { try_files $uri =404; } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} 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 /var/www/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini #let yii catch the calls to unexising PHP files set $fsn /$yii_bootstrap; if (-f $document_root$fastcgi_script_name){ set $fsn $fastcgi_script_name; } # With php5-cgi alone: #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; #fastcgi_index index.php; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fsn; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fsn; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} location ~ /\. { deny all; access_log off; log_not_found off; } }
Nginx能正常启动
# vim /etc/php5/fpm/php.ini
找到cgi.fix_pathinfo选项,取消注释,并将<span style="white-space:pre"> <?php   </span> <span style="white-space:pre">phpinfo(); ?></span></span>
(1)网站是否能工作
网站首页显示没有问题,但是所有的菜单点击后都有404错误
下面是Yii工程url的配置(protected/config/main.php)
下面是菜单栏的路径配置
(2)隐藏Yii url中的index.php
之前nginx的配置是按照yii官方文档配置的,然而并没有什么卵用。Google搜索了许多资料,不外乎修改"location /"中的配置。
1)解决方案1
location /{
try_files $uri $uri/ /index.php?$request_uri;
}
提示$yii_bootstrap变量内容就是inde.php
但是还是404错误
2)解决方案2
也是然并卵
5、结论:只得换装Apache
这个好配,之前的提供的官方链接就能解决问题
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了LNMP配置+yii环境,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

session_start()iscucialinphpformanagingusersessions.1)ItInitiateSanewsessionifnoneexists,2)resumesanexistingsessions,and3)setsasesessionCookieforContinuityActinuityAccontinuityAcconActInityAcconActInityAcconAccRequests,EnablingApplicationsApplicationsLikeUseAppericationLikeUseAthenticationalticationaltication and PersersonalizedContentent。

在MySQL中,添加字段使用ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column,删除字段使用ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop。添加字段时,需指定位置以优化查询性能和数据结构;删除字段前需确认操作不可逆;使用在线DDL、备份数据、测试环境和低负载时间段修改表结构是性能优化和最佳实践。

要安全、彻底地卸载MySQL并清理所有残留文件,需遵循以下步骤:1.停止MySQL服务;2.卸载MySQL软件包;3.清理配置文件和数据目录;4.验证卸载是否彻底。

MySQL批量插入数据的高效方法包括:1.使用INSERTINTO...VALUES语法,2.利用LOADDATAINFILE命令,3.使用事务处理,4.调整批量大小,5.禁用索引,6.使用INSERTIGNORE或INSERT...ONDUPLICATEKEYUPDATE,这些方法能显着提升数据库操作效率。

MySQL函数可用于数据处理和计算。1.基本用法包括字符串处理、日期计算和数学运算。2.高级用法涉及结合多个函数实现复杂操作。3.性能优化需避免在WHERE子句中使用函数,并使用GROUPBY和临时表。

Composer是PHP的依赖管理工具,通过composer.json文件管理项目依赖。1)解析composer.json获取依赖信息;2)解析依赖关系形成依赖树;3)从Packagist下载并安装依赖到vendor目录;4)生成composer.lock文件锁定依赖版本,确保团队一致性和项目可维护性。

在macOS上安装MySQL可以通过以下步骤实现:1.安装Homebrew,使用命令/bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"。2.更新Homebrew,使用brewupdate。3.安装MySQL,使用brewinstallmysql。4.启动MySQL服务,使用brewservicesstartmysql。安装后,可通过mysql-u

使用EXPLAIN命令可以分析MySQL查询的执行计划。1.EXPLAIN命令显示查询的执行计划,帮助找出性能瓶颈。2.执行计划包括id、select_type、table、type、possible_keys、key、key_len、ref、rows和Extra等字段。3.根据执行计划,可以通过添加索引、避免全表扫描、优化JOIN操作和使用覆盖索引来优化查询。
