centos7上安装LNMP环境(php5.x)

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

以下操作均在root用户下完成,基于PHP5.x版本的。基于PHP7.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

参考链接:

安装PHP

先安装PHP的源

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

然后,执行下面的命令,安装PHP全家桶

yum install -y PHP56w.x86_64 PHP56w-cli.x86_64 PHP56w-common.x86_64 PHP56w-gd.x86_64 PHP56w-ldap.x86_64 PHP56w-mbstring.x86_64 PHP56w-mcrypt.x86_64 PHP56w-MysqL.x86_64 PHP56w-pdo.x86_64 PHP56w-devel PHP56w-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

yum install -y composer
composer global require "fxp/composer-asset-plugin:~1.2.0"

安装tmux

先安装PHP的源

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

optional

配置iptables

猜你在找的CentOS相关文章