先部署LNMP网站服务器架构
LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。
Linux是目前最流行的免费操作系统。
Nginx是一个高性能的HTTP和反向代理服务器。
Mysql是一个小型关系型数据库管理系统。
PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。
这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
部署前:
systemctl stop firewalld 关闭防火墙
systemctl disable firewalld 关闭防火墙的开启启动
vim /etc/selinux/config
使SELINUX=disabled
reboot
1.部署Nginx:
安装epel 去阿里镜像站下载
然后# yum -y install nginx
systemctl start nginx
systemctl enable nginx
cd /etc/nginx/
rm -rf nginx.conf
mv nginx.conf.default nginx.conf
2.部署php服务
yum -y install php php-cli php-curl php-fpm php-intl php-mcrypt phpmysql php-gd php-mbstring php-xml php-dom
3.安装数据库服务
yum -y install mariadb-server mariadb
systemctl start php-fpm
systemctl start mariadb
4.配置nginx服务
vim /etc/nginx/nginx.conf
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
去掉以下行的注释:
location ~ .php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx
5.配置数据库
mysqladmin -u root password '123'
登录:mysql -uroot -p123
MariaDB [(none)]> grant all on . to root@'%' identified by '123';
flush priviledges 刷新授权表
MariaDB [(none)]> create database 名字;
MariaDB [(none)]> exit
6.php程序测试
1). 测试php文件能否执行
cd /usr/share/nginx/html/
ls
rm -rf ./*
vim index.php<?php
phpinfo();
?>
2). 测试php连接MySQL是否正常
vim index.php
<?php
$link=mysql_connect('localhost','root','123');
if ($link)
echo "Successfully";
else
echo "Failed";
mysql_close();
?>
删除index.php
7.产品上线
下载
解压缩
复制到网站发布目录
edusoho在线视频学习系统上线:
修改配置文件
我们的edusoho 的app.php在web下
修改nginx配置文件改为root /usr/share/nginx/html/web
在index.html前加一个app.php
qqfarm农场上线
浏览器访问
出现提示需要修改php的配置文件才可以安装
修改php配置文件vim /etc/php.ini
short_open_tag=on
source /etc/php.ini 让文件生效
再次刷新页面
如果出现mysql error 1316数据库错误:
是因为数据库没有导入:mysql -u root -p‘123’ qqnong < /usr/share/nginx/html/qqfarm.sql
重新启动数据库服务:
systemctl restart mariadb
转载于:https://blog.51cto.com/14268956/2374981