LNMP编译安装(亲测ok)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP编译安装(亲测ok)相关的知识,希望对你有一定的参考价值。
以下正式操作前的各个软件版本和系统环境参考这三篇为前提
apache:https://blog.51cto.com/popli3/2357295
php:https://blog.51cto.com/popli3/2358720
mysql:https://blog.51cto.com/popli3/2357211
安装Mysql
-
清理之前安装的mysql环境
[[email protected] mysql]# rm -rf /etc/init.d/mysqld
[[email protected] mysql]# rm -rf /usr/local/mysql/
[[email protected] mysql]# rm -rf /data/mysql/* - 下载并初始化数据库
[[email protected] mysql]# tar xf mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[[email protected] mysql]# cd /usr/local/
[[email protected] local]# ln -sv mysql-5.6.42-linux-glibc2.12-x86_64/ mysql
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql -
复制一些模板文件
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql - 开启服务
[[email protected] mysql]# service mysqld start
[[email protected] mysql]# netstat -tupln |grep mysql
安装PHP
- 清理php之前编译环境
[[email protected] ~]# cd php-7.3.2/
[[email protected] php-7.3.2]# make clean - 安装环境,我这个环境是在之前装过php,没验证过是否有些组件在之前已经安装了
[[email protected] php-7.3.2]# yum -y install libcurl-devel gcc-c++
- 可能会几个选项不认,没关系
[[email protected] php-7.3.2]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc/ --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
-
编译安装
[[email protected] php-7.3.2]# make && make install
- 添加环境变量php-fpm
[[email protected] php-7.3.2]#vi /etc/profile.d/php-fpm.sh
export PATH=/usr/local/php-fpm/sbin:$PATH
[[email protected] php-7.3.2]# source /etc/profile.d/php-fpm.sh - 复制模板php.ini
[[email protected] php-7.3.2]#cp php.ini-production /usr/local/php-fpm/etc/php.ini
-
编辑php-fpm.conf
[[email protected] php-7.3.2]#vi /usr/local/php-fpm/etc/php-fpm.conf
[global]
pid=/usr/local/php-fpm/var/run/php-fpm.pid
error_log=/usr/local/php-fpm/var/log/php-fpm.log
[www]
listen=/tmp/php-fcgi.sock
listen.mode=666
user=php-fpm
group=php-fpm
pm=dynamic
pm.max_children=50
pm.start_servers=20
pm.min_spare_servers=5
pm.max_spare_servers=35
pm.max_requests=500
rlimit_files=1024 - 进入源码php的目录,拷贝模板文件,并设置开机启动
[[email protected] ~]# cd ~/php-7.3.2/
[[email protected] php-7.3.2]#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-7.3.2]#chmod 755 /etc/init.d/php-fpm
[[email protected] php-7.3.2]#chkconfig --add php-fpm
[[email protected] php-7.3.2]#chkconfig php-fpm on
[[email protected] php-7.3.2]#useradd php-fpm
[[email protected] php-7.3.2]#service php-fpm start - 检查下进程启动是否成功
[[email protected] php-7.3.2]# ps -ef |grep php-fpm
安装nginx
- 下载并解压
[[email protected] ~]#wget http://nginx.org/download/nginx-1.13.8.tar.gz
[[email protected] ~]#tar xf nginx-1.13.8.tar.gz - 设置环境并make安装
[[email protected] ~]#cd nginx-1.13.8
[[email protected] nginx-1.13.8]#./configure --prefix=/usr/local/nginx
[[email protected] nginx-1.13.8]#make && make install
以上是关于LNMP编译安装(亲测ok)的主要内容,如果未能解决你的问题,请参考以下文章