从零到精通:手把手教你rpm包安装高性能LNMP环境(Nginx+MySQL+PHP)
# 安装必要的开发工具和依赖项
yum install -y gcc gcc-c++ make zlib-devel libmcrypt-devel mhash-devel openssl-devel libtool* autoconf libaio-devel
# 下载Nginx源码包并解压
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar zxvf nginx-1.16.1.tar.gz
# 编译安装Nginx
cd nginx-1.16.1
./configure
make
make install
# 下载MySQL源码包并解压
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.29.tar.gz
tar zxvf mysql-5.7.29.tar.gz
# 编译安装MySQL
cd mysql-5.7.29
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci
make
make install
# 下载PHP源码包并解压
wget https://www.php.net/distributions/php-7.3.5.tar.gz
tar zxvf php-7.3.5.tar.gz
# 编译安装PHP
cd php-7.3.5
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pear --with-pdo-mysql --with-xmlrpc --with-xsl --with-zlib --enable-bcmath --enable-fpm --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip
make
make install
# 配置PHP-FPM
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# 启动Nginx和PHP-FPM
/usr/local/nginx/sbin/nginx
/usr/local/php/sbin/php-fpm
这段代码提供了在Linux环境下从零开始手动编译安装Nginx、MySQL和PHP的步骤。这是一个基本的LNMP(Linux + Nginx + MySQL + PHP)环境,适合学习和了解Web服务器搭建的过程。在实际生产环境中,可能需要考虑更多的配置细节和优化措施。
评论已关闭