Lnmp架构
1. Nginx
//关闭防火墙
[root@localhost ~]
[root@localhost ~]
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]
SELINUX=disabled
//创建用户
[root@localhost src]
//安装依赖环境(这是lnmp的所有环境)
[root@localhost ~]
[root@localhost src]
[root@localhost src]
//解压
[root@localhost ~]
[root@localhost src]
debug
kernels
mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
nginx-1.20.1.tar.gz
php-8.0.10.tar.xz
[root@localhost src]
//创建日志存放目录
[root@localhost src]
[root@localhost src]
//编译安装
[root@localhost nginx-1.20.1]
[root@localhost nginx-1.20.1]
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
&& make && make install
//环境变量
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
2. mysql
//创建用户
[root@localhost src]
//解压
[root@localhost src]
[root@localhost src]
//软连接
[root@localhost local]
[root@localhost local]
//头文字连接
[root@localhost local]
//库文件
[root@localhost local]
/usr/local/mysql/lib
[root@localhost local]
//创建数据存放目录
[root@localhost local]
[root@localhost local]
//环境变量
[root@localhost local]
[root@localhost local]
//初始化
[root@localhost local]
2021-10-26T05:09:53.834671Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-10-26T05:09:53.995344Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-10-26T05:09:54.023409Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-10-26T05:09:54.027736Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f4793834-361a-11ec-875c-000c292bb2f4.
2021-10-26T05:09:54.028523Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-10-26T05:09:54.496140Z 0 [Warning] CA certificate ca.pem is self signed.
2021-10-26T05:09:54.749748Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
//编写配置文件
[root@localhost local]
> [mysqld]
> basedir = /usr/local/mysql
> datadir = /opt/data
> socket = /tmp/mysql.sock
> port = 3306
> pid-file = /opt/data/mysql.pid
> user = mysql
> skip-name-resolve
> EOF
//编写服务控制脚本
[root@localhost local]
basedir=/usr/local/mysql
datadir=/opt/data
[root@localhost local]
[Unit]
Description=Mysql server daemon
After=network.target sshd-keygen.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/local/mysql/support-files/mysql.server stop
[Install]
WantedBy=multi-user.target
EOF
//启动服务
[root@localhost local]
[root@localhost local]
[root@localhost local]
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@localhost local]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
3. php
//解压
[root@localhost src]
[root@localhost src]
//编译安装
[root@localhost nginx]
--with-config-file-path=/etc \
--enable-fpm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix \
&& make && make install
//环境变量
[root@localhost php-8.0.10]
[root@localhost php-8.0.10]
//配置php
[root@localhost php-8.0.10]
[root@localhost php-8.0.10]
[root@localhost php-8.0.10]
[root@localhost php8]
[root@localhost etc]
[root@localhost etc]
[root@localhost php-fpm.d]
[root@localhost php-fpm.d]
www.conf www.conf.default
//启动
[root@localhost php-fpm.d]
Starting php-fpm done
[root@localhost php-fpm.d]
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
4. 配置nginx
//配置网页文件
[root@localhost nginx]
[root@localhost html]
<?php
phpinfo();
?>
[root@localhost html]
//修改配置文件
[root@localhost nginx]
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
[root@localhost ~]
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
[root@localhost ~]