Lnmp=Linux+Nginx+MySQL(Mariadb)+PHP
1.下载nginx和php安装包
[root@localhost ~]#yum -y install nginx
[root@localhost ~]#yum -y install php php-fpm php-curl php-intl php-mysql
2.下载mysql安装包
[root@localhost ~]#yum -y install wget
[root@localhost ~]#wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
解压
[root@localhost ~]#rpm -ivh mysql80-community-release-el7-3.noarch.rpm
修改
[root@localhost ~]#vim /etc/yum.repos.d/mysql-community.repo
enabled=0代表不执行安装
enabled=1代表执行安装
这里我们安装MySQL5.7版本的所以更改8.0版本和5.7版本的enabled值
/etc/yum.repos.d/mysql-commnity.repo
enabled=0代表不执行安装
enabled=1代表执行安装
这里我们安装MySQL5.7版本的所以更改8.0版本和5.7版本的enabled值
安装
[root@localhost ~]#yum -y install mysql-server mysql
[root@localhost ~]#systemctl start nginx mysqld php-fpm
3.查看数据库密码
[root@localhost ~]#cat /var/log/mysqld.log | grep password
数据库的原始密码
4.更改数据库密码
[root@localhost ~]#mysqladmin -u root -psXr1>c)d*)<o password MySQL5.7
如果上边命令报错请使用下边命令手动设置
[root@localhost ~]#mysqladmin -u root -p password
设置新密码 必须包含大写字母,小写字母,数字,特殊符号任意三种
数据库密码设置问题
数据库密码设置问题
5.删除nginx的默认配置文件
[root@localhost ~]#rm -rf /etc/nginx/nginx.conf
6.拷贝nginx的默认配置文件模板
[root@localhost ~]#mv /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
7.修改nginx的配置文件
[root@localhost ~]#vim /etc/nginx/nginx.conf
修改前
/etc/nginx/nginx.conf修改前
/etc/nginx/nginx.conf修改前
修改后
/etc/nginx/nginx.conf修改后
/etc/nginx/nginx.conf修改后
8.部署php服务
[root@localhost ~]#vim /etc/php.ini
将short_open_tag = Off 改为 On
[root@localhost ~]#systemctl restart nginx php-fpm
9.创建网站发布目录
[root@localhost ~]#mkdir /farm
到这一步lnmp基本完成,接下来我们以农场为例进行项目部署
1.解压farm-ucenter1.5.zip
[root@localhost ~]#yum -y install unzip
[root@localhost ~]#unzip farm-ucenter1.5.zip
2.将项目移动到解压目录下
[root@localhost ~]#cp -r upload/* /farm
3.权限设置
[root@localhost ~]#chmod 777 /farm -R
或者
[root@localhost ~]#chown -R nginx.nginx /farm
4.数据库导入
[root@localhost ~]#cd /farm/
[root@localhost ~]#mysql -u root -pMySQL5.7 farm < qqfarm.sql
农场部署基本完成
5.浏览器登陆
image.png
image.png
image.png
image.png
image.png
image.png
image.png
农场项目完成
用shell脚本编写
yum -y install nginx
yum -y install php php-fpm php-curl php-intl php-mysql
yum -y install wget
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
mysql=/etc/yum.repos.d/mysql-community.repo
sed -i '21s/enabled=0/enabled=1/' mysql
sed -i '28s/enabled=1/enabled=0/' mysql
yum -y install mysql-server mysql
systemctl start nginx
systemctl start mysqld
systemctl start php-fpm
mysql_password=`cat /var/log/mysqld.log | grep password | awk 'NR==1{print $11}'`
mysqladmin -u root -p$mysql_password password MySQL5.7
rm -rf /etc/nginx/nginx.conf
mv /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
nginx=/etc/nginx/nginx.conf
sed -i -r '44s# root /html;# root /farm;#' nginx
sed -i '45s/ index index.html index.htm;/ index index.php index.html index.htm;/' nginx
vim /etc/php.ini
systemctl start nginx
systemctl start php-fpm
mkdir /farm
网友评论