yum安装LNMP环境 Centos7.6+ php7.3

22 篇文章 1 订阅
11 篇文章 0 订阅

写在前面的

以前一直使用lnmp一键安装包 ,开发也够用了 。近期接触到生产环境的布置 再使用lnmp 一键安装总有些不放心 , 索性自己尝试使用yum 安装 记录安装的过程 方便大家借鉴以及自己查阅 。 不喜勿喷

1安装nginx

  • 获取yum 源
    nginx官方源
    在这里插入图片描述
    注意楼主选用的是centos的源 可以根据自己的系统进行设置 复制选中部分
  • 进入yum管理并且设置nginx 源文件
cd /etc/yum.repos.d/#进入源目录
vim nginx.repo #新建且编写nginx源文件   将上面复制的内容粘贴至此  保存
#测试yum 源是否设置成功
yum list | grep nginx
  • 安装nginx
yum -y install nginx

#测试是否成功
nginx -v

安装php7.2

  • php7.2 版本的 yum 源在 webtatic 上,但还有一部分需要依赖 epel-release
yum  install -y epel-release
#安装 安装 REMI 源
rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#查看php可以安装的包
yum list | grep php72

安装php7.2(包含了提供的所有扩展)
-----------------------------------分割线废弃 star--------------------------------------------------

##7.2调试 废弃 yum --enablerepo=remi-php73 install php
##7.2调试 废弃 yum install -y  php73  php73-build php73-php php73-php-ast php73-php-bcmath php73-php-brotli php73-php-cli php73-php-common php73-php-componere php73-php-dba php73-php-dbg php73-php-devel php73-php-embedded php73-php-enchant php73-php-fpm php73-php-gd php73-php-geos php73-php-gmp  php73-php-imap php73-php-interbase php73-php-intl php73-php-ioncube-loader php73-php-json php73-php-ldap php73-php-libvirt php73-php-libvirt-doc php73-php-litespeed php73-php-lz4 php73-php-maxminddb php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-odbc php73-php-opcache php73-php-pdo-dblib php73-php-pear php73-php-pecl-ahocorasick php73-php-pecl-amqp php73-php-pecl-apcu php73-php-pecl-apcu-bc php73-php-pecl-apcu-devel php73-php-pecl-apfd php73-php-pecl-base58 php73-php-pecl-bitset php73-php-pecl-cassandra php73-php-pecl-cmark php73-php-pecl-couchbase2 php73-php-pecl-crypto php73-php-pecl-csv  php73-php-pecl-datadog-trace php73-php-pecl-dbase php73-php-pecl-decimal php73-php-pecl-dio php73-php-pecl-druid  php73-php-pecl-ds php73-php-pecl-eio php73-php-pecl-env php73-php-pecl-ev php73-php-pecl-event php73-php-pecl-fann php73-php-pecl-gearman php73-php-pecl-gender php73-php-pecl-geoip  php73-php-pecl-geospatial  php73-php-pecl-gnupg php73-php-pecl-grpc php73-php-pecl-handlebars php73-php-pecl-hdr-histogram php73-php-pecl-hprose php73-php-pecl-hrtime php73-php-pecl-http php73-php-pecl-http-devel php73-php-pecl-http-message php73-php-pecl-igbinary php73-php-pecl-igbinary-devel  php73-php-pecl-inotify php73-php-pecl-ip2location php73-php-pecl-json-post php73-php-pecl-krb5 php73-php-pecl-krb5-devel  php73-php-pecl-leveldb php73-php-pecl-lua php73-php-pecl-luasandbox php73-php-pecl-lzf php73-php-pecl-mailparse php73-php-pecl-mcrypt php73-php-pecl-memcache php73-php-pecl-memcached php73-php-pecl-memprof php73-php-pecl-mogilefs php73-php-pecl-molten php73-php-pecl-mongodb  php73-php-pecl-mosquitto php73-php-pecl-msgpack php73-php-pecl-msgpack-devel php73-php-pecl-mustache php73-php-pecl-mysql php73-php-pecl-mysql-xdevapi php73-php-pecl-mysqlnd-azure php73-php-pecl-nsq php73-php-pecl-oauth  php73-php-pecl-opencensus php73-php-pecl-parle php73-php-pecl-pcov php73-php-pecl-pdflib php73-php-pecl-pq php73-php-pecl-propro php73-php-pecl-propro-devel php73-php-pecl-protobuf  php73-php-pecl-psr php73-php-pecl-psr-devel php73-php-pecl-radius php73-php-pecl-raphf  php73-php-pecl-raphf-devel php73-php-pecl-rar php73-php-pecl-rdkafka php73-php-pecl-redis4 php73-php-pecl-request php73-php-pecl-rpminfo php73-php-pecl-rrd php73-php-pecl-runkit7  php73-php-pecl-scoutapm php73-php-pecl-scrypt php73-php-pecl-sdl php73-php-pecl-seasclick  php73-php-pecl-seaslog php73-php-pecl-selinux php73-php-pecl-skywalking php73-php-pecl-solr2 php73-php-pecl-sphinx php73-php-pecl-ssdeep php73-php-pecl-ssh2 php73-php-pecl-stats php73-php-pecl-stomp php73-php-pecl-svm php73-php-pecl-svn php73-php-pecl-swoole4 php73-php-pecl-sync php73-php-pecl-taint php73-php-pecl-tcpwrap php73-php-pecl-termbox php73-php-pecl-timecop php73-php-pecl-trace  php73-php-pecl-translit php73-php-pecl-uploadprogress php73-php-pecl-uuid php73-php-pecl-uv php73-php-pecl-varnish php73-php-pecl-vld php73-php-pecl-xattr  php73-php-pecl-xdebug php73-php-pecl-xdiff  php73-php-pecl-xhprof  php73-php-pecl-xlswriter php73-php-pecl-xmldiff php73-php-pecl-xmldiff-devel php73-php-pecl-xxtea php73-php-pecl-yac php73-php-pecl-yaconf php73-php-pecl-yaconf-devel  php73-php-pecl-yaf php73-php-pecl-yaml php73-php-pecl-yar php73-php-pecl-yaz php73-php-pecl-zip php73-php-pecl-zmq php73-php-pggi php73-php-pgsql php73-php-phalcon3 php73-php-phpiredis php73-php-pinba php73-php-process php73-php-pspell php73-php-recode php73-php-smbclient php73-php-snappy php73-php-snmp  php73-php-snuffleupagus php73-php-soap php73-php-sodium php73-php-tidy php73-php-wkhtmltox php73-php-xml php73-php-xmlrpc php73-php-zephir-parser php73-php-zephir-parser-devel php73-php-zstd php73-runtime php73-scldevel php73-unit-php php73-xhprof php73-zephir

