AFFGT
点滴价值

Centos7搭建Nginx、MySQL、PHP

一、安装semanage所需库

1、查看semanage所需库

yum provides /usr/sbin/semanage

 

2、安装semanage所需库

yum install policycoreutils-python

3、查看SELinux允许的端口

semanage port -l | grep http_port_t

4、添加SELinux端口

semanage port -a -t http_port_t -p tcp 2323

二、安装Nginx

1、新建yum源

vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

2、安装nginx

yum -y install nginx

 

三、安装MySQL

1、添加yum源

vim /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

2、安装mysql

yum -y install mysql-community-server

 

四、安装PHP

1、安装EPEL源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

2、安装webtatic源

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

3、修改EPEL源

vim /etc/yum.repos.d/epel.repo //将#注释去掉
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS

4、安装php

yum -y install php72w-fpm php72w-cli php72w-common php72w-gd php72w-mysqlnd php72w-odbc php72w-pdo php72w-pgsql php72w-xmlrpc php72w-xml php72w-mbstring php72w-opcache

 

五、启动Nginx/MySQL/PHP以及设置开机自启动

1、启动

systemctl start nginx
systemctl start mysqld
systemctl start php-fpm

2、开机自启

systemctl enable nginx
systemctl enable mysqld
systemctl enable php-fpm

3、运行状态

systemctl status nginx
systemctl status mysqld
systemctl status php-fpm

4、查看MySQL的初始随机密码

grep ‘temporary password’ /var/log/mysqld.log

5、设置MySQL密码

mysqladmin -u root -p password

赞(0) 打赏
未经允许不得转载:EngineerSharing » Centos7搭建Nginx、MySQL、PHP

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