周末上線一個(gè)幫朋友做的網(wǎng)站,遇到一些坑淋纲,記錄一下

網(wǎng)站上線流程

  • 購(gòu)買(mǎi)服務(wù)器劳闹,目前選擇的是阿里云服務(wù)器,選擇的是入門(mén)型1核1G實(shí)例

  • 配置SSH連接

    • 增加本機(jī)ssh連接配置洽瞬,一般激活實(shí)例后本涕,ssh的22端口是默認(rèn)開(kāi)放的,可以直接通過(guò)root用戶進(jìn)行登錄配置部署環(huán)境伙窃,
    • 登錄到服務(wù)器后菩颖,將自己的公鑰加入到 ~/.ssh/authorized_keys 配置文件中就可直接通過(guò)秘鑰進(jìn)行登錄
  • 服務(wù)器配置

    • 服務(wù)器系統(tǒng)版本:CentOS Linux release 7.4.1708 (Core)
    • 內(nèi)存:1G
    • CPU:1核
    • 硬盤(pán):40G

    *安裝Mysql5.5

    因?yàn)榉?wù)器配置有點(diǎn)低,所以這邊選擇安裝比較低的mysql版本为障。從CentOS 7.0發(fā)布以來(lái)晦闰,yum源中開(kāi)始使用mariadb來(lái)代替MySQL的安裝。即使你輸入的是yum install mysql , 顯示的也是mariadb的安裝內(nèi)容鳍怨,因此呻右,如果使用yum安裝MySQL的話,就需要去下載官方指定的yum源鞋喇。

    網(wǎng)址: https://dev.mysql.com/downloads/repo/yum/声滥。

    1. 先卸載mariadb,查看mariadb是否已經(jīng)安裝

    [root@iZbp17dq2xryqoixibq5u1Z ~]#  yum list installed | grep mariadb
    mariadb-libs.x86_64                     1:5.5.56-2.el7                 @anaconda
    

    進(jìn)行卸載

    [root@iZbp17dq2xryqoixibq5u1Z ~]# yum -y remove mariadb*
    Loaded plugins: fastestmirror
    Resolving Dependencies
    ......    **省略過(guò)程**
    
    Removed:
      mariadb-libs.x86_64 1:5.5.56-2.el7
    
    Dependency Removed:
      postfix.x86_64 2:2.10.1-6.el7                                                                redhat-lsb-core.x86_64 0:4.1-27.el7.centos.1
    
    Complete!
    

    2. 獲取yum源和數(shù)據(jù)庫(kù)安裝侦香,官方指南

    wget http://repo.mysql.com/yum/mysql-5.5-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm   #MySQL5.5yum源
    

    安裝yum源

    rpm -ivh mysql-5.5-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm 
    

    安裝好yum源后落塑,需要修改一下配置文件,文件路徑在 /etc/yum.repos.d/mysql-community.repo罐韩,要將5.5的enabled改為1憾赁,而5.6的enabled改為0

    # Enable to use MySQL 5.5
    [mysql55-community]
    name=MySQL 5.5 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    # Enable to use MySQL 5.6
    [mysql56-community]
    name=MySQL 5.6 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    
    # Note: MySQL 5.7 is currently in development. For use at your own risk.
    # Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
    [mysql57-community-dmr]
    name=MySQL 5.7 Community Server Development Milestone Release
    baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    

    修改后保存退出,開(kāi)始安裝MySQL散吵。在安裝之前龙考,可以查看下是否已有MySQL可安裝文件

    [root@iZbp17dq2xryqoixibq5u1Z ~]# yum repolist enabled | grep "mysql.*-community.*"
    mysql-connectors-community/x86_64 MySQL Connectors Community                  49
    mysql-tools-community/x86_64      MySQL Tools Community                       61
    mysql55-community/x86_64          MySQL 5.5 Community Server                 449
    

    3. 安裝mysql

    # 安裝client膘壶,devel,server
    yum install mysql-community-client mysql-community-devel mysql-community-server
    

    安裝完畢后洲愤,可以查看下當(dāng)前mysql版本

    [root@iZbp17dq2xryqoixibq5u1Z ~]# rpm -qi mysql-community-server
    Name        : mysql-community-server
    Version     : 5.5.60
    Release     : 2.el6
    Architecture: x86_64
    Install Date: 2018年05月05日 星期六 16:26:00
    ......
    

    4. 啟動(dòng)mysql

    執(zhí)行 service mysqld start 啟動(dòng)mysql

    [root@iZbp17dq2xryqoixibq5u1Z ~]# service mysqld start
    Starting mysqld (via systemctl):                           [  OK  ]
    

    ok颓芭,mysql安裝完畢

    常用命令:

    systemctl start mysqld #啟動(dòng)mysqld

    systemctl stop mysqld #停止mysqld

    systemctl restart mysqld #重啟mysqld

    systemctl enable mysqld #設(shè)置開(kāi)機(jī)啟動(dòng)

    systemctl status mysqld #查看 MySQL Server 狀態(tài)

    5. 數(shù)據(jù)庫(kù)安全設(shè)置

    設(shè)置mysql root賬戶密碼

    # mysqladmin -u root password 'new password'
    

    重新登錄mysql報(bào)如下錯(cuò)誤

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    

    執(zhí)行如下命令進(jìn)行解決

    [root@iZbp17dq2xryqoixibq5u1Z ~]# systemctl stop mysqld       **關(guān)閉mysql服務(wù)**
    [root@iZbp17dq2xryqoixibq5u1Z ~]# mysqld --user=root --skip-grant-tables &        **關(guān)閉skip-grant-tables**
    [1] 32163
    [root@iZbp17dq2xryqoixibq5u1Z ~]# 180505 16:57:08 [Note] mysqld (mysqld 5.5.60) starting as process 32163 ...
    180505 16:57:08 [Note] Plugin 'FEDERATED' is disabled.
    180505 16:57:08 InnoDB: The InnoDB memory heap is disabled
    180505 16:57:08 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    180505 16:57:08 InnoDB: Compressed tables use zlib 1.2.3
    180505 16:57:08 InnoDB: Using Linux native AIO
    180505 16:57:08 InnoDB: Initializing buffer pool, size = 128.0M
    180505 16:57:08 InnoDB: Completed initialization of buffer pool
    180505 16:57:08 InnoDB: highest supported file format is Barracuda.
    180505 16:57:08  InnoDB: Waiting for the background threads to start
    180505 16:57:09 InnoDB: 5.5.60 started; log sequence number 1595675
    180505 16:57:09 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
    180505 16:57:09 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
    180505 16:57:09 [Note] Server socket created on IP: '0.0.0.0'.
    180505 16:57:09 [Note] mysqld: ready for connections.
    Version: '5.5.60'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
    mysql -u root mysql       **空密碼登入**
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1
    Server version: 5.5.60 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> UPDATE user SET authentication_string=PASSWORD('new password') where USER='root';      **重新設(shè)置root密碼**
    Query OK, 4 rows affected (0.00 sec)
    Rows matched: 4  Changed: 4  Warnings: 0
    
    mysql> FLUSH PRIVILEGES;      **刷新設(shè)置**
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> quit
    Bye
    

    *安裝PHP環(huán)境

    1. 開(kāi)始安裝PHP和PHP-FPM

    首先安裝EPEL。EPEL即Extra Packages for Enterprise Linux的簡(jiǎn)稱柬赐,是為企業(yè)級(jí)Linux提供的一組高質(zhì)量的額外軟件包

    yum -y install epel-release
    

    安裝PHP和PHP-FPM

    yum -y install php php-fpm
    

    查看PHP版本

    [root@iZbp17dq2xryqoixibq5u1Z ~]# php -v
    PHP 5.4.16 (cli) (built: Mar  7 2018 13:34:47)
    Copyright (c) 1997-2013 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    

    這時(shí)發(fā)現(xiàn)PHP版本是5.4的亡问,原因是yum默認(rèn)的epel-release源太低了,而我需要部署的網(wǎng)站是基于Laravel5.5開(kāi)發(fā)的肛宋,環(huán)境要求:

    • PHP >= 7.0.0 需要重新安裝PHP7
    • PHP OpenSSL 擴(kuò)展
    • PHP PDO 擴(kuò)展
    • PHP Mbstring 擴(kuò)展
    • PHP Tokenizer 擴(kuò)展
    • PHP XML 擴(kuò)展

    刪除之前安裝的PHP版本

    yum remove php* php-common
    

    我們需要更換下rpm源州藕,搜索epel-release源并刪除后進(jìn)行更新

    [root@iZbp17dq2xryqoixibq5u1Z ~]# rpm -qa | grep epel
    epel-release-7-11.noarch
    [root@iZbp17dq2xryqoixibq5u1Z ~]# rpm -e epel-release-7-11.noarch
    warning: /etc/yum.repos.d/epel.repo saved as /etc/yum.repos.d/epel.repo.rpmsave
    [root@iZbp17dq2xryqoixibq5u1Z ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm
    warning: /var/tmp/rpm-tmp.PHnPwl: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:epel-release-7-5                 ################################# [100%]
    [root@iZbp17dq2xryqoixibq5u1Z ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    warning: /var/tmp/rpm-tmp.ohTozh: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:webtatic-release-7-3             ################################# [100%]
    

    重新安裝PHP和一些相關(guān)擴(kuò)展

    yum install php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-pdo.x86_64
    

    安裝PHP-FPM

    yum install php72w-fpm
    

    再次查看PHP版本

    [root@iZbp17dq2xryqoixibq5u1Z ~]# php -v
    PHP 7.2.4 (cli) (built: Mar 30 2018 08:49:13) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    

    啟動(dòng)PHP-FPM

    systemctl start php-fpm
    systemctl enable php-fpm.service      **開(kāi)機(jī)自啟動(dòng)**
    

    常用命令:

    systemctl start php-fpm # 啟動(dòng)

    systemctl stop php-fpm # 停止

    systemctl restart php-fpm # 重啟

    systemctl enable php-fpm #開(kāi)機(jī)自啟動(dòng)

*安裝Nginx

1. 開(kāi)始安裝Nginx

yum install nginx

安裝完畢后,啟動(dòng)Nginx

systemctl start nginx
systemctl enable nginx        **系統(tǒng)啟動(dòng)時(shí)自動(dòng)啟動(dòng)Nginx**

常用命令:

fuser -k 80/tcp # 殺死80端口

nginx -s stop # 停止

nginx -s reopen # 重啟

nginx -s reload # 重新載入配置文件

*網(wǎng)站部署

1. 生成秘鑰

ssh-keygen -t rsa

提示一直回車(chē)就行酝陈,將生成的秘鑰添加到項(xiàng)目托管的git庫(kù)網(wǎng)站上床玻,因?yàn)槲业木W(wǎng)站是放在Coding上,我直接添加在了項(xiàng)目部署秘鑰

2. 克隆項(xiàng)目

通過(guò) git clone 命令將項(xiàng)目拉取到服務(wù)器上沉帮,我這邊因?yàn)槭荖ginx锈死,所以我拉取到 /var/www/ 目錄下,

