centos 7.2 安装 php7.2.29+nginx+mysql5.7+swoole扩展

php7.2.29安装

php官网: https://www.php.net/downloads.php

1.从官网找到对应php版本号 鼠标右键复制下载链接地址

2.在/home 目录下面创建一个package文件夹用来存放安装包

cd /home
mkdir package
cd package

3.下载php安装包

wget https://www.php.net/distributions/php-7.2.29.tar.gz

4.安装php7.2.29所需依赖

yum install gcc
yum install libxml2
yum install openssl-devel
yum install libxml2-devel -y
yum -y install curl-devel 
yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
yum install bzip2-devel.x86_64 -y
yum install libXpm-devel -y
yum install gmp-devel -y
yum install -y icu libicu libicu-devel
yum  install  php-mcrypt  libmcrypt  libmcrypt-devel -y
yum install  postgresql-devel -y
yum install libxslt-devel -y
yum -y install libjpeg-devel
yum -y install libxslt-devel
yum install krb5-devel
yum install sqlite-devel
yum install bzip2 bzip2-devel
yum install oniguruma
yum -y install autoconf automake libtool
yum -y install libXpm-devel
yum -y install postgresql-devel
yum install libxslt-devel

5.解压编辑PHP压缩包

tar -xzxvf php-7.2.29.tar.gz #解压7.2.29压缩包

cd php-7.2.29/ #进入解压好的文件

#设置需要编译加载的模块
./configure --prefix=/usr/local/php --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr --with-png-dir=/usr --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu/--enable-ftp --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-iconv --with-xpm-dir=/usr

make clean && make && make install #编译

 

6. 复制配置文件

cp php.ini-development /usr/local/php/lib/php.ini

7.设置php全局命令

vim /etc/profile #打开这个文件 i编辑

#文件最后添加 :wq保存退出
PATH=$PATH:/usr/local/php/bin
export PATH

#然后执行命令
source /etc/profile

8.查看php版本号 php -v 查看编译加载的模块 php -m

9.配置php-fpm

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp /home/package/php-7.2.29/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

10.新建www-data 用户组

groupadd www-data
useradd -g www-data www-data

11.启动fpm,并添加到开机启动项

service php-fpm start #启动fpm
service php-fpm stop #停止pm
chkconfig --add php-fpm #添加到开机启动项

nginx安装

1.选择需要安装的版本

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

yum info nginx

yum install nginx

默认安装目录

config: /etc/nginx/nginx.conf     
config: /etc/sysconfig/nginx
pidfile: /var/run/nginx.pid

日志文件在var/log/nginx

2.配置nginx支持php

cd /etc/nginx/

删掉原本的nginx.conf,复制一份nginx.conf.default的默认配置

rm -rf nginx.conf
cp nginx.conf.default nginx.conf
vim nginx.conf

 在home下新建www目录 项目存放目录,配置php指向目录,这样就可以访问php文件了

server {
         listen       80;
         server_name  localhost;

        #charset koi8-r;
  
          #access_log  logs/host.access.log  main;
  
          location / {
              #修改1:运行目录指向
              root   /home/www;
              # 修改2:这里新增了index.php
              index index.html index.htm index.php;
              # 修改3:这里新增url重写(path)
              try_files $uri $uri/ /index.php$is_args$args;
          }
  
          #error_page  404              /404.html;
  
          # redirect server error pages to the static page /50x.html
          #
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
  
             root   html;
          }
  
          # proxy the PHP scripts to Apache listening on 127.0.0.1:80
          #
          #location ~ \.php$ {
          #    proxy_pass   http://127.0.0.1;
          #}
  
          # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
          #
	      #修改4:解开php支持的注释
          location ~ \.php$ {
              #修改5:php运行目录指向
              root           html;
              #默认就使用php-fpm
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              #修改6:修改fastcig的路径
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include        fastcgi_params;
          }
  
          # deny access to .htaccess files, if Apache's document root
          # concurs with nginx's one
          #
          #location ~ /\.ht {
          #    deny  all;
          #}
      }

启动nginx命令

启动命令    service nginx start

停止命令    service nginx stop

重启命令    service nginx restart

mysql5.7安装

进入mysql官网获取RPM包下载地址:https://dev.mysql.com/downloads/repo/yum/

选择linux系统版本对应的mysql安装包 点击Download

下载完成上传到linux服务器

linux 安装包过大wget下载太慢 我是直接windows本地下载通过远程链接软件直接上传的

我是用的finashell上传 直接文件拖拽就可以

解压mysql文件

tar -xzvf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz 

解压完成后移动重新命名一下mysql文件

mv mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql

cd /usr/local/mysql #进入解压好移动的目录

创建mysql用户组并修改用户权限

#创建mysql用户组
groupadd mysql
useradd -r -g mysql mysql

mkdir -p  /data/mysql              #创建目录
chown mysql:mysql -R /data/mysql   #赋予权限

删除原本的my.cnf文件 新建配置my.cnf文件

rm -rf /etc/my.cnf #删除文件
touch /etc/my.cnf #创建一个新文件
vim /etc/my.cnf #编辑文件

插入如下内容

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true

初始化数据库

cd /usr/local/mysql/bin/ #进入mysql/bin目录

#执行下面语句
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

#查看密码
cat /data/mysql/mysql.err

红色框起来的就是默认的mysql密码

先将mysql.server放置到/etc/init.d/mysql中

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

#启动mysql
service mysql start
#查看mysql进程
ps -ef|grep mysql

启动成功

下面修改密码

进入到mysql/bin目录下

cd /usr/local/mysql/bin
#访问mysql 输入上面查询的密码进入
./mysql -u root -p

执行下面命令修改密码

SET PASSWORD = PASSWORD('123456');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;   

exit;#修改完成退出命令

配置远程连接mysql

./mysql -u root -p
use mysql                                            #访问mysql库
update user set host = '%' where user = 'root';      #使root能再任何host访问
FLUSH PRIVILEGES;    
exit;


#重启mysql
service mysql restart

这样外部就能远程连接mysql数据库了

swoole安装 教程 https://blog.csdn.net/LGDmar/article/details/102680491

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值