lnmp环境搭建

xshell 安装  xshell官网:https://www.xshell.com/zh/xshell/  可以免费试用

yum(软件包管理)工具安装

mkdir yum  --创建目录

wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz  --下载安装包

# 安装vim
yum install vim -y

# 安装nginx
yum install -y epel-release
yum install nginx -y

# 查看nginx软件包包括了哪些文件
rpm -ql nginx

# 启动nginx
systemctl start nginx
# 查看nginx是否启动成功
systemctl status nginx
# 设置nginx随机自启动
systemctl enable nginx

# 查看nginx主配置
vim /etc/nginx/nginx.conf

# 新建一个站点
vim /etc/nginx/conf.d/test.actself.me.conf

# 内容如下:
server {
listen 80;
server_name test.actself.me;
root /var/www/test.actself.me;
index index.html;

location \ {
}

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;
}
}

# 查看 fastcgi 相关的配置指令
view /etc/nginx/fastcgi_params

# reload nginx,使新建的站点配置生效
systemctl reload nginx

# 创建网站目录
mkdir -p /var/www/test.actself.me

# 进入网目录,创建index.html和test.php两个文件
cd /var/www/test.actself.me
vim index.html
vim test.php

# 查看linux服务器的ip,因为test.actself.me并没有做域名配置,我们要把这个ip写到/etc/hosts里面才能访问这个域名
ip addr list

# 停止运行防火墙
systemctl stop firewalld

# 安装php7
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum install -y php72.x86_64 php72-php-cli.x86_64 php72-php-fpm.x86_64 php72-php-json.x86_64 php72-php-mbstring.x86_64 php72-php-mysqlnd.x86_64 php72-php-opcache.x86_64 php72-php-pdo.x86_64 php72-php-pecl-amqp.x86_64 php72-php-pecl-igbinary.x86_64 php72-php-pecl-mcrypt.x86_64 php72-php-pecl-memcached.x86_64 php72-php-pecl-msgpack.x86_64 php72-php-pecl-mysql.x86_64 php72-php-pecl-redis.x86_64 php72-php-pecl-yac.x86_64 php72-php-pear.noarch php72-php-pecl-zip.x86_64

# 安装php swoole扩展
yum search php72 | grep swoole
yum install php72-php-pecl-swoole2.x86_64

# 启动php-fpm
systemctl start php72-php-fpm
systemctl status php72-php-fpm
systemctl enable php72-php-fpm

# 查看php-fpm的配置
rpm -ql php72-php-fpm
vim /etc/opt/remi/php72/php-fpm.conf
vim /etc/opt/remi/php72/php-fpm.d/www.conf

# php.ini 的配置
vim /etc/opt/remi/php72/php.ini

# 安装mysql
yum install mariadb-server
systemctl start mariadbv
systemctl start mariadb
systemctl status mariadb
systemctl enable mariadb

 

posted @ 2022-05-19 12:46  shadowsuyan3  阅读(53)  评论(0编辑  收藏  举报