3. 安裝composer

[root@iZbp17dq2xryqoixibq5u1Z project_fjylhjjsyxgs]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.6.5) successfully installed to: /var/www/project_fjylhjjsyxgs/composer.phar
Use it: php composer.phar

移動(dòng)composer.phar文件到/usr/local/bin目錄下 穆壕,使命令全局可用待牵,并更換Packagist中國(guó)全量鏡像

mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com

通過(guò)composer安裝項(xiàng)目依賴,但是出現(xiàn)了報(bào)錯(cuò)

[root@iZbp17dq2xryqoixibq5u1Z project_fjylhjjsyxgs]# composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phar-io/manifest 1.0.1 -> satisfiable by phar-io/manifest[1.0.1].
    - phar-io/manifest 1.0.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 2
    - Installation request for phpunit/php-code-coverage 5.3.0 -> satisfiable by phpunit/php-code-coverage[5.3.0].
    - phpunit/php-code-coverage 5.3.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 3
    - Installation request for phpunit/phpunit 6.5.7 -> satisfiable by phpunit/phpunit[6.5.7].
    - phpunit/phpunit 6.5.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 4
    - Installation request for theseer/tokenizer 1.1.0 -> satisfiable by theseer/tokenizer[1.1.0].
    - theseer/tokenizer 1.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php.d/bz2.ini
    - /etc/php.d/calendar.ini
    - /etc/php.d/ctype.ini
    - /etc/php.d/curl.ini
    - /etc/php.d/exif.ini
    - /etc/php.d/fileinfo.ini
    - /etc/php.d/ftp.ini
    - /etc/php.d/gd.ini
    - /etc/php.d/gettext.ini
    - /etc/php.d/gmp.ini
    - /etc/php.d/iconv.ini
    - /etc/php.d/json.ini
    - /etc/php.d/ldap.ini
    - /etc/php.d/mbstring.ini
    - /etc/php.d/pdo.ini
    - /etc/php.d/pdo_sqlite.ini
    - /etc/php.d/phar.ini
    - /etc/php.d/shmop.ini
    - /etc/php.d/simplexml.ini
    - /etc/php.d/sockets.ini
    - /etc/php.d/sqlite3.ini
    - /etc/php.d/tokenizer.ini
    - /etc/php.d/xml.ini
    - /etc/php.d/zip.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Google后發(fā)現(xiàn)喇勋,php-xml擴(kuò)展有以上需要的相關(guān)軟件包

yum install php72w-xml.x86_64

重新執(zhí)行composer install命令缨该,依賴下載成功

開(kāi)始配置Nginx配置

我本機(jī)homestead中的Nginx是通過(guò) /etc/nginx/sites-available 目錄設(shè)置對(duì)應(yīng)多域名的nginx配置文件,但是不知道服務(wù)器上安裝的Nginx川背,卻沒(méi)有這個(gè)目錄贰拿,所以查看了下Nginx.conf文件,發(fā)現(xiàn)http模塊中有如下一條配置

  本機(jī)homestead中Nginx.conf
  ##
    # Virtual Host Configs
    ##
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    
    服務(wù)器上安裝的Nginx.conf
  # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

那好吧熄云,我估計(jì)sites-available也是軟連接的conf.d或者sites-enabled目錄吧膨更,所以我就直接將官方手冊(cè)中Nginx配置復(fù)制了一份到/etc/nginx/conf.d/域名.conf,修改了一些配置

server {
    listen 80;
    server_name 域名或公網(wǎng)IP;
    root 項(xiàng)目地址指向到public目錄;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;       **這里有個(gè)坑下面講**
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

配置完畢皱碘,保存退出询一,通過(guò)域名訪問(wèn)隐孽,發(fā)現(xiàn)報(bào)502錯(cuò)誤癌椿,查看下Nginx的錯(cuò)誤日志,發(fā)現(xiàn)報(bào)如下錯(cuò)誤

2018/05/06 20:17:37 [crit] 5898#0: *66 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream,

簡(jiǎn)單的講下菱阵,php-fpm.sock文件就是讓Nginx和PHP-FPM的進(jìn)程間進(jìn)行通信的文件踢俄,具體的含義,這邊就不做詳細(xì)介紹了晴及。進(jìn)這個(gè)目錄查看下是否存在這個(gè)目錄或文件都办,發(fā)現(xiàn)兩個(gè)問(wèn)題:

  • 目錄錯(cuò)誤,不是/var/run/php,而是/var/run/php-fpm
  • php7.2-fpm.sock這個(gè)文件未生成

未生成原因:php5.3之后的版本琳钉,php-fpm.conf里的listen的默認(rèn)配置是127.0.0.1:9000势木,也就是tcp的方式,不會(huì)生成php-fpm.sock歌懒。

因?yàn)檫@次上線的網(wǎng)站沒(méi)有什么并發(fā)量啦桌,unix socket方式要比tcp的方式快而且消耗資源少,所以我還是采用unix socket方式及皂。定位到問(wèn)題后甫男,修改下 /etc/php-fpm.d/www.conf,也就是php-fpm的配置文件验烧,關(guān)閉原來(lái)的listen方式板驳,然后重啟下php-fpm

;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php7.2-fpm.sock

這個(gè)時(shí)候,由于職業(yè)習(xí)慣碍拆,想把Nginx也重啟下若治,然后就又碰到了一個(gè)問(wèn)題

[root@iZbp17dq2xryqoixibq5u1Z project_fjylhjjsyxgs]# nginx -s stop
[root@iZbp17dq2xryqoixibq5u1Z project_fjylhjjsyxgs]# nginx -s reload
nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)

這應(yīng)該是因?yàn)榘袾ginx進(jìn)程殺死后pid丟失了,下一次再開(kāi)啟nginx -s reload時(shí)無(wú)法啟動(dòng)感混。再次面向Google編程直砂,發(fā)現(xiàn)還有挺多人碰到這個(gè)問(wèn)題,所以解決方法馬上就能搜索到了浩习,執(zhí)行如下命令

nginx -c /etc/nginx/nginx.conf
nginx -s reload

ok静暂,接著Navicat遠(yuǎn)程連接到服務(wù)器數(shù)據(jù)庫(kù),source下數(shù)據(jù)庫(kù)完畢∑谆啵現(xiàn)看起來(lái)應(yīng)該是可以跑起網(wǎng)站來(lái)了洽蛀。再次訪問(wèn)域名,發(fā)現(xiàn)還是502疟赊,再次查看Nginx日志郊供,報(bào)如下錯(cuò)誤:

