openEuler yum 安装 LNMP 环境
安装 常用软件
yum -y update
yum -y install vim tar wget zip unzip net-tools
yum 安装 nginx
yum -y install nginx
systemctl start nginx.service
systemctl enable nginx.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
yum 安装 PHP8
yum -y install php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis --skip-broken
配置 nginx 支持 PHP
yum -y install php-fpm
systemctl start php-fpm.service
systemctl enable php-fpm.service
修改PHP配置文件如下:
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# 该部分为后追加的整合配置
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
}
编写 PHP 测试页面
vim /usr/share/nginx/html/phpinfo.php
内容如下:
<?php
phpinfo()
重新加载 nginx 配置
systemctl reload nginx.service
yum 安装 mysql
yum -y install https://repo.mysql.com//mysql80-community-release-el8-4.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
systemctl enable mysqld.service
查看初始密码
grep 'temporary password' /var/log/mysqld.log
结果如下:
[root@openEuler nginx]# grep 'temporary password' /var/log/mysqld.log
2022-08-21T05:38:36.448107Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: g.h*q/zFy5!k
使用初始密码登录
mysql -uroot -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lihaozhe!!@@1122';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Lihaozhe!!@@1122';
FLUSH PRIVILEGES;
设置root用户远程客户端访问
update mysql.user set host = '%',plugin='mysql_native_password' where user='root';
FLUSH PRIVILEGES;
退出系统
exit;
重启 mysql 服务
systemctl restart mysqld.service
测试登录
mysql -h 127.0.0.1 -uroot -p
防火墙放行
firewall-cmd --zone=public --add-port=3306/tcp --add-port=33060/tcp --permanent
firewall-cmd --reload
PHP 连接 mysql
yum -y install php-mysqlnd
编写php文件db.php
vim /usr/share/nginx/html/db.php
<?php
$servername = "localhost";
$username = "root";
$password = "Lihaozhe!!@@1122";
try {
$conn = new PDO("mysql:host=$servername;", $username, $password);
echo "连接成功";
}
catch(PDOException $e)
{
echo $e->getMessage();
}
systemctl restart php-fpm
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgffgjj
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01