-----------------------------------分割线废弃 end--------------------------------------------------

 yum install -y mod_php72w php72w-cli php72w-fpm php72w-common php72w-devel  php72w-bcmath  php72w-dba php72w-embedded php72w-enchant php72w-gd php72w-imap php72w-interbase php72w-intl php72w-ldap php72w-mbstring   php72w-odbc php72w-opcache php72w-pdo php72w-pdo_dblib php72w-pear  php72w-pecl-apcu php72w-pecl-apcu-devel php72w-pecl-geoip php72w-pecl-igbinary php72w-pecl-igbinary-devel php72w-pecl-imagick php72w-pecl-imagick-devel  php72w-pecl-libsodium php72w-pecl-memcached  php72w-pecl-mongodb  php72w-pecl-redis  php72w-pecl-xdebug php72w-pgsql php72w-phpdbg php72w-process php72w-pspell php72w-recode  php72w-snmp php72w-soap php72w-sodium  php72w-tidy php72w-xml php72w-xmlrpc

在指定目录下创建index.php文件(楼主创建在home文件下写入phpinfo();)
在这里插入图片描述
配置nginx 到访问目录

cd /etc/nginx/conf.d/ #新建index.conf 文件
vim index.conf# 内容如下
server {
    listen 8080;
    server_name localhost;
    root /home;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php index.html index.htm;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        root /home;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

重启nginx

systemctl restart nginx
systemctl start php-fpm

访问8080 端口
在这里插入图片描述
配置成功

  • 安装mysql
安装 mysql 官方 yum 源
rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
#查看 yum 源
yum list | grep mysql
#关闭 80 包,开启 57 包
yum-config-manager --disable mysql80-community
yum-config-manager --enable mysql57-community
#安装 mysql57
yum -y install mysql-community-server mysql-community-client
#启动mysql
systemctl start mysqld
#查看密码
grep 'temporary password' /var/log/mysqld.log
#修改密码
mysql -uroot -p
# 输入密码
set password for root@localhost = password('你的密码');
#如果提示错误,那是因为 mysql57 对密码的复杂度进行了限制,依次执行下列命令,取消复杂度限制,再修改
set global validate_password_policy=0;
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=3;
set global validate_password_special_char_count=0;
set global validate_password_length=3;

  • 写在后面的
    配置php.ini
vim /etc/php.ini //修改配置如下
cgi.fix_pathinfo=1 
max_execution_time = 0 
max_input_time = 300
memory_limit = 256M
post_max_size = 100M  
upload_max_filesize = 10M

修改用户组

vim /etc/php-fpm.d/www.conf 
#将下面的apache改成nginx  如下 
user =  nginx 
group =  nginx

#改变目录的组和用户
chown nginx.nginx /usr/lib64/php/modules
#修改目录下所有文件所属
chown -R nginx.nginx /usr/share/nginx/html
#修改目录下所有文件权限
chmod -R 777 /usr/share/nginx/html

至此 lnmp安装成功

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值