tp5项目上线Nginx的配置
-
进入/usr/local/nginx/conf/vhost目录下打开 www.myworld.com.conf
修改 root /home/wwwroot/www.bao.cn/public;
添加 location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
2. 进入/usr/local/nginx/conf 打开 fastcgi.conf
注释 fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
若没有开启pathinfo 就添加
location ~ ^(.+\.php)(.*)$ {
# try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(\/?.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
# 强制将某些非法地址交给 index.php 处理
set $new_fastcgi_script_name $fastcgi_script_name;
if (!-e $document_root$fastcgi_script_name) {
set $new_fastcgi_script_name "/index.php";
}
fastcgi_param SCRIPT_FILENAME $document_root$new_fastcgi_script_name;
fastcgi_param SCRIPT_NAME $new_fastcgi_script_name;
}
location /nginx_status
{
stub_status on;
access_log off;
}
服务器上的数据库允许外网连接
1.mysql配置my.cnf 是否不允许外网访问
[root@VM_71_45_centos ~]# vim /etc/my.cnf
找到里面bind-address
将bind-address = 127.0.0.1
设置成bind-address = 0.0.0.0(设备地址)或者直接注释该行
设置完重启mysql
2.修改mysql数据库user表
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypasswd' WITH GRANT OPTION;
上面root为用户名,mypasswd为密码 all为全部权限。接着执行命令:
FLUSH PRIVILEGES;
3.安全组问题,需要登陆你的云服务控制台,在安全组里面添加响应的端口即可。
4. 禁止防火墙或者配置端口允许访问
注:由于linux有不同的版本系统,禁止防火墙命令也不一样