[精讚] [會員登入]
3101

[Centos7] 安裝apache+php7+mariadb10+selinux

Centos7 安裝apache+php7+mariadb10+selinux

分享此文連結 //n.sfs.tw/11045

分享連結 [Centos7] 安裝apache+php7+mariadb10+selinux@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2022-10-07 12:27:57 最後編修
2017-05-10 12:54:41 By 張○○
 

自動目錄

OS

CentOS Linux release 7.3.1611 (Core)

安裝apache

# yum install httpd

 

開啟防火牆 Selinux

# firewall-cmd --zone=public --add-port=80/tcp --permanent

# firewall-cmd --reload

開啟SELINUX

# setsebool httpd_can_network_connect on

# setsebool httpd_can_network_connect_db on

# setsebool httpd_can_sendmail on

要讓httpd寫入的目錄,例如上傳目錄
# chcon -t httpd_sys_rw_content_t /path/to/upload

要讓httpd讀取的目錄,例如網頁目錄 (預設的/var/www/html已設定)
# chcon -R -t httpd_sys_content_t /path/to/html

安裝PHP7[1]

如果你已有安裝其他版本的PHP,請先移除它們

# yum remove php*

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

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

# yum install php70w php70w-opcache

# yum install php70w-mysqlnd php70w-mbstring php70w-gd

# yum install php70w-pecl-imagick

===  111.10.6 更新,因為此時的php版本已經到7.4.x[2] =====

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

# yum -y install yum-utils

# yum-config-manager --enable remi-php74

主要使用 remi來更新

# yum update

# yum install php php-cli

# php -v
PHP 7.4.32 (cli) (built: Sep 28 2022 09:09:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

 

設定 vi /etc/php.ini

; 時區
date.timezone =  "Asia/Taipei"
; Session 時間改一天
session.gc_maxlifetime = 86400
; 記憶體,預設128M
memory_limit = 1024M
; 上傳大小限制和時間
post_max_size = 20M
upload_max_filesize = 20M
max_input_time = 120
default_socket_timeout = 600

安裝mariadb10.9

建立 yum repository

# vim /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.9/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

# yum install MariaDB-server MariaDB-client

 

安裝 phpmyadmin

到官網 https://www.phpmyadmin.net/ 找尋下載連結

# cd /var/www/html
# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
# unzip phpMyAdmin-5.2.0-all-languages.zip

修改設定檔

# cd phpMyAdmin-5.2.0-all-languages/ 請視版本修改目錄
# mv config.sample.inc.php config.inc.php
# vi config.inc.php

 

去 [3] phpMyAdmin blowfish secret generator 取得secret,這個頁面只要點開就會隨機產生一組,只要貼上即可

$cfg['blowfish_secret'] = 'l54xE78nRD;7Fiz{K85X5e{U9iwm7k;X';

建立暫存目錄以提升速度

# mkdir tmp
# chmod 777 tmp
# chcon -t httpd_sys_rw_content_t tmp

開啟頁面,警告消失。

 

啟動

# systemctl enable httpd

# systemctl enable mariadb

# systemctl start mariadb

# systemctl start httpd

你的檔案放在 /var/www/html中

開你的網頁 http://x.x.x.x/ 來測試能不能看到歡迎畫面,我發現這頁還是responsive web design。

如果出現forbidden代表selinux或檔案權限問題,如果等很久沒頁面是防火牆問題。

其他的問題原因太複雜得CASE by CASE

參考資料

[1] https://webtatic.com/packages/php70/

[2] https://computingforgeeks.com/how-to-install-php-7-4-on-centos-7/

[3] https://phpsolved.com/phpmyadmin-blowfish-secret-generator

END

你可能感興趣的文章

[Centos7] 安裝apache+php7+mariadb10+selinux Centos7 安裝apache+php7+mariadb10+selinux

[Centos7] selinux 修改網頁連線的埠號 想把網頁改到非標準的80埠,在selinux上要如何修改?

移除ssl 私鑰的密碼 現在用ssl產生私鑰會需要設定密碼,但是私鑰有密碼,啟動apache會失敗。

[CentOS8] 1.安裝JULIA 安裝及開始使用 JULIA

[Rocky9] 安裝docker 安裝docker

[Centos8] linux 上的Base64加解密指令 在linux上很方便的指令可以加解密 base64

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

談借錢 人借錢時手心向上頭向下,人還錢時手心向下頭向上

PHP for sphinx 函式庫安裝 PECL/sphinx PHP>= 5.2.2 已經能原生支援 sphinx,可是預設的沒有裝,我們得自己裝才能用

UTF8中文字/全形一覽 快速查詢urf-8的中文字,共計13246中文字(5401常用字+7652罕用字+日文或編號),292全形符號,27半形符號。

TFTP Server 安裝及使用 讓設備的網路設定檔或是韌體經由TFTP拷備出來,操作的方法

世紀帝國征服者新版本--被遺忘的帝國 世紀帝國征服者新版本--被遺忘的帝國 世紀二代的征服者是精典遊戲中的精典,aofe更好玩...