`
xieye
  • 浏览: 804193 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

centos7.4安装php7.2套件

阅读更多
# 操作系统 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

     [root@node1 ~]#chkconfig iptables off

     [root@node1 ~]#vi /etc/selinux/config
       修改:SELINUX=disabled

CentOS7

     [root@node1 ~]# systemctl disable firewalld
     Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
     Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
     [root@node1 ~]# systemctl stop firewalld


     [root@node1 ~]# setenforce 0
     [root@node1 ~]# vi /etc/selinux/config
     SELINUX=disabled

配置iptables

yum install iptables-services

vim /etc/sysconfig/iptables

*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-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

       [root@node1 ~]#yum install -y wget

3.2  下载aliyun的repo

      [root@node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3.3  更新镜像源

       [root@node1 ~]#yum clean all

       [root@node1 ~]#yum makecache


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



2
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics