源码编译安装LNMP
发布日期:2021-07-29 11:00:20
浏览次数:2
分类:技术文章
本文共 5806 字,大约阅读时间需要 19 分钟。
目录
前言
LNMP是什么?
LNMP即是Linux +Nginx+Mysql+PHP的简称,是一个基于CentOS/Debian编写的Nginx、PHP、MySQL、phpMyAdmin、eAccelerator一键安装包 ,是用来在Linux系统下Nginx+MySQL+PHP这种网站中搭建服务器架构。
Nginx是什么
是一款小巧且高效的 Linux下 Web 服务器软件,是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。
MySQL是什么
是一种开放源代码的关系型数据库管理系统(RDBMS),MySQL数据库系统使用最常用的数据库管理语言--结构化查询语言(SQL)进行数据库管理。
PHP是什么
是一种通用开源脚本语言。语法吸收了 C 语言、Java 和 Perl 的特点,利于学习,使用广泛,主要适用于 Web 开发领域。PHP 独特的语法混合了C、Java、Perl 以及 PHP 自创的语法。
基础环境的准备
一台centos 7 系统的虚拟机即可
搭建所需要的LNMP软件包
链接:https://pan.baidu.com/s/1bOR-rMurWbIZvs9oBN9F0g
提取码:THQ1关闭防火墙和selinux
[root@localhost nginx-1.8.0]# systemctl stop firewalld && systemctl disable firewalld [root@localhost nginx-1.8.0]# setenforce 0[root@localhost nginx-1.8.0]# iptables -F[root@localhost nginx-1.8.0]# iptables -X[root@localhost nginx-1.8.0]# iptables -Z
源码安装nginx
下载依赖包[root@localhost nginx-1.8.0]# yum install gcc gcc-c++ autoconf automake libtool make zlib zlib-devel openssl openssl-devel pcre* pcre-devel net-tools -y[root@localhost ~]# tar xf nginx-1.8.0.tar.gz -C /usr/local/src/[root@localhost ~]# cd /usr/local/src/nginx-1.8.0/[root@localhost nginx-1.8.0]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre[root@localhost nginx-1.8.0]# make -j 2 ; make install[root@localhost nginx-1.8.0]# /usr/local/nginx/sbin/nginx 启动成功[root@localhost nginx-1.8.0]# netstat -ntlup | grep nginxtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22321/nginx: master
nginx优化
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf 44 location / { 45 root html; 46 index index.php index.html index.htm; //新增支持index.php 47 }取消注释 66 location ~ \.php$ { 67 root html; 68 fastcgi_pass 127.0.0.1:9000; 69 fastcgi_index index.php; 70 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_scri pt_name; //新增/usr/local/nginx/html 71 include fastcgi_params;
安装MySQL
[root@localhost ~]# tar xf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz -C /usr/local/ [root@localhost ~]# cd /usr/local/[root@localhost ~]# mv mysql-8.0.13-linux-glibc2.12-x86_64/ mysql[root@localhost ~]# cd mysql/[root@localhost ~]# useradd -M -s /sbin/nologin mysql [root@localhost ~]# bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data2021-05-16T10:15:05.727773Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: k?:-.a0dl6%O //#生成临时密码2021-05-16T10:15:07.075863Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) initializing of server has completed[root@localhost mysql]# cd support-files/[root@localhost mysql]# cp mysql.server /etc/init.d/[root@localhost mysql]# rm -rf /etc/my.cnf //删除旧数据库配置文件,数据库初始化生成新的[root@localhost mysql]# /etc/init.d/mysql.server start[root@localhost mysql]# netstat -nltup | grep 3306tcp6 0 0 :::33060 :::* LISTEN 59350/mysqld tcp6 0 0 :::3306 :::* LISTEN 59350/mysqld 环境变量:[root@localhost mysql]# cd[root@localhost ~]# vi .bash_profile //添加环境变量PATH=$PATH:$HOME/bin:/usr/local/mysql/bin[root@localhost ~]# source .bash_profile //执行环境变量[root@localhost ~]# mysql -u root -pk?:-.a0dl6%OType 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>修改密码初始化数据库[root@localhost ~]# mysql_secure_installation
安装PHP的依赖
[root@localhost ~]# yum install php-pear wget -y[root@localhost ~]# wget https://www.linuxprobe.com/Software/libmcrypt-2.5.8.tar.gz[root@localhost ~]# tar xf libmcrypt-2.5.8.tar.gz -C /usr/local/src/ [root@localhost ~]# cd /usr/local/src/libmcrypt-2.5.8/[root@localhost libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt ; make ; make install ; cd[root@localhost ~]# yum -y install gcc gcc-c++ libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel[root@localhost ~]# vi /etc/ld.so.conf[root@localhost ~]# ldconfig [root@localhost ~]# echo 'ldconfig' >> /etc/rc.local[root@localhost ~]# yum install sqlite-devel[root@localhost ~]# tar xf oniguruma-6.9.4.tar.gz [root@localhost oniguruma-6.9.4]# ./autogen.sh && ./configure --prefix=/usr[root@localhost oniguruma-6.9.4]# make && make install
安装PHP
[root@localhost ~]# tar xf php-5.6.13.tar.gz -C /usr/local/src/[root@localhost ~]# cd /usr/local/src/php-5.6.13/[root@localhost php-5.6.13]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-mysqlnd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --with-mcrypt=/usr/local/libmcrypt[root@localhost ~]# make -j 3 && make install ; cd[root@localhost ~]# cp /usr/local/src/php-5.6.13/php.ini-production /usr/local/php/php.ini[root@localhost ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf[root@localhost ~]# cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm[root@localhost ~]# chmod +x /etc/init.d/php-fpm[root@localhost ~]# chkconfig php-fpm on[root@localhost ~]# /etc/init.d/php-fpm start启动成功[root@localhost ~]# netstat -nltup | grep 9000tcp 0 0 127.0.0.1:9000
网页测试
[root@localhost ~]# echo " " > /usr/local/nginx/html/index.php
转载地址:https://blog.csdn.net/thq1443765353/article/details/118252031 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年04月15日 10时12分00秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
如何使用R语言在SAP Analytics Cloud里绘制各种统计图表
2019-04-27
阿里云上的docker安装
2019-04-27
重新安装SCCM 2012 client,解决Windows10 1909在线更新问题
2019-04-27
使用jasmine.createSpyObj具有依赖关系的Angular服务进行单元测试
2019-04-27
MAYA 绑定 批量 关联属性 (手指FK 2 SK)
2019-04-27
c语言格式化浮点数多余的0
2019-04-27
Linux快速创建文件命令
2019-04-27
Linux下挂载U盘
2019-04-27
ubtunu开机黑屏无桌面解决方法
2019-04-27
Linux开发_退格符的花样用法
2019-04-27
Linux开发_判断程序是否以管理员权限运行(root/sudo)
2019-04-27
Windows核心编程_实现QQ好友来消息时任务栏头像闪烁功能
2019-04-27
CMake构建_增加编译选项(debug&&release)
2019-04-27
Cmake构建_指定gcc/g++版本
2019-04-27
Cmake构建_设置全局编译选项
2019-04-27
Cmake构建_设置debug与release不同名字
2019-04-27
Cmake构建_设置debug与release输出路径
2019-04-27
Cmake构建_选择debug与release的库
2019-04-27
ZeroMQ设置超时等待
2019-04-27