yum 安装 LNMP
一、安装 nginx
vim /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 yum install nginx -y nginx -v systemctl start nginx systemctl enable nginx
二、安装 mysql 5.7 (mariadb)
yum remove mariadb* wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server systemctl start mysqld.service systemctl enable mysqld.service grep "password" /var/log/mysqld.log #在日志文件中找出root用户的初始密码 2021-07-31T07:55:00.366359Z 1 [Note] A temporary password is generated for root@localhost: ga7%<d<0*jD& //登录 mysql mysql -u root -p Enter password: #输入初始密码 ga7%<d<0*jD& ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123'; #密码设置要求有 大小写字母、数字和符号 组合 grant all privileges on *.* to root@"%" identified by "Admin@123" with grant option; flush privileges; yum -y remove mysql57-community-release-el7-10.noarch #为了防止每次yum操作都会自动更新,卸载这个软件
三、安装 php7.2
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache php72w-redis systemctl start php-fpm systemctl enable php-fpm php -v //配置 nginx 支持 PHP 解析 cd /etc/nginx/conf.d vim default.conf ...... location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; #将 /scripts 修改为nginx的工作目录 include fastcgi_params; } cd /usr/share/nginx/html vim index.php <?php phpinfo(); ?> 浏览器访问:http://192.168.229.90/index.php //测试mysql是否能连接成功 vim /usr/share/nginx/html/index.php <?php $link=mysqli_connect('192.168.229.90','root','Admin@123'); if($link) echo "<h1>Success!!</h1>"; else echo "Fail!!"; ?> 浏览器访问:http://192.168.229.90/index.php
将本人在工作学习中的一些知识记录并分享