centos7安装LNMP与Laravel遇到的一些小问题

安装LNMP

第一次安装

  1. yum update
  2. CentOS7下 Nginx1.13.5 + PHP7.1.10 + MySQL5.7.19 源码编译安装
  3. 安装mySQL时,mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directoryinnobackupex: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory 解决办法中使用了yum install numactl -y安装了依赖包,不过其他问题来了。

搞坏了一个东西,重装吧。而且这篇排版啥的pre标签文字过长都隐藏了不好重新找一个yum安装吧。

第二次安装

  1. nginx安装后用 nginx 可以直接启动
nginx 
nginx -s stop|reload

也可 service nginx start

还可以直接 /usr/sbin/nginx
  1. mysql
[root@]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@]# service mysqld status

提醒重定向 systemctl 但是也是可以用 service mysqld start/stop 启停的,service mysqld status 查看状态。

重置密码的时候,提醒Your password does not satisfy the current policy requirements (mysql文档规定,密码必须包括大小写字母数字加特殊符号>8位),那么复杂以后肯定会忘记的(暴雪账号忘过太多次了),基于 ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsmysql> set global validate_password_policy=0; 设置参数为0,则只判断长度。

  1. php也是傻瓜式安装,需启动php-fpm。修改完配置后也需要重启php-fpm
service php-fpm start|stop

访问php页面会直接下载,需要配置nginx,我最后的配置是

    server {
        location / {
            index index.html index.htm index.php;
        }

        location ~ .php$ {
           # root /usr/share/nginx/html;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }

可惜没有用户权限管理。

Laravel

  1. 安装 Composer

curl -sS https://getcomposer.org/installer | php 下载得到 composer.phar

参考 Composer简介mv composer.phar /usr/local/bin/composer放到执行目录,方可直接composer命令直接调用。

  1. 安装 Laravel

ln -s /usr/share/nginx/html/vendor/bin/laravel /usr/local/bin/laravel 给执行目录下放个链接

laravel new messages

或者直接 /usr/share/nginx/html/vendor/bin/laravel new messages


The stream or file "/.../html/messages/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

storage 目录需要权限 chmod -R 777 storage

开发

新增数据库用户及密码:CREATE USER 'cowpea'@'%' IDENTIFIED BY 'Cowpea1!'

使用

Laravel 使用数据库时 Connections using insecure transport are prohibited while --require_secure_transport=ON.,mysql ssl问题,错误出来的那一刹都已经预料到,加了ssl就不能回头了啊,继续搞。

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
            //for ssl.... :(
            'sslmode' => env('DB_SSLMODE', 'prefer'),
            'options' => array(
                PDO::MYSQL_ATTR_SSL_KEY => '/var/lib/mysql/client-key.pem',
                PDO::MYSQL_ATTR_SSL_CERT => '/var/lib/mysql/client-cert.pem',
                PDO::MYSQL_ATTR_SSL_CA => '/var/lib/mysql/ca.pem',
            ),
        ],

注册登录错误

访问错误:

访问 messages/public/register 时,出错404,nginx配置。
老板,来一份配置,少放点辣子 Laravel 在 Nginx 中的参考配置两份
根目录直接放public目录吧,好开发。

注册错误:

试着注册一个账号,

SQLSTATE[HY000] [2026] SSL connection error: Unable to get private key (SQL: select count(*) as aggregate from `users` where `email` = ss@qq.com)

用了一个多小时,
还是没有解决,
加了\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false也没用,我的没有这个 Undefined class constant 'MYSQL_ATTR_SSL_VERIFY_SERVER_CERT'

终于发现了救命稻草:
PHP application cannot connect to MySQL over SSL

After a few bug reports and complaints a new PDO::MySQL attribute was added in php-7.0.18, php-7.1.4 with commit 247ce052cd0fc7d0d8ea1a0e7ea2075e9601766a but not documented in the official documentation.

If after adding this parameter you get an error message

PHP message: Error: Undefined class constant 'MYSQL_ATTR_SSL_VERIFY_SERVER_CERT'

then your PHP version does not support that parameter and you need to upgrade.

卧槽,还得升级到7.1.4我是7.1.14,我弄个锤子的SSL啊,毁我青春。赶紧去掉/etc/my.cnf的ssl配置。

posted @ 2018-04-20 15:29  姜小豆  阅读(1193)  评论(0编辑  收藏  举报