2018/05/06 20:37:00 [crit] 6078#0: *1 connect() to unix:/var/run/php-fpm/php7.2-fpm.sock failed (13: Permission denied) while connecting to upstream,

和上面報(bào)錯(cuò)看起來(lái)差不多,但是這次主要問(wèn)題出在跑Nginx的用戶是Nginx近哟,而php-fpm.sock這個(gè)文件驮审,監(jiān)聽(tīng)的Nginx用戶沒(méi)有該權(quán)限,導(dǎo)致Nginx無(wú)法訪問(wèn)php-fpm.sock這個(gè)文件吉执,自然監(jiān)聽(tīng)就失去了效果疯淫,再次修改php-fpm配置文件和重啟下php-fpm

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

重新訪問(wèn)下域名,發(fā)現(xiàn)訪問(wèn)任何路由都是白屏戳玫,這次狀態(tài)碼都是200了熙掺,但是沒(méi)有任何輸出,再次面向Google編程……發(fā)現(xiàn)問(wèn)題:

由于nginx與php-fpm之間的一個(gè)小bug咕宿,會(huì)導(dǎo)致這樣的現(xiàn)象: 網(wǎng)站中的靜態(tài)頁(yè)面 .html 都能正常訪問(wèn)币绩,而 .php 文件雖然會(huì)返回200狀態(tài)碼蜡秽, 但實(shí)際輸出給瀏覽器的頁(yè)面內(nèi)容卻是空白。 簡(jiǎn)而言之缆镣,原因是nginx無(wú)法正確的將 *.php 文件的地址傳遞給php-fpm去解析芽突, 相當(dāng)于php-fpm接受到了請(qǐng)求,但這請(qǐng)求卻指向一個(gè)不存在的文件董瞻,于是返回空結(jié)果官脓。 為了解決這個(gè)問(wèn)題硬鞍,需要改動(dòng)nginx默認(rèn)的fastcgiparams配置文件

/etc/nginx/fastcgi_params 文件的最后增加兩行:

fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;  
fastcgi_param PATH_INFO     $fastcgi_script_name;  

再再再次訪問(wèn)域名廉涕,終于正常顯示了雀哨,但是頁(yè)面上又出現(xiàn)了新的錯(cuò)誤:

could not find driver(select * from users where deleted = 0)

