全部文章/linux

LNMP安装配置及ssl配置

nginx安装

使用官网稳定版1.18.0编译安装 准备编译环境 zlib-devel openssl-devel gcc gcc-c++ make pcre-devel 添加如下模块 --with-http_stub_status_module \ --with-http_gzip_static_module \ --with-http_realip_module \ --with-http_sub_module \ --with-http_ssl_module 设置软连接 ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx ln -s /usr/local/nginx/conf/ /etc/nginx nginx -V查看模块是否正常

php安装

添加webtatic源 官网地址 rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

数据库安装

由于使用mysql数据库的时候php就是连接不上去,验证方式啥的都试了就是不好使,于是使用的mariadb。

安装 mariadb-server mariadb 配置 mysql_secure_installation 设置密码 Remove anonymous users 是否删除匿名用户 Disallow root login remotely 是否禁止root远程登录 Remove test database and access to it 是否删除test数据库 Reload orivilege tables now 是否刷新权限表

ssl配置

在nginx的配置文件中配置好http站点 使用Let‘s Encrypt 安装certbot yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install certbot certbot-nginx certbot --nginx安装证书 是否设置邮箱提醒 是否同意协议 是否共享你的邮箱 选择nginx中的域名 是否将http重定向到https nginx配置文件会自动配置好 添加域名 certbot run --nginx