[精讚] [會員登入]
3217

[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

你可能感興趣的文章

[Rocky9] Sphinx 3支援中文 + Docker + PHP7 使用docker建置sphinxsearch 3

[Centos7 8] postfix+DKIM 設定 信件總是被退?希望別的mail server相信我寄出的信?那麼你可以設定dkim。

[Linux] 刪除last/lastb登出入記錄 linux shell的登出入記錄

[Rocky9] 安裝docker 安裝docker

[Centos6] php5.3升級為php5.6 Centos6 + php5.6 升級

[BASH] 自建檔案拷背程式--把指定的檔案拷背到指定的位置。 Git 是很好用的版本控制程式,但我沒辦法使用。 原因就是資安。用SHELL自建簡易的GIT

隨機好文

[jQuery] textarea 的取值和給值 HTML 的 TEXTAREA 標籤若要用 jquery 取值,不能使用 .text() 或 .html() ,使用 .

UTF-8 BOM (Byte Order Mark) 的問題 在 Michael Kaplan 那看到 Every character has a story #4: U+feff

SELinux 常用指令和檔案 在Redhat系列中,Centos5以後加入了selinux,他並沒有這麼可怕,不必每次看到Selinux ,就想把他

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

設計的工作絕不接受比價 拿買陽春麵的價格想買牛肉麵,寧願倒掉也不賣