CentOS8 安装部署Apache+Php+MariaDB(pdo扩展)
使用新的CentOS8系统架设PHP服务器,因现在主流数据库mysql已闭源了,所以现在改为使用MariaDB.而php7以后不支持mysqli链接,只有pdo方式,为了安装pdo扩展,所以重新编译安装了PHP,折腾很久才完成,收获还是不错的,了解了很多方面的知识.
安装Apache
- 安装
yum -y install httpd - 开启apache服务
systemctl start httpd.service - 设置apache服务开机启动
systemctl enable httpd.service - 开启防火墙
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload - 验证apache服务是否安装成功
打开http://xx.xx.xx.xx/,apache默认的页面--有Testing 123...字样
安装PHP
- 安装工具与软件
yum install -y wget tar nano - 下载并解压PHP源码
cd /home
wget https://www.php.net/distributions/php-7.3.13.tar.gz
tar -xzf php-7.3.13.tar.gz php-7.3.13
- 安装编译工具与依赖
yum install -y gcc make gcc-c++ libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl-devel postgresql-devel libpng libjpeg-devel libjpeg libpng-devel freetype freetype-devel libicu-devel libzip cmake
- 安装libsodium
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
tar -zxf libsodium-1.0.18-stable.tar.gz libsodium-stable
cd libsodium-stable
./configure --prefix=/usr
make && make check
php-devel
- 创建用户与群组
groupadd www
useradd -g www www
- 内连ldap
ln -sv /usr/lib64/libldap* /usr/lib/
- 安装libzip
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
make -j4
make install
- 添加搜索路径到配置文件
nano /etc/ld.so.conf
在文件最后添加
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
- 更新配置
ldconfig -v - 配置php源码
cd /home/php-7.3.13
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --enable-gd-jis-conv --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-maintainer-zts --with-ldap=shared --without-gdbm --with-apxs2=/usr/bin/apxs
编译与安装
make && make install- 将路径加入到系统环境变量中
nano /etc/profile
在最后加入PHP路径:
PATH=$PATH:/usr/local/php/bin
export PATH
保存后,在任意地方尝试运行php -version成功。
- 修改Apache配置
nano /etc/httpd/conf/httpd.conf
#在LoadModule后面添加:(未添加.php文件会变成下载)
LoadModule php7_module modules/libphp7.so
#在DirectoryIndex后面添加index.php:(让网站默认显示页面)
DirectoryIndex index.html index.php
#在AddType application/x-gzip .gz .tgz后面添加:
AddType application/x-httpd-php .php //.php前面有一个空格
然后重启Apache服务
systemctl restart httpd.service
安装MariaDB
- 安装MariaDB
yum install mariadb-server -y - 重启MariaDB
systemctl restart mariadb.service - 设置MariaDB权限与密码等
- 登陆MariaDB:无密码
mysql -uroot有密码用mysql -uroot -p123456 - 显示数据库
show databases; - 选择数据库
use mysql; - 查询用户
SELECT host,user,password from user; - 设置密码
set password for 'root'@'localhost' =password('123456'); - 远程连接设置
grant all privileges on *.* to root@'%'identified by '123456'; - 如果是不是root则先新建用户
create user '用户名'@'%' ip地址 by '密码'
- 设置防火墙
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --reload
至此数据库已经可以连接了(windows客户端可以使用HeidiSQL来连接数据库)
CentOS8 安装部署Apache+Php+MariaDB(pdo扩展)的更多相关文章
- Apache入门篇(一)之安装部署apache
一.HTTPD特性 (1)高度模块化:core(核心) + modules(模块) = apache(2)动态模块加载DSO机制: Dynamic Shared Object(动态共享对象)(3)MP ...
- CentOS7.5 安装部署Apache+Mysql+Php
系统:CentOS7.5 安装Apache 安装 yum -y install httpd 开启apache服务 systemctl start httpd.service 设置apache服务开机启 ...
- 安装部署Apache Hadoop (本地模式和伪分布式)
本节内容: Hadoop版本 安装部署Hadoop 一.Hadoop版本 1. Hadoop版本种类 目前Hadoop发行版非常多,有华为发行版.Intel发行版.Cloudera发行版(CDH)等, ...
- Docker容器里部署Apache+PHP+MariaDB+phpMyAdmin
前面讲到了创建MariaDB,这次在前面的基础上搭建phpMyAdmin服务,以便友好的管理数据库MariaDB.MariaDB的docker独立出来,这样方便管理,易于扩展.这次我们基于Docker ...
- Linux下安装配置Apache+PHP+MariaDB
一.安装apache 1.下载并安装apache yum install httpd 2.启动apache systemctl start httpd.service 3.停止apache syste ...
- 安装部署Apache Hadoop (完全分布式模式并且实现NameNode HA和ResourceManager HA)
本节内容: 环境规划 配置集群各节点hosts文件 安装JDK1.7 安装依赖包ssh和rsync 各节点时间同步 安装Zookeeper集群 添加Hadoop运行用户 配置主节点登录自己和其他节点不 ...
- [日常] ubuntu下安装php pdo扩展和导入数据库
默认安装的php不存在pdo扩展,因此在使用到的时候会报错,直接使用这个命令 apt-get install php-mysql 就可以成功安装pdo扩展 安装完数据库后需要导入sql语句,先进入数据 ...
- CentOS 7.0安装配置LAMP服务器(Apache+PHP+MariaDB)
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止fir ...
- CentOS 7 安装 Apache PHP MariaDB
准备篇: 一.配置防火墙,开启80端口.3306端口 CentOS 7 默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl sto ...
随机推荐
- curl基本用法
curl 是一种命令行工具,作用是发出网络请求,然后获取数据,显示在"标准输出"(stdout)上面. 以下是博主整理的一些关于curl命令的基本用法. -A/--user-age ...
- 分享一个linux系统中循环遍历两个数组内容,并输出数组中的不同内容的shell脚本
cat diffarray.sh #!/bin/bash arry_list1=(1 2 3 4 5 6 7 8 9) arry_list2=(3 5 8) declare -a diff_list ...
- Java常用的日志框架
1.Java常用日志框架对比 https://www.jianshu.com/p/bbbdcb30bba8 2.Log4j,Log4j2,Logback日志框架性能对比 https://bbs.hua ...
- [Git] 016 远程仓库篇 第三话 删除远程仓库
1. 来到自己的 GitHub 页面,先点右上角自己的头像,再点 "Your profile" 2. 选择自己的某个远程仓库,我选 "git_skills" 3 ...
- freemarker进阶--项目中使用
1.工程引入依赖 <dependency> <groupId>org.freemarker</groupId> <artifactId>freemark ...
- qt undefined reference to `vtable for subClass'
1. 建立一个console工程 QT -= gui CONFIG += c++ console CONFIG -= app_bundle # The following define makes y ...
- 搜索专题: HDU1372Knight Moves
Knight Moves Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- Neo4j源代码分析
1.下载neo4j源码 https://github.com/neo4j/neo4j/ 参考文章 原文地址:https://blog.csdn.net/e15273/article/details/7 ...
- django2.0url的变动
WARNINGS:?: (urls.W001) Your URL pattern '^$' uses include with a route ending with a '$'. Remove th ...
- Xdex(百度版)脱壳工具基本原理
[原创]Xdex(百度版)脱壳工具基本原理作 者: sherrydl时 间: 2015-12-13,10:52:45链 接: http://bbs.pediy.com/showthread.php?t ...