LNMP 二进制安装

Linux   2023-01-01 23:54   1132   0  

第一步

MySQL8.0.29

## 安装
[root@v2ray ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.29-linux-glibc2.17-x86_64-minimal.tar.xz
[root@v2ray ~]# tar xf mysql-8.0.29-linux-glibc2.17-x86_64-minimal.tar.xz
[root@v2ray ~]# mv mysql-8.0.29-linux-glibc2.17-x86_64-minimal /usr/local/mysql
[root@v2ray ~]# groupadd mysql
[root@v2ray ~]# useradd -r -g mysql mysql
[root@v2ray ~]# yum -y install libaio
[root@v2ray ~]# yum -y remove mariadb*
[root@v2ray ~]# vim /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
socket=/tmp/mysql.sock

[mysqld]
# skip-name-resolve

# 设置3306端口
port=3306
socket=/tmp/mysql.sock
pid-file=/usr/local/mysql/mysql.pid

# 是否需要密码登录
# skip-grant-tables

# 设置mysql的安装目录
basedir=/usr/local/mysql

# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data

# 允许最大连接数
max_connections=1000

# 服务端使用的字符集默认为8比特编码的Iatin1字符秀
character-set-server=UTF8MB4

# 创建新表时将使用的默认存储引随
default-storage-engine=INNODB

# 是否敏感大小写 0=是 1=否
# lower_case_table_name=1

# 客户端写入数据大小
# max_alloved_packet=128M

# 设置默认密码验证插件
authentication_policy=mysql_native_password
[root@v2ray ~]# chown -R mysql:mysql /usr/local/mysql/
[root@v2ray ~]# /usr/local/mysql/bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --log-bin=/usr/local/mysql/data/mysql-bin --user=mysql
2020-12-15T08:32:21.215780Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 23367
2020-12-15T08:32:21.219425Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-12-15T08:32:21.238802Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-12-15T08:32:22.797006Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-12-15T08:32:26.071931Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: !qj.Iu)6z/8A
[root@v2ray ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@v2ray ~]# chmod 777 /etc/init.d/mysqld 
[root@v2ray ~]# chkconfig --add mysqld
[root@v2ray ~]# chkconfig --list mysqld

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

mysqld          0:关    1:关    2:开    3:开    4:开    5:开    6:关
[root@v2ray ~]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/v2ray.err'.
.. SUCCESS! 
[root@v2ray ~]# vim /etc/profile
#添加
PATH=$PATH:/usr/local/mysql/bin
export PATH
[root@v2ray ~]# source /etc/profile
## 修改密码
[root@v2ray ~]# mysql -uroot -p'!qj.Iu)6z/8A'
mysql> ALTER USER 'root'@'localhost' identified by 'qwe123.0' ;  #修改密码
Query OK, 0 rows affected (0.01 sec)

mysql> use mysql;  #进入MySQL库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set user.Host='%' where user.User='root';  #开放远程访问权限
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;  #立即生效
Query OK, 0 rows affected (0.01 sec)

mysql> exit;  #退出
Bye
[root@v2ray ~]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL.. SUCCESS! 
[root@v2ray ~]# /sbin/chkconfig mysqld on

第二步

PHP8.0.20

## 安装其他软件包
yum -y install libsmbclient-devel autoconf m4 nfs-utils postgresql-devel postgresql libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc gcc-c++ sqlite-devel libicu-devel oniguruma oniguruma-devel openldap openldap-devel ImageMagick-devel cmake3 oniguruma oniguruma-devel libsodium libsodium-devel openldap-devel libicu libicu-devel libc-client-devel file-devel libxml2-devel libcurl-devel libjpeg-devel libwebp-devel freetype-devel libpng-devel libzip-devel openssl-devel libldap-devel gmp-devel imap-devel readline-devel gmp-devel bzip2-devel libmcrypt-devel libmemcached-devel libssh2-devel sqlite-devel libxml2-devel libXpm libXpm-devel numactl
##libzip-1.9.2
#1、下载源码,并解压
wget https://libzip.org/download/libzip-1.9.2.tar.gz
tar xf libzip-1.9.2.tar.gz 
cd libzip-1.9.2
#2、编译安装
mkdir build && cd build && cmake3 -DCMAKE_INSTALL_PREFIX=/usr .. && make -j2 && make -j2 install

