如何进行centos7_Lnmp的编译安装
发表于:2026-11-05 作者:千家信息网编辑
千家信息网最后更新 2026年11月05日,如何进行centos7_Lnmp的编译安装,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。编译安装nginx+php+mysql,操作
千家信息网最后更新 2026年11月05日如何进行centos7_Lnmp的编译安装
如何进行centos7_Lnmp的编译安装,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
编译安装nginx+php+mysql,操作如下
准备环境
环境:centos7.3
软件:nginx-1.12.1 + mysql-5.7.19 + php-7.1.8
yum -y remove php mysql httpd## 添加epel源:(如果是版本6的操作系统请用第二条)rpm -ivh https://mirrors.ustc.edu.cn/epel/7/x86_64/e/epel-release-7-10.noarch.rpm --forcerpm -ivh https://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm --force## centos源:rpm -ivh http://mirrors.163.com/centos/6.9/os/x86_64/Packages/centos-release-6-9.el6.12.3.x86_64.rpm --force==================================================================================
安装Mysql
1. 创建用户useradd mysql2.下载安装包、依赖的库:wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gzyum install cmake gcc-c++ ncurses-devel perl boost-devel bison-devel bison -y3.安装boost插件:注:如果只为安装mysql其实可以不用安装的,解压就好,到时安装mysql时引用目录,不过percona-xtrabackup需要用到,所以我安装了。wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz./bootstrap.sh./b2 install4.编译安装:cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/var/downloads/boost_1_59_0 -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1make && make install5.配置/etc/my.cnf 仅作测试,没加任何优化参数。cat > /etc/my.cnf << EOF[client]socket=/var/data/mysql/mysql.sock[mysqld]basedir=/usr/local/mysqldatadir=/var/data/mysqlsocket=/var/data/mysql/mysql.socksymbolic-links=0log-error=/var/log/mysql.logpid-file = /tmp/mysql.pidEOF6.添加环境变量:vi /etc/profileecho -e '\n\nPATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile && source /etc/profile7.初始化数据&更改相应权限:/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/var/data/mysqlchown -R mysql:mysql /var/data/mysql8、配置开机启动项(centos7操作姿势)cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldsystemctl enable mysqld9.启动数据库:systemctl start mysqld10.创建密码(推荐使用中等 MEDIUM 级别)、添加其它用户(可选):mysql_secure_installationCREATE DATABASE `lampdb` ;grant all privileges on lampdb.* to 'lamp@%' identified by 'Hi.lamp@888';flush privileges;
PHP安装
1.下载并安装依赖包:wget http://mirrors.sohu.com/php/php-7.1.8.tar.gzyum clean allyum install libjpeg libjpeg-devel curl-devel gcc gcc-c++ libxml2-devel openssl openssl-devel libpng-devel freetype-devel libmcrypt libmcrypt-devel -y2.添加用户:useradd -s /sbin/nologin php3.编译php:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --with-mhashmake && make install4.复制相关配置文件(仅测试用,生产请用专业的配置文件):cp /var/downloads/php-7.1.8/php.ini-production /usr/local/php/etc/php.inicp /var/downloads/php-7.1.8/sapi/fpm/init.d.php-fpm /etc/init.d/phpcp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confchmod u+x /etc/init.d/phpmkdir -p /var/data/php/log/5.启动服务:/etc/init.d/php start/etc/init.d/php status
Nginx安装
1.下载nginx:wget https://nginx.org/download/nginx-1.12.1.tar.gzyum install openssl openssl-devel pcre-devel zlib-devel -yyum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel2.添加用户:useradd -s /sbin/nologin nginx3.编译安装:./configure --prefix=/usr/local/nginx --without-http_memcached_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_modulemake && make install4.配置Nginx支持php-fpm模块vim /usr/local/nginx/conf/nginx.conflocation / { root html; index index.html index.htm index.php;}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;}5.添加环境变量:echo -e '\n\nPATH=/usr/local/nginx/sbin:$PATH' >> /etc/profile && source /etc/profile6.启动Nginx/usr/local/nginx/sbin/nginx5.详细可以参考这里:http://www.cnblogs.com/zhang-shijie/p/5294162.htmlhttp://www.cnblogs.com/lyongde/p/4201484.html==========================================================访问验证:验证php:建立测试页面test1.phpvi /usr/local/apache/htdocs/test1.php浏览器输入:http://116.196.xx.xxx/test1.php常见问题
安装PHP需要的依赖:1.安装libiconv:wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz./configure --prefix=/usr/local/libiconvmake && make install2.安装libmcryptwget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz./configuremake && make install3.安装 Mhash下载地址(下载后上传到服务器):https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download?use_mirror=nchc&r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fmhash%2Ffiles%2Fmhash%2F0.9.9.9%2Fmhash-0.9.9.9.tar.gz%2Fdownload&use_mirror=nchc./configuremake && make install4.安装Mcryptwget http://iweb.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz#注意一下这步运行下,不然下面可能报错export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH./configuremake && make install编译mcrypt可能会报错:configure: error: *** libmcrypt was not foundvi /etc/ld.so.conf最后一行添加/usr/local/lib/保存并退出::wq!执行载入命令:ldconfig---------------------------------------------------------checking for libmcrypt - version >= 2.5.0... no*** Could not run libmcrypt test program, checking why...*** The test program compiled, but did not run. This usually means*** that the run-time linker is not finding LIBMCRYPT or finding the wrong*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point*** to the installed location Also, make sure you have run ldconfig if that*** is required on your system****** If you have an old version installed, it is best to remove it, although*** you may also be able to get things to work by modifying LD_LIBRARY_PATH***configure: error: *** libmcrypt was not found---------------------------------------------------------------
完成收工!
关于如何进行centos7_Lnmp的编译安装问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
编译
配置
用户
问题
环境
测试
数据
文件
更多
帮助
服务
解答
验证
易行
操作系统
简单易行
一行
不用
到时
参数
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
上海挚品互联网科技有限公司
有格互联网科技
科技企业和互联网企业
互联网金融公司科技
互联网 科技创业
互联网科技公司官网
未来的互联网科技
金融科技和互联网金融
无锡溥仪互联网科技有限公司
山东吉时兔互联网科技有限公司
天津腾达互联网科技有限公司
深圳艾果互联网通讯科技
黑云互联网科技有限公司
张召忠谈中国互联网科技
银川新华互联网科技学校是国营吗
互联网科技收购价值
互联网时代高科技布局
科技和互联网行业的特点
第三届互联网大会安防黑科技
科技互联网专业工作会议发言稿
咖啡豆
腾讯阿里互联网科技
互联网科技论文
友谊互联网络科技
撒么互联网科技公司
上海卓越科技 互联网
滨湖区互联网智能科技产品供应
南山科技园互联网公司有哪些
高科技互联网发展前景如何
互联网对科技影响