Home > php教程 > php手册 > 阿里云下nginx+php+mysql+codeigniter的配置

阿里云下nginx+php+mysql+codeigniter的配置

WBOY
Release: 2016-06-06 19:53:24
Original
1150 people have browsed it

最近开发的站点使用的阿里云的弹性计算A套餐。 使用官方的论坛的一键安装包安装了nginx+php+mysql。要注意的是脚本会提示选择服务器脚本,但是不会选择php版本,默认是5.2.7。由于用到了5.3以上的新特性,比如json_encode支持中文(5.3以下不支持),所以想

最近开发的站点使用的阿里云的弹性计算A套餐。

使用官方的论坛的一键安装包安装了nginx+php+mysql。要注意的是脚本会提示选择服务器脚本,但是不会选择php版本,默认是5.2.7。由于用到了5.3以上的新特性,比如json_encode支持中文(5.3以下不支持),所以想更改,看了以下install.sh,直接把里面的一个叫php变量的由2改成3就行了,安装包里是已经有5.3的包的。

安装好以后将codeigniter 2.2的框架移植过去以后出现了502错误。找了很久,最后在stackflow上看到要确认一下php-fpm的进程是否在。用' ps as | grep php'看,果然没有。于是到php安装文件下找到php-fpm执行一下就行了。

然后碰到的是codeigniter开启clean url后需要rewrite支持的问题,2个地方要注意,一是conf文件,下面贴出我的,具体就不赘述了。

<span> 1</span> server {<br><span> 2</span>         listen       80<span>;<br></span><span> 3</span>         server_name  localhost<span>;<br></span><span> 4</span>     index index.html index.htm index.php<span>;<br></span><span> 5</span>     root /PATH_TO_YOU_ROOT_FOLDER<span>;<br></span><span> 6</span>     <br><span> 7</span>     location / {<br><span> 8</span>             <br><span> 9</span>             index  index.php index.html index.htm<span>;<br></span><span>10</span>             if ( $request_filename !~ (uploads|js|css|views|robots/.txt|index/.php.*) ) {  <br><span>11</span>                 rewrite ^/(.*)$ /index.php/$1 last<span>;</span><span><br></span><span>12</span>                 break<span>;</span><span><br></span><span>13</span>             }  <br><span>14</span> <br><span>15</span>        }<br><span>16</span>     <br><span>17</span>     location ~ /index.php/<br><span>18</span>     {<br><span>19</span>         #fastcgi_pass  unix:/tmp/php-cgi.sock<span>;<br></span><span>20</span>         fastcgi_pass  127.0.0.1:9000<span>;<br></span><span>21</span>         fastcgi_index index.php<span>;<br></span><span>22</span>         include fastcgi.conf<span>;<br></span><span>23</span>  <br><span>24</span>         fastcgi_param  SCRIPT_FILENAME  /PATH_TO_YOU_ROOT_FOLDER/index.php<span>;</span> <span><br></span><span>25</span>         fastcgi_param PATH_INFO $fastcgi_script_name<span>;</span><span><br></span><span>26</span>     }<br><span>27</span> <br><span>28</span>     <br><span>29</span>     log_format  mumoon  '$remote_addr - $remote_user <span>[</span><span>$time_local</span><span>]</span> "$request" '<br><span>30</span>                   '$status $body_bytes_sent "$http_referer" '<br><span>31</span>                   '"$http_user_agent" "$http_x_forwarded_for"'<span>;<br></span><span>32</span>     access_log  /alidata/log/nginx/access/mumoon.log mumoon<span>;<br></span><span>33</span>     error_log  /alidata/log/nginx/error/mumoon.log  debug<span>;<br></span><span>34</span> }
Copy after login

里面有几个地方改成需要的参数就行了。

二是CI的config文件需要修改,将index_page一项变成空的,不要写index.php,写了的话会导致系统不断重定向。

 

顺便一提,阿里云还是挺好用,感觉速度够快,可以很方便的启动停止。在控制台还有个重置功能,相当于重装服务器。

睡觉去了~

Related labels:
Ali
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template