您的位置 首页 php

openeuler LAMP搭建 PHP8.1+maraidb10.6+Apache2.4.54 超详细步骤

centos7安装参考以下链接
CentOS7配置LAMP环境(PHP7.3.6+maraidb10.3+ apache 2.4.39)源码安装超详细步骤

新安装了openeuler 与centos8兼容,新开配置贴

搭建环境笔记,命令都已测

先增加xrdp远程连接,这样就可以远程到图形界面了

最近出于对 linux服务器 的学习,在安装配置的过程中遇到了各种问题,也上网看了许多相关文章,现在终于弄好了,特写此教程向大家分享,也为自己留下学习笔记。

生命不息,折腾不止。

注:如果系统之前已配置过LAMP运行环境,记得先将之前的版本卸载,防止安装过程中出现各种莫名其妙的问题,本教程为全新的CentOS8【openeuler】。

【安装 Apache
安装使用 二进制 安装,方便管理使用
下载 apache 及相关组件 apr、 apr -util、pcre

 [ root @localhost ~]# wget 
[root@localhost ~]# wget 
[root@localhost ~]# wget 
[root@localhost ~]# wget 
COPY  

安装编译所需工具及依赖库

“`shell
[root@localhost ~]# yum install gcc gcc++ gcc-c++ libxml2 libxml2-devel expat-devel -y
[root@localhost ~]# yum install -y expat-devel

 解包并做相关配置
 ```shell
[root@localhost ~]# tar -zxvf httpd-2.4.54.tar.gz
[root@localhost ~]# tar -zxvf apr-1.7.0.tar.gz
[root@localhost ~]# tar -zxvf apr-util-1.6.1.tar.gz
[root@localhost ~]# tar -zxvf pcre-8.45.tar.gz
[root@localhost ~]# mv apr-1.7.0 apr
[root@localhost ~]# mv apr-util-1.6.1 apr-util
[root@localhost ~]# mv apr apr-util httpd-2.4.54/srclib  

安装 pcre

“`shell
[root@localhost ~]# cd pcre-8.45
[root@localhost pcre-
]# ./configure –prefix=/usr/local/pcre8
[root@localhost pcre-
]# make
[root@localhost pcre-*]# make install

 
开始 apache 编译配置,完成后执行安装
```shell
[root@localhost ~]# cd httpd-2.4.54
[root@localhost httpd-*]# ./configure --prefix=/usr/local/apache2 -with-pcre=/usr/local/pcre8/bin/pcre-config -with-included-apr
[root@localhost httpd-*]# make
[root@localhost httpd-*]# make install  

开放防火墙端口并重启防火墙服务(HTTP协议80端口)

 [root@localhost ~]#  firewall -cmd --zone=public --add-port=80/tcp --permanent
[root@localhost ~]# systemctl restart firewalld.serviceCOPY  

添加 apache 开机启动服务

 [root@localhost ~]# cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
[root@localhost ~]# vim /etc/init.d/httpd
在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the  Apache HTTP Server .

[root@localhost ~]# chmod +x /etc/rc.d/init.d/httpd
[root@localhost ~]# chkconfig --add httpd
[root@localhost ~]# chkconfig httpd onCOPY  

查看服务是否添加成功,启动 apache 服务

 [root@localhost ~]# chkconfig --list httpd
[root@localhost ~]# systemctl start httpd.serviceCOPY  

此时在浏览器中输入对应ip地址,将显示如下提示,表示Apache已经开始正常工作

It works!

设置Apache支持PHP

 1 [root@localhost ~]# vim /usr/local/apache2/conf/httpd.conf
 2 找到<IfModule unixd_module>  在该行前面添加  LoadModule php7_module modules/libphp7.so
   搜索x-compress添加内容
 4 AddType application/x-httpd-php .php
 5 AddType application/x-httpd-php-source .php5
 6 
 7 接着找到
 8 <IfModule dir_module>
 9     DirectoryIndex index.html
10 </IfModule>
11 修改为
12 <IfModule dir_module>
13     DirectoryIndex index.html index.php
14 </IfModule>
15 
16 找到
17 DocumentRoot "/usr/local/apache2/htdocs"
18 <Directory "/usr/local/apache2/htdocs">
19 修改为
20 DocumentRoot "/home/www"
21 <Directory "/home/www">
22 此处 /home/www 为你自定义的网站根目录,设置效果如图片-2COPY  

保存退出后创建网站根目录

 1 [root@localhost ~]# mkdir /home/www  

重启Apache服务

 1 [root@localhost ~]# systemctl restart httpd.service  

注意:此时Apache重启后仍然无法解析php,原因为 modules/libphp7.so 文件不存在,当安装完PHP后就能正常解析。

【安装PHP】

为了避免后期麻烦的编译安装或者出现的额问题,作者在安装过程中尽量安装所有功能,所以需要提前安装一些扩展,然后再编译

首先安装 openssl

 yum install openssl

yum install openssl-devel  

安装curl

  wget  
tar zxvf curl-7.84.0.tar.gz##如果选择的是tar.bz2版本 解压使用 tar -jxvfcd curl-7.65.0
./configure --prefix=/usr/local/sysother/curl7   --with-wolfssl
(如果有错,提示没有c相关的编译器,执行#yum install gcc命令)
make
make install</li>  

接下来一堆莫名其妙插件,装就是了

 yum install libpng-devel
yum install freetype-devel
yum install libxslt-devel* -y
dnf install libcurl-devel
yum install gmp-devel -y  
yum install oniguruma-devel -y
yum install readline-devel -y  

下面两个安装
cmake 安装

下载 php 并解包 即可安装8.1.9版本

 [root@localhost ~]# wget  
[root@localhost ~]# tar -zxvf  mirror 

切换至解包好的目录并执行编译配置(--enable-fpm 是为了配合能使用  nginx )
[root@localhost ~]# cd php-8.1.9/
[root@localhost php-7.3.0]# ./configure --prefix=/usr/local/php8 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php8/etc/ --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable- filter  --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache

编译配置完成后执行编译,最后执行安装

[root@localhost php-7.3.0]# make
[root@localhost php-7.3.0]# make install  

此时重启Apache后即可在 /home/www 目录中自行创建php文件进行测试访问

安装 mariadb

文章来源:智云一二三科技

文章标题:openeuler LAMP搭建 PHP8.1+maraidb10.6+Apache2.4.54 超详细步骤

文章地址:https://www.zhihuclub.com/149345.shtml

关于作者: 智云科技

热门文章

网站地图