CentOS 7 设置-Step3.在 CentOS 7 上安装 LNMP


=Start=

缘由:

搭建VPS不仅仅是为了要有一个Linux环境进行学习、测试,最好还能安装PHP、Nginx、MySQL等环境方便搭建网站用来记录和分享所学内容。

正文:

# PHP
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo vim /etc/yum.repos.d/remi.repo
    [remi]
    ......
    enabled = 1
    [remi-php56]
    ......
    enabled = 1
yum list | grep php
sudo yum install php php-devel php-mbstring php-mcrypt php-mysqlnd php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common php-imap php-xmlrpc php-soap php-snmp php-ldap php-opcache php-phpunit-PHPUnit php-pecl-apcu php-pecl-xdebug php-pecl-xhprof php-pecl-xmldiff-devel php56-runtime php56-build
# Nginx(也可以选择自行编译安装)
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install nginx nginx-module-xslt nginx-module-perl nginx-module-image-filter nginx-mod-http-geoip
sudo systemctl status nginx
sudo systemctl start nginx
curl http://localhost:80/
# MySQL
sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum info Percona-Server-client-56 Percona-Server-server-56 Percona-Server-devel-56
sudo yum install Percona-Server-client-56 Percona-Server-server-56 Percona-Server-devel-56
sudo systemctl status mysql
sudo systemctl start mysql
sudo /usr/bin/mysql_secure_installation

参考链接:

=END=

,

《 “CentOS 7 设置-Step3.在 CentOS 7 上安装 LNMP” 》 有 7 条评论

  1. Nginx Google 扩展
    https://github.com/cuber/ngx_http_google_filter_module/blob/master/README.zh-CN.md#从发行版迁移

    丛源码开始构建 ngx_pagespeed 扩展
    https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source

    为 CentOS7 上的 Nginx 启用 TCP Fast Open 功能
    http://www.masv.io/enabling-tcp-fast-open-nginx-centos-7/

    Let’s Encrypt,免费好用的 HTTPS 证书
    https://imququ.com/post/letsencrypt-certificate.html
    # 本打算在测试的时候就用上 Let’s Encrypt 的 HTTPS 证书的,后来发现,现在不支持为 IP 发 HTTPS 证书
    https://github.com/ebekker/ACMESharp/issues/94

    为nginx配置https并自签名证书
    http://blog.creke.net/762.html

    使用OpenSSL自签发服务器https证书
    http://blog.creke.net/736.html

  2. 在CentOS上安装PHP 7
    ==
    PHP源码下载
    http://php.net/downloads.php

    为 WordPress 编译安装 PHP 7.0.3 亲测全攻略
    https://www.bokeyy.com/post/build-php-7-0-3-for-wordpress.html

    让PHP7达到最高性能的几个Tips
    http://www.laruence.com/2015/12/04/3086.html

    PHP7.0正式版编译安装升级及WordPress问题解决分享
    https://zhangge.net/5075.html

    Install PHP 7 on CentOS, RHEL or Fedora
    https://blog.remirepo.net/post/2016/02/14/Install-PHP-7-on-CentOS-RHEL-Fedora
    ==
    `$ sudo yum install php php-devel php-mbstring php-mcrypt php-mysqlnd php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common php-imap php-xmlrpc php-soap php-snmp php-ldap php-opcache php-phpunit-PHPUnit php-pecl-apcu php-pecl-xdebug php-pecl-xmldiff-devel
    `

  3. 因为VPS上的MySQL服务出现过停止导致WordPress无法正常工作的情况,所以用crontab增加一个停止检测重启MySQLd功能的任务,防止博客挂太久
    `
    #!/bin/bash
    # Date: 20170220
    # set -x
    # */2 * * * * /bin/bash /root/restart_mysqld.sh
    export PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin/:/usr/local/sbin

    function func_restart_mysqld() {
    sudo systemctl status mysqld
    if [[ $? -ne 0 ]]; then
    sudo systemctl start mysqld
    fi
    }

    function func_main() {
    func_restart_mysqld
    }
    func_main
    `

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注