Cenos8编译安装LNMP配置自定义404页面,配置访问日志为json格式

nginx 下载地址:nginx: Linux packages

1.编译安装nginx步骤
[root@YWQ ~]#wget http://nginx.org/download/nginx-1.18.0.tar.gz (下载nginx源码包)
[root@YWQ ~]#tar -zxvf nginx-1.18.0.tar.gz (解压源码包)
[root@YWQ ~]#dnf install gcc gcc-c++ glibc pcre-devel zlib-devel openssl-devel(安装依赖软件)

[root@YWQ ~]# groupadd nginx (创建nginx 用户组)
[root@YWQ ~]# useradd nginx -g nginx -s /sbin/nologin -M


image.png

[root@YWQ ~]#
[root@YWQ nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre

参数说明:


image.png

执行完成如图:


image.png

执行make 和 make install 安装:
make && make install

编译安装完成如图:



创建启动软连接:
[root@YWQ conf]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/
[root@YWQ ~]# nginx -v
nginx version: nginx/1.18.0
[root@YWQ ~]# nginx

查看进程:


image.png

验证:


image.png

nginx 配置 log_json格式:vi nginx.conf

image.png

配置自定义404


image.png

配置虚拟主机实现 https 自定义 域名 https://ywq.com 访问

image.png

  1. 编译安装PHP步骤:
    [root@YWQ lmnp]# wget http://cn2.php.net/distributions/php-8.0.0.tar.gz
    [root@YWQ lmnp]# tar -zxvf php-8.0.0.tar.gz

(安装依赖包)
[root@YWQ php-8.0.0]# dnf install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

编译:
[root@YWQ php-8.0.0]#./configure --prefix=/usr/local/php8 --with-curl --with-mysql-sock=/var/tmp/mysql/mysql.sock --with-jpeg-dir --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-mysqli=mysqlnd --with-openssl --with-pcre-regex --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --with-pdo-mysql --with-fpm-user=nginx --with-fpm-group=nginx --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --enable-mysqlnd --enable-maintainer-zts

报错1:configure: error: Package requirements (libxml-2.0 >= 2.9.0)
yum -y install libxslt libxslt-devel

报错2:configure: error: Package requirements (oniguruma) were not met:
centos8 安装:
yum config-manager --set-enabled PowerTools
yum -y install oniguruma oniguruma-devel

报错3:configure: error: Package requirements (sqlite3 > 3.7.4)
[root@YWQ php-8.0.0]# dnf install sqlite-devel

编译完成:


image.png

[root@YWQ php-8.0.0]# make && make install

安装完成:


image.png

配置:
[root@YWQ php-8.0.0]# cp php.ini-production /usr/local/php8/etc/php.ini
[root@YWQ etc]# cp php-fpm.conf.default php-fpm.conf
[root@YWQ etc]#
[root@YWQ php-fpm.d]# pwd
/usr/local/php8/etc/php-fpm.d
[root@YWQ php-fpm.d]# cp www.conf.default www.conf
[root@YWQ php-fpm.d]#

[root@YWQ sbin]# pwd
/usr/local/php8/sbin
[root@YWQ sbin]# ./php-fpm
[root@YWQ sbin]# ln -sf /usr/local/php8/bin/php /usr/bin/php
[root@YWQ sbin]#
[root@YWQ ~]# cp /opt/lmnp/php-8.0.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@YWQ ~]# chmod +x /etc/init.d/php-fpm
[root@YWQ ~]#
修改nginx.conf 支持可执行php:


image.png
image.png

源码编译安装MySQL8.0:
下载源码包:
mysql-8.0.19.tar.gz
boost_1_70_0.tar.gz //安装mysql-8所需要的boost版本
rpcsvc-proto-1.4.tar.gz 需要的源码包

[root@YWQ mysql]# wget http://mirrors.sohu.com/mysql/MySQL-8.0/mysql-8.0.19.tar.gz
[root@YWQ mysql]# wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz
[root@YWQ mysql]# wget https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz
安装依赖:
[root@YWQ mysql]# yum install -y cmake ncurses-devel

编译软件:
[root@YWQ mysql]# tar -zxf rpcsvc-proto-1.4.tar.gz -C /usr/local/src/
[root@YWQ src]# cd rpcsvc-proto-1.4/
[root@YWQ rpcsvc-proto-1.4]# ./configure && make && make install

[root@YWQ local]# mkdir -p /usr/local/boost
[root@YWQ local]# cp /opt/lmnp/mysql/boost_1_70_0.tar.gz /usr/local/boost/
[root@YWQ boost]# cd /usr/local/boost
[root@YWQ boost]# tar xf boost_1_70_0.tar.gz
[root@YWQ boost]# mv boost_1_70_0/* ./

[root@YWQ ~]# groupadd mysql
[root@YWQ ~]# useradd -g mysql mysql -s /bin/false
[root@YWQ ~]# mkdir -p /data/mysql
[root@YWQ data]# chown -R mysql:mysql /data/mysql
[root@YWQ ~]# mkdir -p /usr/local/mysql
[root@YWQ ~]#

编译 mysql
[root@YWQ mysql-8.0.19]#cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DINSTALL_DATADIR=/data/mysql -DMYSQL_USER=mysql
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_EMBEDDED_SERVER=1
-DFORCE_INSOURCE_BUILD=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all
-DWITH_BOOST=/usr/local/boost

报错误:
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
解决:
[root@YWQ ~]# cp -a /opt/lmnp/mysql/mysql-8.0.19/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/windeps/sunrpc/rpc /usr/include/

编译完成:


image.png

安装:
make -j 3 && make install


image.png

修改mysql目录权限:
[root@YWQ ~]# chown -R mysql:mysql /usr/local/mysql
[root@YWQ ~]# chmod -R 755 /usr/local/mysql

初始化数据库:
[root@YWQ mysql]# cd /usr/local/mysql/


image.png

初始化
命令:
mysqld --initialize --console
目录授权
命令:
chown -R mysql:mysql /var/lib/mysql/
启动mysql服务
命令:
systemctl start mysqld
命令:
systemctl status mysqld


image.png

你可能感兴趣的:(Cenos8编译安装LNMP配置自定义404页面,配置访问日志为json格式)