ITeye博客

centos7.4安装php7.2套件

xieye · 2018-08-24 12:07 · PHP · linux · docker · 编程语言 · Markdown

操作系统 centos7.4

所谓套件,就是nginx,php7.2最新版本,mysql5.7,redis

这是查看centos版本的命令 cat /etc/redhat-release

设置centos的阿里镜像源。

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum install -y wget epel-release yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum install -y yum-utils

设置epel的阿里镜像源。

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum-config-manager --enable remi-php72

设置remi 的清华大学镜像源。

yum-config-manager --setopt=remi-php72.baseurl="https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php72/$basearch/" --save

yum-config-manager --setopt=remi-php56.baseurl="https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php56/$basearch/" --save

yum install -y nginx php72 redis zip unzip p7zip rsync crontabs vim supervisor

yum install -y php72-php-devel php72-php-fpm php72-php-mbstring php72-php-memcache php72-php-redis php72-php-mysqli php72-php-mysqlnd php72-php-pdo php72-php-bcmath php72-php-dom php72-php-gd php72-php-gmp php72-php-igbinary php72-php-imagick php72-php-mcrypt php72-php-pdo_mysql php72-php-posix php72-php-simplexml php72-php-opcache php72-php-xsl php72-php-xmlwriter php72-php-xmlreader php72-php-xml php72-php-swoole php72-php-zip php72-php-phalcon php72-php-yaml

ln -s /usr/bin/php72 /usr/bin/php

sed -i 's/user\ =\ apache/user\ =\ nginx/g' /etc/opt/remi/php72/php-fpm.d/www.conf sed -i 's/group\ =\ apache/group\ =\ nginx/g' /etc/opt/remi/php72/php-fpm.d/www.conf

等效于 vi /etc/opt/remi/php72/php-fpm.d/www.conf

# user=apche, group=apache改成 
user = nginx
group = nginx

echo "location ~ .php$ {root /usr/share/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}" > /etc/nginx/default.d/php.conf

等效于 vi /etc/nginx/default.d/php.conf

    ## enable php support ##
    location ~ \.php$ {
        root /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

vi /usr/share/nginx/html/phpinfo.php

<?php
phpinfo();

systemctl enable php72-php-fpm.service systemctl start php72-php-fpm

systemctl enable nginx.service systemctl start nginx

systemctl enable redis systemctl start redis

打开浏览器

http://127.0.0.1/phpinfo.php

下面一大段 mysql 5.7

wget http://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm yum install -y mysql57-community-release-el7-11.noarch.rpm yum install -y mysql-community-server systemctl start mysqld

这一步查看到初始密码

grep "password" /var/log/mysqld.log

这一步输入刚才的初始密码

mysql -uroot -p

以下语句在mysql的shell里执行,最后一句是设置密码

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; SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123');

下面这句话去除 mysql在yum仓库的记录,避免每次更新。

yum -y remove mysql57-community-release-el7-11.noarch

这句话查看mysql的安装配置

mysql_config

systemctl stop mysqld systemctl start mysqld

git 和composer curl https://setup.ius.io | sh yum remove -y git yum install -y git2u git config --global core.autocrlf false git config --global core.safecrlf false git config --global user.name 'test' git config --global user.email 'test@qq.com'

curl -s http://getcomposer.org/installer | php mv composer.phar /usr/local/bin/ chmod a+x /usr/local/bin/composer.phar ln -s /usr/local/bin/composer.phar /usr/local/bin/composer composer config -g repo.packagist composer https://developer.aliyun.com/composer

=====================================================

关闭防火墙和Selinux CentOS6

 #chkconfig iptables off

 #vi /etc/selinux/config
   修改:SELINUX=disabled

CentOS7

 # systemctl disable firewalld
 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
 Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
 # systemctl stop firewalld


 # setenforce 0
 # vi /etc/selinux/config
 SELINUX=disabled

配置iptables

yum install iptables-services

vim /etc/sysconfig/iptables

*filter :INPUT DROP :FORWARD ACCEPT :OUTPUT ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT

yum restart iptables systemctl enable iptables


更改镜像源

3.1 安装wget

   #yum install -y wget

3.2 下载aliyun的repo

  # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3.3 更新镜像源

   #yum clean all

   #yum makecache

参考 https://blog.csdn.net/chengyuqiang/article/details/55044073

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。