LNMP环境搭建
环境信息
system:CentOS7
ipaddr:10.86.29.56
netmask:255.255.255.192
gateway:10.86.29.62
DNS1:101.226.4.6
DNS2:8.8.8.8
修改yum
#将原yum更名
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载阿里云镜像进行替换
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除缓存
yum clean all
#生成缓存
yum makecache
#测试
yum install vim* wget* -yNginx
#创建编辑
vi /etc/yum.repos.d/nginx.repo
-----------------------------------
[nginx]
name = nginx repo
baseurl = https://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck = 0
enabled = 1
-----------------------------------
#安装nginx
yum install -y nginx
#备份配置文件
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.backup
#编辑替换原有配置内容
vim /etc/nginx/conf.d/default.conf
-----------------------------------
server {
listen 80;
root /usr/share/nginx/html;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#
location / {
index index.php index.html index.htm;
}
#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;
}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-----------------------------------
#启动nginx
systemctl start nginx
#开机自启nginx
systemctl enable nginx
#查看nginx运行状态
systemctl status nginx
#
cd /usr/share/nginx/html/
rm -rf index.html
vim index.html
--------------
22403XX
--------------
systemctl restart nginx#访问测试 http://10.86.29.56
MySQL
rpm -qa | grep mariadb
rpm -qa | grep mysql
yum remove mariadb-* #*代表版本,根据情况修改
cd /usr/local
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
ls
vi /etc/yum.repos.d/mysql-community.repo
--------------------------------------------
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0 #<---修改为0,默认为1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
--------------------------------------------
yum install -y mysql-community-server
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqldPHP
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
systemctl start php-fpm
systemctl enable php-fpm
echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
systemctl restart nginx#访问测试 http://10.86.29.56/index.php
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Vincent Cassano