LNMP环境部署-上线qqfarm:
一、LNMP介绍
LNMP是指一组软件名称首字母缩写。
L指Linux;N指Nginx;M一般指MySQL,也可以指MariaDB;P一般指PHP,也可以指Perl或Python。
LNMP代表的就是:Linux+Nginx+MySQL+PHP这种网站服务器架构。
Linux是一个基于UNIX的操作系统,是目前最流行的免费操作系统。代表版本有:Debian、CentOS、Ubuntu等。
Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。
Mysql是一个小型关系型数据库管理系统。
MariaDB 数据库管理系统是 MySQL 数据库的一个分支,完全兼容 MySQL 数据库,主要由开源社区维护。
PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。
这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
二、项目环境
- 腾讯云服务器(使用VMware虚拟机也可以)
- CentOS操作系统
- Finalshell远程连接工具
- 相关程序
三、清理环境
[root@VM-0-5-centos ~]# setenforce 0 #临时关闭selinux
[root@VM-0-5-centos ~]# systemctl stop firewalld #关闭防火墙
[root@VM-0-5-centos ~]# systemctl disable firewalld #开机禁用防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
四、LNMP环境部署
- 安装Nginx
[root@VM-0-5-centos ~]# yum install -y epel-release wget vim bash-completion lrzsz unzip #安装工具
[root@VM-0-5-centos ~]# yum -y install nginx #安装nginx
- 安装PHP
[root@VM-0-5-centos ~]# yum -y install php php-fpm php-curl php-intl php-mcrypt php-mysql php-mbstring php-xml php-dom php-gd gd
- 安装mysql
[root@VM-0-5-centos ~]# yum install -y mariadb mariadb-server
五、启动服务及设置开机启动
[root@VM-0-5-centos ~]# systemctl start nginx
[root@VM-0-5-centos ~]# systemctl start mariadb
[root@VM-0-5-centos ~]# systemctl start php-fpm
[root@VM-0-5-centos ~]# systemctl enable nginx
[root@VM-0-5-centos ~]# systemctl enable mariadb
[root@VM-0-5-centos ~]# systemctl enable php-fpm
六、服务配置
- 数据库配置
[root@VM-0-5-centos ~]# mysql -u root -e 'create database farm;'
- Nginx配置
[root@VM-0-5-centos ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@VM-0-5-centos ~]# mv /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
[root@VM-0-5-centos ~]# vim /etc/nginx/nginx.conf # 修改配置文件中的一下配置
...
43 location / {
44 root html; ==>改为 root /webroot/farm;
45 index index.html index.htm; ==>改为 index index.php index.html index.htm;
46 }
...
... ...
65 #location ~ \.php$ {
66 # root html;
67 # fastcgi_pass 127.0.0.1:9000;
68 # fastcgi_index index.php;
69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
70 # include fastcgi_params;
71 #}
==>改为
65 location ~ \.php$ {
66 root /webroot/farm;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
70 include fastcgi_params;
71 }
- php配置
[root@VM-0-5-centos ~]# vim /etc/php.ini
将short_open_tag = Off 改为 On
七、重启服务
[root@VM-0-5-centos ~]# systemctl restart nginx
[root@VM-0-5-centos ~]# systemctl restart php-fpm
八、上线产品(qqfarm)
[root@VM-0-5-centos ~]# mkdir -p /webroot/farm
[root@VM-0-5-centos ~]# rz # 上传包
[root@VM-0-5-centos ~]# unzip farm-ucenter1.5.zip # 解压包
[root@VM-0-5-centos ~]# cp -rf upload/* /webroot/farm
[root@VM-0-5-centos ~]# chown -R nginx.nginx /webroot/farm
[root@VM-0-5-centos ~]# mysql -u root farm <./upload/qqfarm.sql
九、安装向导
- 复制自己服务器的ip地址
- 在浏览器地址栏输入ip地址打开网页
到这里我们发现需要更改文件目录权限才能继续安装,并且需要更改的文件全在 /webroot/farm/ 下,那么直接将路径下的所有文件修改权限
[root@VM-0-5-centos ~]# ls /webroot/farm/
bbs home index.php install logo.jpg qqfarm.sql ucenter
[root@VM-0-5-centos ~]# chmod -R 777 /webroot/farm/ #对目录递归修改
- 权限修改完成后,刷新网页,然后下一步
- 填写相关信息
- 使用默认导航页为首页
- 安装信息,防止忘记可以保存一下
- 入口界面,点击"网络家园"进入
- 进入主页,点击左下角"QQ农场"
- qqfarm部署完成,可体验游戏,后台用户管理,修改用户参数