## 进入正题
[root@v2ray ~]# wget https://www.php.net/distributions/php-8.0.20.tar.gz
[root@v2ray ~]# tar -zxvf php-8.0.20.tar.gz
[root@v2ray ~]# cd php-8.0.20
[root@v2ray php-8.0.20]# ./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc --with-curl --with-freetype --enable-gd --with-jpeg  --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql  --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl --with-xsl --with-zlib --with-zip -with-bz2 --with-iconv  --enable-fpm --enable-pdo  --enable-bcmath  --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd --enable-fileinfo --with-sodium
[root@v2ray php-8.0.20]# make -j2 && make -j2 install
[root@v2ray php-8.0.20]# /usr/local/php8/bin/php --version
PHP 8.0.20 (cli) (built: Dec 15 2020 05:50:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
## 生成php.ini配置文件
cp php.ini-production /usr/local/php8/etc/php.ini
## 生成www.conf配置文件
cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
## 生成php-fpm的配置文件
cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
## 生成php-fpm启动文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm 
## 启动php-fpm
[root@v2ray ~]# /etc/init.d/php-fpm start
Starting php-fpm  done
## 查看进程中是否已启动
[root@v2ray ~]# ps auxfww | grep php | grep -v grep
root     16261  0.0  0.7 164660  5352 ?        Ss   06:20   0:00 php-fpm: master process (/usr/local/php8/etc/php-fpm.conf)
nobody   16263  0.0  0.6 164660  5008 ?        S    06:20   0:00  \_ php-fpm: pool www
nobody   16264  0.0  0.6 164660  5008 ?        S    06:20   0:00  \_ php-fpm: pool www
#查看php-fpm默认守护的端口
[root@v2ray ~]# ss -lntp | grep php
LISTEN     0      128    127.0.0.1:9000                     *:*                   users:(("php-fpm",pid=16264,fd=5),("php-fpm",pid=16263,fd=5),("php-fpm",pid=16261,fd=7))

## openssl-1.1.0l 如果安装php时报openssl的错误 就执行此步骤
yum -y remove openssl
wget https://www.openssl.org/source/openssl-1.1.0l.tar.gz
tar xf openssl-1.1.0l.tar.gz
cd openssl-1.1.0l
./config
make && make install 
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
ln -s /usr/local/lib64/pkgconfig/openssl.pc /usr/local/lib/pkgconfig/

第三步

Nginx

## 安装
[root@v2ray ~]# yum -y install gcc gcc-c++ make make-devel zlib zlib-devel pcre-devel openssl openssl-devel
[root@v2ray ~]# wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz
[root@v2ray ~]# tar xf tengine-2.3.3.tar.gz
[root@v2ray ~]# cd tengine-2.3.3
[root@v2ray tengine-2.3.3]# useradd -r -M -s /sbin/nologin www
[root@v2ray tengine-2.3.3]# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_realip_module
[root@v2ray tengine-2.3.3]# make && make install
[root@v2ray tengine-2.3.3]# ln -s /usr/local/nginx/sbin/nginx /usr/sbin/

第四步

测试

[root@v2ray ~]# vim /usr/local/nginx/conf/nginx.conf
        location ~ \.php$ {
            root           /php/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }
[root@v2ray ~]# cat /php/index.php 
<?php
phpinfo();
?>




上一篇
没有了
博客评论
还没有人评论,赶紧抢个沙发~
发表评论
说明:请文明发言,共建和谐网络,您的个人信息不会被公开显示。