任何有sql查詢的頁(yè)面都報(bào)如上錯(cuò)誤,這個(gè)錯(cuò)誤多半是因?yàn)閜do_mysql未打開(kāi)或者未安裝此模塊造成眠蚂,執(zhí)行 php -m 發(fā)現(xiàn)還真沒(méi)裝煞聪,安裝php72w-mysql的又遇到一個(gè)坑

yum install php72w-mysql

報(bào)如下錯(cuò)誤,說(shuō)缺少libmysqlclient.so.18依賴

......
error: package: php72w-mysql 
requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Available: 1:mariadb-libs-5.5.52-1.el7.x86_64 (base)
           libmysqlclient.so.18(libmysqlclient_18)(64bit)
......

這就很奇怪了逝慧,查看用戶庫(kù)文件目錄內(nèi)libmysqlclient.so.18已經(jīng)存在

[root@iZbp17dq2xryqoixibq5u1Z ~]# ll /usr/lib64/mysql/libmysqlclient.so.18
libmysqlclient.so.18      libmysqlclient.so.18.1.0

這個(gè)坑花了一個(gè)小時(shí)昔脯,Google多次嘗試無(wú)果后,認(rèn)真思考下可能的原因笛臣,想了想可能是mysql版本的問(wèn)題云稚,修改下 /etc/yum.repos.d/mysql-community.repo 配置文件,將5.6的enabled設(shè)為1沈堡,5.5設(shè)為0静陈,更新Mysql版本后,再次執(zhí)行 yum install php72w-mysql 成功安裝pdo_mysql模塊…...

至此诞丽,網(wǎng)站訪問(wèn)終于成功鲸拥!

后續(xù)的部署優(yōu)化,另外開(kāi)篇記錄僧免。

Ended, coding happy~

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末刑赶,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子懂衩,更是在濱河造成了極大的恐慌撞叨,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,639評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件浊洞,死亡現(xiàn)場(chǎng)離奇詭異牵敷,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)沛申,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,277評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)劣领,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人铁材,你說(shuō)我怎么就攤上這事尖淘。” “怎么了著觉?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,221評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵村生,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我饼丘,道長(zhǎng)趁桃,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,474評(píng)論 1 283
  • 正文 為了忘掉前任肄鸽,我火速辦了婚禮卫病,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘典徘。我一直安慰自己蟀苛,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,570評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布逮诲。 她就那樣靜靜地躺著帜平,像睡著了一般。 火紅的嫁衣襯著肌膚如雪梅鹦。 梳的紋絲不亂的頭發(fā)上裆甩,一...
    開(kāi)封第一講書(shū)人閱讀 49,816評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音齐唆,去河邊找鬼嗤栓。 笑死,一個(gè)胖子當(dāng)著我的面吹牛箍邮,可吹牛的內(nèi)容都是我干的抛腕。 我是一名探鬼主播,決...
    沈念sama閱讀 38,957評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼媒殉,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼担敌!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起廷蓉,我...
    開(kāi)封第一講書(shū)人閱讀 37,718評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤全封,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后桃犬,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體刹悴,經(jīng)...
    沈念sama閱讀 44,176評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,511評(píng)論 2 327
  • 正文 我和宋清朗相戀三年攒暇,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了土匀。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,646評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡形用,死狀恐怖就轧,靈堂內(nèi)的尸體忽然破棺而出证杭,到底是詐尸還是另有隱情,我是刑警寧澤妒御,帶...
    沈念sama閱讀 34,322評(píng)論 4 330
  • 正文 年R本政府宣布解愤,位于F島的核電站,受9級(jí)特大地震影響乎莉,放射性物質(zhì)發(fā)生泄漏送讲。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,934評(píng)論 3 313
  • 文/蒙蒙 一惋啃、第九天 我趴在偏房一處隱蔽的房頂上張望哼鬓。 院中可真熱鬧,春花似錦边灭、人聲如沸异希。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,755評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)宠互。三九已至,卻和暖如春椭坚,著一層夾襖步出監(jiān)牢的瞬間予跌,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,987評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工善茎, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留券册,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,358評(píng)論 2 360
  • 正文 我出身青樓垂涯,卻偏偏與公主長(zhǎng)得像烁焙,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子耕赘,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,514評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容