nginx与mysql传输过程_某互联网企业技术发展史(四)配置nginx和mysql兼容Yii框架,上传网站并调试成功...
昨天安装好了php、nginx和squid,今天配置mysql和nginx,使nginx兼容Yii框架,并上传网站,将网站调试和配置好。
1, 首先配置下php的时区
# vi /etc/php.ini
date.timezone = "Asia/Chongqing"
# service php-fpm restart
若没有配置时区,php页面可能会出现如下错误:
date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead
2,配置mysql数据库
默认情况下mysql只有root用户,并只可以本地登录,昨天已经修改了root的密码。
我们将创建一个新用户,并且为管理员级别,且可以远程登录,这样我们就可以使用mysql administrator tool进行远程管理,mysql远程管理端口是3306,在下一步将配置防火墙允许3306端口。
先用root登录mysql,查询账号信息:
# mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.67 Source distribution
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.查询账号信息:
mysql> select host, user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *3DC3333qE11EEF04038E306BC8779D651 |
| 127.0.0.1 | root | |
| localhost | | |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)添加可远程登录的新管理员账号:
mysql> GRANT ALL PRIVILEGES ON *.* TO testroot@"%" IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
查询当前账号信息:
mysql> select host, user,password from user;
+--------------+-------+-------------------------------------------+
| host | user | password |
+--------------+-------+-------------------------------------------+
| localhost | root | *3DC8AE44442111DE11EEF04038E306BC8779D651 |
| 127.0.0.1 | root | |
| localhost | | |
| % | testroot | *3DC8AE08411DE11EEF04038E306BC8779D651 |
+--------------+-------+-------------------------------------------+
4 rows in set (0.00 sec)删除匿名账户:
mysql> delete from user where user='';
3, 配置防火墙,允许远程登录mysql管理
# iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
或者
# vim /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
这样,就可以使用mysql管理工具使用testroot账号远程登录进行管理了。
4,导入网站数据库,创建网站数据库用户
使用mysql管理工具将数据库备份还原到该服务器数据库中;
为网站创建普通账号testweb,只允许本地登录,赋予该账号对网站数据库的读写更新等权限。
这样网站就可以使用该账号连接数据库了。
5,上传网站源代码和Yii框架
Yii框架位于网站根目录下yii目录:
/var/www/html/yii
网站目录位于根目录下的testweb目录下:
/var/www/html/testweb
配置网站数据库信息。
5,配置nginx支持Yii框架
由于网站使用了Yii框架,需要nginx实现rewrite的功能。
nginx配置如下:
/etc/nginx/nginx.conf
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 50000;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.conf
server {
listen 8080;
server_name localhost;
charset utf-8;
access_log /var/log/nginx/log/host.access.log main;
location / {
root /var/www/html;
index index.html index.htm default.htm default.html index.php default.php;
add_header Content-Type "text/html; charset=UTF-8";
add_header Content-Encoding "gzip";
}
# Disable logging for favicon
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Disable logging for robots.txt
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~* \.(jpg|jpeg|png|gif|css|js|swf|mp3|avi|flv|xml|zip|rar)$ {
expires 7d;
gzip on;
gzip_types text/plain application/x-javascript text/css application/xml;
root /var/www/html;
}
location ~ /.svn/* {
deny all;
access_log off;
log_not_found off;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
# yii configuration
include conf.d/yii.common.conf.internal;
#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 /usr/share/nginx/html;
}
}
/etc/nginx/conf.d/yii.common.conf.internal
# BEGIN yiiframework.conf
# Block access to protected, framework, and nbproject (artifact from Netbeans)
location ~ /(yii|protected|framework|nbproject) {
deny all;
access_log off;
log_not_found off;
}
# Block access to theme-folder views directories
location ~ /themes/\w+/views {
deny all;
access_log off;
log_not_found off;
}
# Attempt the uri, uri+/, then fall back to yii's index.php with args included
# Note: old examples use IF statements, which nginx considers evil, this approach is more widely supported
location /testweb {
index index.php;
try_files $uri $uri/ /testweb/index.php?$args;
}
重启nginx:
# service nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
浏览器中输入网址:http://192.168.1.18/testweb/ 即可访问到网站内容,请求首先经过squid,再转发到nginx,然后经过php解析器。
至此,网站初步配置基本完成,剩下调优和细化的工作了。
nginx与mysql传输过程_某互联网企业技术发展史(四)配置nginx和mysql兼容Yii框架,上传网站并调试成功...相关推荐
- 某互联网企业技术发展史(四)配置nginx和mysql兼容Yii框架,上传网站并调试成功...
昨天安装好了php.nginx和squid,今天配置mysql和nginx,使nginx兼容Yii框架,并上传网站,将网站调试和配置好. 1, 首先配置下php的时区 # vi /etc/php.in ...
- ELK学习8_ELK数据流传输过程_问题总结1
数据流传输过程描述: 使用Java程序,读取本地的.csv文件: 发送给集群中的Kafka: Kafka将数据传给Logstash,这个过程中,Logstash中设置有filter,对字符串进行匹配或 ...
- mysql还书过程_记一次安装 MySQL 的过程
记一次安装 MySQL 的过程 一直以来我用的 MySQL 都是从官网下载的zip压缩包,解压后自己配置的.但是这次安装时遇到了几个坑,特别在这里记录一下. 再次更新, 今天安装 MySQL 8.0. ...
- php mysql盲注_[题目]记一次利用gopher的内网mysql盲注
进去之后随便输账号密码登陆, 发现是个send.php在url后缀中,疑似文件包含,尝试用phpfilter发现可以任意读取,把源码down下来之后发现是个利用gopher的ssrf,题目已经提示得很 ...
- java用mysql方便吗_面试题总结:可能是全网最好的MySQL重要知识点
标题有点标题党的意思,但希望你在看了文章之后不会有这个想法--这篇文章是作者对之前总结的 MySQL 知识点做了完善后的产物,可以用来回顾MySQL基础知识以及备战MySQL常见面试问题. 什么是My ...
- mysql打印语句_最全总结 | 聊聊 Python 数据处理全家桶(Mysql 篇)
点击上方"AirPython",选择"加为星标" 第一时间关注 Python 技术干货! 1. 前言 在爬虫.自动化.数据分析.软件测试.Web 等日常操作中, ...
- nfine框架 上传文件_网站服务器Nginx运行环境,后台文件上传超出Nginx的最大值...
解决方法: 1.修改Nginx的配置文件(一般是:nginx/nginx.conf),在 http{} 段中增大nginx上传文件大小限制 #设置允许发布内容为8M client_max_body_s ...
- 安装mysql没有密码_如何在没有密码提示的情况下安装MySQL?
问题描述 我试图在没有密码提示的情况下在Ubuntu Natty上安装MySQL.但是,在主安装后的某个阶段,我总是不断提示输入密码. 另外,当我输入我认为应该是我的密码(mymysqlpass)的密 ...
- mysql gtid 同步_结合案例说说5.7使用gtid同步后,mysql.gtid_executed引起的从库gtid断层...
结合案例说说5.7使用gtid同步后,mysql.gtid_executed引起的从库gtid断层,从库重复拉取主库数据,导致数据在从库被重复执行; mysql.gtid_executed,5.7.5 ...
最新文章
- 用.net中的socket实现文件传输
- (LeetCode 203)Remove Linked List Elements
- windowsxp的自动更新关闭后怎么能不提示?
- BZOJ3028食物——生成函数+泰勒展开
- 超好看倒计时特效单页html模板源码下载
- EtherCAT是什么?
- oracle 慕课课程_我在慕课网学习到的oracle
- android excel读取和写入_Python科普帖 csv amp; excel
- MAC SSH密钥登陆
- 电镜的成像原理-冷冻电镜成像技术1
- Ubuntu 第2章 基本命令和文件系统
- MSDP配置(anycast RP)
- 使用typedef定义数据类型
- trimmed ICP及其在PCL代码解析与使用
- 2.4G无线音频双向传输技术运用
- python from用法_python学习笔记1_import与from方法总结
- 面试官:2 年招到 18 个前端教你怎么招人
- WIN10系统在中国知网下载期刊封面、扉页、目录的PDF版本
- Relief特征提取算法实战
- Java练习——输入n个数,存入数组,进行排序输出
热门文章
- pycharm Application cannot start in headless mode
- pytorch dropout用法
- pytorch 维度练习
- No module named 'tf_extended'
- 'numpy.float64' object cannot be interpreted as an integer
- VS2012创建ATL工程及使用MFC测试COM组件
- python二分法查找
- 使用Python和OpenCV检测图像中的物体并将物体裁剪下来
- HOG可视化 opencv
- 帝国cms清除html标签,帝国CMS结合项筛选带已选择的条件和删除操作的方法