centos7.4安装php7.2套件
程序员文章站
2022-07-13 14:36:09
...
# 操作系统 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
# 所谓套件,就是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
上一篇: git常用命令
下一篇: centos7 时间同步
推荐阅读
-
Ubuntu如何安装php7.2、php7.3、php7.4?(方法详解)
-
ubuntu怎么安装php7.2
-
php集成套件服务器xampp安装使用教程(适合第一次玩PHP的新手)
-
ANSYS Electronics Suite Desktop 18.0增强套件破解安装图文教程
-
movavi video suite 17套件 中文注册激活破解安装教程(附破解补丁下载)
-
ANSYS Electronics Suite Desktop 18.0增强套件破解安装图文教程
-
centOS7.4 安装 mysql 5.7.26的教程详解
-
Centos7 Yum安装PHP7.2流程教程详解
-
php集成套件服务器xampp安装使用教程(适合第一次玩PHP的新手)
-
阿里云 CentOS7.4 安装 Python3.6的方法讲解