LNMP架构

一.    LNMP组成

二. 下载源码包

wget http://nginx.org/download/nginx-1.17.2.tar.gz   
wget https://www.php.net/distributions/php-7.3.7.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar

解压:
tar zxvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
tar zxvf php-7.3.7.tar.gz
tar zxvf nginx-1.17.2.tar.gz

# 安装cmake

yum install -y gcc gcc-c++ make automake
wget https://github.com/Kitware/CMake/releases/download/v3.15.1/cmake-3.15.1.tar.gz
tar zxvf cmake-3.15.1.tar.gz
cd cmake-3.15.1
./configure --prefix=/usr/local/cmake
make && make install
创建 cmake的软连接
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake

 三. 安装MYSQL流程

# 创建用户组
groupadd mysql

# 创建mysql用户,属于mysql组
useradd -g mysql mysql

#安装
# 安装依赖
yum install -y libaio
 
rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装common
rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装libs
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安装client
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --nodeps --force #安装server
 
# 修改组
chown mysql:mysql /var/lib/mysql -R
# 启动
systemctl start mysqld.service
# 开机自启
systemctl enable mysqld
<br># 查看默认密码<br>cat /var/log/mysqld.log | grep password
 
# 修改密码
alter user 'root'@'localhost' identified by '123456';

 四. 安装PHP

#安装依赖
 yum install screen gcc git openssl curl -y
yum install gmp-devel libc-client-devel bzip2-devel enchant-devel libwebp-devel libXpm-devel openldap openldap-devel php-pspell aspell-devel readline-devel libtidy-devel libxslt-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel autoconf
yum install epel-release 
yum -y install libc-client-devel libtidy 
yum install libtidy-devel -y

#######################################
如果 提示Please reinstall the libzip distribution 

# 先卸载原先的 libzip yum remove libzip # 下载 libzip 源码(去网站选择合适的版本)
curl-O https://libzip.org/download/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
cmake ..
make && make install
#######################################
编译PHP时出现的提示,报错信息为: configure: error: off_t undefined; check your library configuration 。
解决方案:
(1)输入以下命令,添加搜索路径到配置文件:
    echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf
(2)更新配置
    ldconfig -v
#######################################

 # 编译安装
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --with-sqlite3 --with-pdo-sqlite --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-posix --enable-pcntl --enable-shmop --enable-sysvshm --enable-sysvsem --enable-sysvmsg --enable-phar --enable-zip --with-zlib --with-zlib-dir --with-bz2 --with-gd --enable-gd-jis-conv --with-webp-dir --with-jpeg-dir --with-png-dir --with-xpm-dir --with-freetype-dir --enable-exif --enable-json --enable-libxml --with-libxml-dir --enable-xml --enable-xmlreader --enable-xmlwriter --enable-simplexml --with-pear --with-xsl --enable-dom --enable-soap --enable-wddx --with-xmlrpc --enable-ctype --enable-filter --with-pcre-regex --with-pcre-jit --with-enchant --with-pspell --enable-fileinfo --enable-mbstring --with-iconv --enable-hash --with-openssl --enable-bcmath --with-gmp --enable-session --enable-sockets --enable-ftp --with-curl --with-ldap --with-ldap-sasl --with-imap --with-kerberos --with-imap-ssl --enable-calendar --with-gettext --with-tidy --with-readline --enable-tokenizer --enable-opcache --enable-cli --enable-cgi --enable-fpm --enable-phpdbg

make  
make install 

# 提示 libc-client 和 libldap 问题 重新./configure


ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
cp -frp /usr/lib64/libldap* /usr/lib/
# 编译 collect2: error: ld returned 1 exit status 在PHP源码目录下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make即可
 
# 安装
make -j `grep processor /proc/cpuinfo | wc -l` && make install


# 拷贝配置文件

 五.nginx安装配置

cd ~/nginx-1.17.2
./configure --prefix=/usr/local/nginx
make && make install
curl 127.0.0.1  出现welcome to nginx 则成功



# 修改配置<br>vim ./conf/nginx.conf # 修改如下

	
location ~ .php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME /$document_root$fastcgi_script_name;
            include        fastcgi_params;
}

# 重启

/usr/local/sbin/nginx 

安装完毕!  2进制安装比较恶心,缺什么安什么
原文地址:https://www.cnblogs.com/zhaobin-diray/p/13205317.html