centos7上安装LNMP(php7)

前端之家收集整理的这篇文章主要介绍了centos7上安装LNMP(php7)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本篇笔记主要讲解如何在centos7.x下配置LNMP环境,其中PHP版本为7.x。如果需要配置6.x的,请参考

安装一些常用的源

EPEL源

centos6
yum install http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
centos7
yum install http://mirrors.yun-idc.com/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

mysql源

#centos6
yum install http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
#centos7
yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

nginx源

#centos6
yum install http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
#centos7
yum install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

全量更新一遍

yum update

参考链接:

安装PHP7

第一步,安装YUM源

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

第二步,安装PHP7.1和相关依赖库

sudo yum install -y mod_PHP71w PHP71w-cli PHP71w-common PHP71w-gd PHP71w-mbstring PHP71w-mcrypt PHP71w-MysqLnd PHP71w-xml PHP71w-devel

第三步,Step 3: configure PHP 7.x

sudo cp /etc/PHP.ini /etc/PHP.ini.bak
sudo vi /etc/PHP.ini

安装PHP-fpm

yum install -y PHP7.1-fpm

安装redis

yum install -y redis

安装git

yum install -y git

安装PHP的redis扩展

git clone git://github.com/nicolasff/PHPredis.git
cd PHPredis
PHPize
./configure
make
sudo -s make install

sudo -s
echo "extension=redis.so">/etc/PHP.d/redis.ini
exit

参考:

检测是否有安装:

php -m | grep redis

安装nginx

yum install -y nginx

安装mysql

sudo yum install -y mysql-server
sudo systemctl start mysqld

然后,secure mysql

mysql_secure_installation

安装composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

安装php-fpm

先安装php的源

yum install -y php71w-fpm

安装tmux

yum install -y tmux

配置redis

调整daemon状态

配置php-fpm

调整运行用户,deploy
权限问题,会导致nginx层报错,说script file 找不到的问题

配置nginx

- 调整运行用户,如deploy
- 调整对应文件夹的权限
    - 全局的日志文件夹权限
    - 默认的缓存文件夹

配置系统的文字系统

vi /etc/environment

LC_ALL=en_US.utf-8
LANG=en_US.utf-8

配置基础用户

useradd -m deploy

useradd www
usermod -a -G deploy www
usermod -aG wheel deploy

optional

配置iptables

参考:

原文链接:https://www.f2er.com/centos/419677.html

猜你在找的CentOS相关文章