日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

用yum源配合源码包安装openresty、mariadb、php7服务

發布時間:2024/4/13 php 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用yum源配合源码包安装openresty、mariadb、php7服务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在開始部署之前,有必要先簡單介紹一下!

????OpenResty 是一個基于 Nginx 與 Lua 的高性能 Web 平臺,其內部集成了大量精良的 Lua 庫、第三方模塊以及大多數的依賴項。用于方便地搭建能夠處理超高并發、擴展性極高的動態 Web 應用、Web 服務和動態網關。

????MariaDB服務器是一個在世界上最流行的數據庫服務器。這是由原始開發者的MySQL,并保證保持開放源碼。MariaDB是因為它速度快,可擴展性和魯棒性,具有豐富的生態系統,存儲引擎,插件和許多其他工具,使各種各樣的用例非常靈活。

????PHP,我想就不必再絮叨多少了吧。

那我們就開始新的學習之旅吧!


1、? 前期準備(最小化安裝的系統)

? ? 1.更新系統

????yum makecache && yum -y update

????2.安裝常用基礎軟件

????yum -y install bash-completion vim net-tools bind-utilswget screen

????最后別忘了重啟

?

2、? 更新yum源(阿里云源:mirrors.aliyun.com

[root@localhost~]# mv /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup

[root@localhost~]# ls /etc/yum.repos.d/

CentOS-Base.repo.backup? CentOS-fasttrack.repo? CentOS-Vault.repo

CentOS-CR.repo??????????CentOS-Media.repo

CentOS-Debuginfo.repo???CentOS-Sources.repo

先關閉fastestmirror

[root@localhostyum.repos.d]# vi /etc/yum/pluginconf.d/fastestmirror.conf ?(enabled=0)

[root@localhost yum.repos.d]# wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost yum.repos.d]# yumclean all

[root@localhost yum.repos.d]# yum makecache


3、? 安裝mariadb

????1.添加mariadb yum資源庫

????vi /etc/yum.repos.d/MariaDB.repo

????[mariadb]

????name= MariaDB

????baseurl= http://yum.mariadb.org/10.1/centos7-amd64

????gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

????gpgcheck=1

????2.可以使用yum search MariaDB 查看安裝包,官方給出的只要安裝serverclient就行,其他的根據?

??????自己的需要來

????yum?install?MariaDB-server?MariaDB-client

????注意:雖然說是只需添加系統服務,并啟動數據庫就完事了,但我也有幾次還是報錯(個人建議使

??????????用我以下的步驟)

????[root@localhost ~]# yum search mariadb


????這時會出現好多的軟件,你只需用yum安裝即可

[root@localhost ~]# yum -y install MariaDB-backupMariaDB-client MariaDB-common MariaDB-compat MariaDB-connect-engineMariaDB-cracklib-password-check MariaDB-devel MariaDB-gssapi-clientMariaDB-gssapi-server MariaDB-oqgraph-engine MariaDB-server? MariaDB-shared MariaDB-test mariadb-benchmariadb-devel mariadb-embedded mariadb-embedded-devel mariadb-libs mariadb

????網上也有帖子說是要初始化一下,我也試了,無非就是設置數據庫的一些配置,像是否刪除測試數據庫,是否禁止遠程登錄數據庫,是否刪除用命用戶什么的,后面可以跟配置項—defaults-file--datadir--user等,感覺沒多大卵用(廢話有點多,回到原題)

? ? [root@localhost my.cnf.d]# mysql_secure_installation


????3.加入系統服務

??????[root@localhost ~]# systemctl enable mariadb

????? [root@localhost ~]# systemctl start mariadb.service

????? [root@localhost ~]# systemctl stop mariadb.service


???????提醒:通過yum裝很多東西都是默認的,不像源碼編譯或者自己DOWN安裝包可以各種指定,列

?????一些比較重要的路徑出來

? ? yum 安裝會自動創建mysql 用戶和用戶組

? ? Yum安裝會自動創建 /etc/my.cnf 以及/etc/my.cnf.d 文件架(并存放 server.conf????client.conf ?tokudb.conf 等文件)

??? 默認rpm路徑

basedir =/usr/bin

datadir=/var/lib/mysql

.h=/usr/include/mysql

plung=/usr/lib64/mysql

share=/usr/share/mysql(confcharset etc)

?

4、? 安裝PHP7 ?

1.先看下yum

?[root@localhost ~]# ls /etc/yum.repos.d/

????back?webtatic-archive.repo?webtatic.repo?webtatic-testing.repo

????[root@localhost ~]# ls /etc/yum.repos.d/back/?

? ?#/etc/yum.repo.d/目錄下,只留webstaic頭的,其他的都放到back目錄里【建一個目錄back


CentOS7-Base-163.repo???? CentOS-CR.repo? ???????CentOS-Media.repo??? epel.repo

CentOS-Base.repo.backup?? CentOS-Debuginfo.repo? CentOS-Sources.repo? epel-testing.repo?? CentOS-Base.repo.backup1? CentOS-fasttrack.repo? CentOS-Vault.repo

????2.刪除之前的PHP版本

????[root@localhost ~]#yum remove php* php-common


????3.rpm 安裝Php7 相應的 yum源:

????[root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

????

????4.直接yum安裝php7:

????[root@localhost ~]# yum install php70w


????5.記得手動裝一下php-fpm

????[root@localhost ~]#yum?–y? install php-fpm

????[root@localhost ~]# ls /etc/php

????php.d/ ? ?php-fpm.conf? php-fpm.d/??? php.ini??????php-zts.d/

????6.看下PHP的版本:

????[root@localhost~]# php -v

????PHP 7.0.18 (cli) (built: Apr 15 2017 07:09:11) ( NTS )

????Copyright (c) 1997-2017 The PHP Group

????Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

????注意:

????????1、php.ini是php運行核心配置文件:

????????2、php-fpm.conf是 php-fpm 進程服務的配置文件:

????????3、配置www.conf(在php-fpm.d目錄下)

???????????www.conf這是 php-fpm 進程服務的擴展配置文件:

???????????php服務的一些文件路徑在/

????

5、? 安裝openresty? (編譯安裝)

????1.依賴關系

????openresty依賴于perl5.6.1+, libreadline, libpcre, libssl,首先安裝依賴關系。

????[root@localhost ~]# yum? –y? install?? perl 5.6.1+ ?libreadline?libpcre? libssl

????[root@localhost~]# yum? -y? install?readline-devel ?pcre-devel ?openssl-devel ?gcc


????2下載源碼

????https://openresty.org/download/openresty-1.11.2.3.tar.gz174月份)

????https://openresty.org/download/openresty-1.11.2.2.tar.gz? 1611月)

????使用wget下載(可以登錄http://openresty.org查看最新版本)

????[root@localhost~]# wget https://openresty.org/download/openresty-1.11.2.3.tar.gz


????3.解壓下載好的壓縮包

????[root@localhost ~]# tar zxf openresty-1.11.2.3.tar.gz


????4.配置./configure

? ?[root@localhost openresty-1.11.2.3]# cd openresty-1.11.2.3/

? ?[root@localhost openresty-1.11.2.3]# ./configure ?--prefix=/opt/openresty ?--with-luajit


默認, prefix=/usr/local/openresty程序會被安裝到/usr/local/openresty目錄。


我們可以指定各種選項,比如

./configure --prefix=/opt/openresty \

??????????? --with-luajit \

? ??????????--without-http_redis2_module \

? ? ? ? ? ? --with-http_iconv_module \

? ? ? ? ? ? --with-http_postgres_module

具體用法參考./configurehelp 或者官方文檔


?5.?編譯、安裝

[root@localhostopenresty-1.11.2.3]# gmake && gmake install


6.將nginx添加到系統變量

PATH=/opt/openresty/nginx/sbin:$PATH

export PATH?????????或者


[root@localhost openresty-1.11.2.3]# echo

"export PATH=$PATH:/opt/openresty/nginx/sbin/" >>/etc/profile && source /etc/profile


7.默認項目路徑

/opt/openresty/nginx/html


? 8.啟動、關閉、重啟nginx

nginx -c /opt/openresty/nginx/conf/nginx.conf?? //啟動并加載配置文件

nginx? -s stop??? //停止

nginx? -s reload??? //重啟

? 9.nginx做語法檢測

[root@localhost openresty-1.11.2.3]# nginx -t

nginx: the configuration file/opt/openresty/nginx/conf/nginx.conf syntax is ok

nginx: configuration file/opt/openresty/nginx/conf/nginx.conf test is successful

啟動nginx服務

[root@localhost openresty-1.11.2.3]# nginx

80端口設置防火墻規則:

[root@localhost openresty-1.11.2.3]# cd

[root@localhost ~]# firewall-cmd--add-port=80/tcp --permanent

success

[root@localhost ~]# firewall-cmd –reload

Success

?

6、用include指令實現nginx多虛擬主機配置? (nginx文件設置)

? 1.創建nginx賬戶和組

? ? [root@localhost~]# groupadd ?www-data

? ? [root@localhost~]# useradd ?-g ?www-data ?www-data

????????

2.配置nginx.conf文件:?? 內容如下(程序代碼)

user? www-data;

worker_processes? 1;

?

error_log/opt/openresty/nginx/logs/error.log crit;

pid?????? /opt/openresty/nginx/logs/nginx.pid;

?

?

events {

#使用的網絡I/)模型,Linux系統推薦采用epoll模型,FreeBSD系統推薦采用kqueue模型

??????? use epoll;

??????? worker_connections? 1024;

}

?

?

http {

??????? include???? /opt/openresty/nginx/conf/mime.types;

??????? default_type? application/octet-stream;

??????? charset?utf-8;

?

??????? server_names_hash_bucket_size 128;

??????? client_header_buffer_size 32k;

??????? large_client_header_buffers 4 32k;

??????? keepalive_timeout 60;

??????? fastcgi_connect_timeout 300;

??????? fastcgi_send_timeout 300;

??????? fastcgi_read_timeout 300;

??????? fastcgi_buffer_size 128k;

??????? fastcgi_buffers 4 128k;

??????? fastcgi_busy_buffers_size 128k;

??????? fastcgi_temp_file_write_size 128k;

??????? client_body_temp_path/opt/openresty/nginx/client_body_temp;

??????? proxy_temp_path/opt/openresty/nginx/proxy_temp;

??????? fastcgi_temp_path/opt/openresty/nginx/fastcgi_temp;

??????? gzip on;

??????? gzip_min_length? 1k;

??????? gzip_buffers???? 4 16k;

??????? gzip_http_version 1.0;

??????? gzip_comp_level 2;

??????? gzip_types?????? text/plain application/x-javascripttext/css application/xml;

??????? gzip_vary on;

??????? client_header_timeout? 10;

??????? client_body_timeout??? 10;

??????? send_timeout????????? 10;

??????? sendfile??????????????? on;

??????? tcp_nopush????????????? on;

??????? tcp_nodelay?????????? ?on;

?

??????? #virtual host

?

?

??????? include??????/host/nginx/conf/vhost/www_test_com.conf;

??????? include??????/host/nginx/conf/vhost/www_test1_com.conf;

??????? include??????/host/nginx/conf/vhost/www_test2_com.conf;

#也可以使用 include /host/nginx/conf/vhost/*.conf 來代替的,這里支持通配符.

?

###################################################partingline########################################################

?

?

??? # another virtual host using mix of IP-,name-, and port-based configuration

??? #

??? #server {

??? #???listen?????? 8000;

??? #???listen?????? somename:8080;

??? #???server_name? somename? alias?another.alias;

?

??? #???location / {

??? #???????root?? html;

??? #???????index? index.html index.htm;

??? #???}

??? #}

?

??? # HTTPS server

??? #

??? #server {

??? #???listen?????? 443 ssl;

??? #???server_name? localhost;

?

??? #???ssl_certificate????? cert.pem;

??? #???ssl_certificate_key? cert.key;

?

??? #???ssl_session_cache???shared:SSL:1m;

??? #???ssl_session_timeout? 5m;

?

??? #???ssl_ciphers? HIGH:!aNULL:!MD5;

??? #???ssl_prefer_server_ciphers? on;

?

??? #???location / {

??? #???????root?? html;

??? #???????index? index.html index.htm;

??? #???}

??? #}

?

}

? ??3.Nginx的虛擬主機配置(www_test_com.conf, www_test1_com.conf, www_test2_com.conf)文件里,設置access.logerror.log

????????[root@localhost~]# mkdir -p?/host/nginx/logs/test{"",1,2}

? ? 4.conf目錄下創建虛擬主機配置文件目錄vhost,vhost目錄下分別根據域名建立相應的

????????www_test_com.conf,www_test1_com.conf,www_test2_com.conf3個文件.


##我把虛擬主機配置文件放在了這個目錄下,只不過需要先手動創建目錄和.conf文件

[root@www test]#ls /host/nginx/conf/vhost/???

www_test1_com.conf? www_test2_com.conf? www_test_com.conf

?

www_test_com.conf配置代碼:

vi /host/nginx/conf/vhost/www_test_com.conf

?

server {

???????listen ? ?80; ? ###換成自個的IP地址(我是基于域名的虛擬主機,所以是相同IP不同端口。

???????client_max_body_size 100M;

???????server_name? www.test.com; ? ? ? ? ?###換成自個要用的域名

???????charset utf-8; ? ? ? ? ? ? ? ? ? ? ?###字符集:utf-8

???????root?? /var/www/test/; ? ? ? ? ? ? ?###站點路徑——存放網頁的目錄

???????index? ?index.php index.html index.htm? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ###追加index.php讓nginx服務器默認支持index.php為首頁:

???????autoindex?????? on;

???????access_log?? /host/nginx/logs/test/test.access.log;

????? ?error_log?? /host/nginx/logs/test/test.error.log;

???????

???????if (-d $request_filename) {

???????rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

???????}

???????error_page? 404????????????? /404.html;

???????location = /40x.html {

???????root? /var/www/test/;?????? #你的站點路徑

???????charset??? on;

???????}

???????# redirect server error pages to the static page /50x.html

???????#

???????error_page?? 500 502 503 504? /50x.html;

???????location = /50x.html {

???????????root?? /var/www/test/; ? ? ? ? ###自個的站點路徑——網頁存放路徑

???????????charset???? on;

???????}

???????#將客戶端請求裝交給fastcgi,老大要求用fpm模塊(修改)

???????location ~ \.php$ {

???????????root????????? /var/www/test/;

???????????fastcgi_pass?? 127.0.0.1:9000;

???????????fastcgi_index? index.php;

???????????fastcgi_param?SCRIPT_FILENAME?$document_root$fastcgi_script_name;

???????????include??????? fastcgi_params;

???????}

????????注意:配置.php請求被傳送到后端的php-fpm模塊,默認情況下php配置塊是被注釋的,此時去

??????????????掉注釋并修改,這里面很多都是默認的,root是配置php程序放置的根目錄,主要修改

????????????? 的就是fastcgi_param中的/scripts$document_root

????????例如:fastcgi_param?SCRIPT_FILENAME?$document_root$fastcgi_script_name;

?

?????????????????? location~ .*\.(php|php5|php4|shtml|xhtml|phtml)?$ {

??????????????? fastcgi_pass?? 127.0.0.1:9000;

????????????????????????? include /opt/openresty/nginx/conf/fastcgi_params;

??????????????? }

?????????????????? #網站的圖片較多,更改較少,將它們在瀏覽器本地緩存15

???????location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {

??????????????? expires????? 15d;

??????????????? }

?????????????????? #網站會加載很多JSCSS,將它們在瀏覽器本地緩存1

???????location ~ .*\.(js|css)?$ {

??????????????? expires????? 1d;

??????????????? }

???????location /(WEB-INF)/ {

??????????????? deny all;

??????????????? }

}

?

注意:www_test1_com.conf配置代碼和www_test2_com.conf配置代碼跟www_test_com.conf(除了

和網頁存放路徑不一樣外)一樣。

? ? 5.創建/var/www/test,/var/www/test1,/var/www/test2這三個目錄,并在這三個目錄下分別創建?index.php,還要給它們屬主和屬組權限。

? ? [root@www ~]# ls /var/www/test

?test/? test1/ test2/

?[root@www ~]# vi/var/www/test/index.php

?<?php

?phpinfo();

??>

給網頁文檔目錄/var/www/test{“”,1,2}添加屬主和屬組權限。

[root@localhosttest]# chown -R www-data:www-data /var/www/test{"",1,2}

其他兩個測試文件(注意目錄)一樣。


7、php文件配置:

? 1.php-fpm.conf配置文件

[root@www~]# vi /etc/php-fpm.conf

在[global]配置項下,把pid = /var/run/php-fpm/php-fpm.pid前的分號注釋去掉,還有就是include=/etc/php-fpm.d/*.conf這一項,設置配置文件路徑


2.php-fpm.d/www.conf配置文件

[root@www~]# vi /etc/php-fpm.d/www.conf

在[www]配置項下有user = ,group= 兩配置項,都改了

user= www-data

group= www-data

?

8、檢查nginx配置是否有錯

nginx?????? -t

啟動Nginx服務

[root@localhost~]#?Nginx????##nginx啟動命令

啟動PHP服務

[root@localhost~]#?php-fpm????##PHP啟動命令

啟動mariadb服務

[root@localhost~]# systemctl enable mariadb


9、配置防火墻規則:

??? [root@www~]# firewall-cmd --add-port=80/tcp –permanent??? #nginx:80

??? [root@www~]# firewall-cmd --add-port=3306/tcp –permanent? #mariadb:3306

??? [root@www~]# firewall-cmd --add-port=3306/tcp –permanent?#PHP:9000

??? [root@www~]# firewall-cmd –reload

10、在windows系統中C:\WINDOWS\system32\drivers\etc下的hosts文件中做域名映射


11、可以查看訪問了


轉載于:https://blog.51cto.com/12092502/1929825

總結

以上是生活随笔為你收集整理的用yum源配合源码包安装openresty、mariadb、php7服务的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。