源码安装LNMP
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
欢迎加入:高级运维工程师之路 598432640
前言:非常简单的一个平台LNMP,在生产实际环节中我们也经常用到!
二话不说,开始享受我们的搭建过程吧!
一.源码安装nginx
1.安装依赖包
[root@localhost yinzhengjie]# mkdir -pv /yinzhengjie/ && cd /yinzhengjie
[root@bogon yinzhengjie]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel
2.获取nginx软件包
[root@bogon yinzhengjie]# wget http://nginx.org/download/nginx-1.9.15.tar.gz
我已经下载好了这个包:链接:http://pan.baidu.com/s/1o8lSow6 密码:i0tk
3.源码安装nginx
[root@bogon yinzhengjie]# useradd nginx -s /sbin/nologin -M
[root@bogon yinzhengjie]# tar -zxvf nginx-1.9.15.tar.gz
[root@bogon yinzhengjie]# cd nginx-1.9.15
root@bogon nginx-1.9.15]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
[root@bogon nginx-1.9.15]# make -j 4 && make install
4.编辑nginx配合文件,使其支持fastcgi功能
[root@bogon yinzhengjie]# cd /usr/local/nginx/conf/
[root@bogon conf]# cp nginx.conf nginx.conf.`date +%F` 备份配置文件
[root@bogon conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
}
}
5.编写Nginx启动脚本
[root@bogon nginx-1.9.15]# cd /etc/init.d/
[root@bogon init.d]# vim nginx
#!/bin/bash
#chkconfig: 2345 89 89
#Description:This is Nginx web script"
PID="/usr/local/nginx/logs/nginx.pid"
start(){
/usr/local/nginx/sbin/nginx
if [ $? -eq 0 ];then
echo -en "Starting Nginx...\t\t\t["
echo -en "\033[32;34mOK\033[0m"
echo "]"
else
echo "Starting Nginx Error"
fi
}
stop(){
/usr/local/nginx/sbin/nginx -s stop
if [ $? -eq 0 ];then
echo -en "Stop Nginx...\t\t\t["
echo -en "\033[32;34mOK\033[0m"
echo "]"
else
echo "Stop Nginx Error"
fi
}
status(){
if [ -f $PID ];then
ID=$(cat $PID)
echo "Ngix($ID) is running..."
else
echo "Nginx is stop"
fi
}
case $1 in
start)
start;;
stop)
stop;;
restart)
stop
start
;;
status)
status;;
*)
echo "Usage:$0 {start|stop|restart|status}"
esac
5.启动nginx
[root@localhost yinzhengjie]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost yinzhengjie]# chmod +x /etc/init.d/nginx
[root@localhost yinzhengjie]# chkconfig --add nginx
[root@localhost yinzhengjie]# chkconfig nginx on
[root@bogon init.d]# service nginx start
Starting Nginx... [OK]
二.源码安装php
链接:http://pan.baidu.com/s/1c14SaIk 密码:xwox
[root@bogon yinzhengjie]# yum -y install lrzsz (安装上传工具)
利用上传工具将源码包上传到服务器
2.源码安装php
[root@bogon yinzhengjie]# tar -zxvf php-5.5.35.tar.gz
[root@bogon yinzhengjie]# cd php-5.5.35
[root@bogon php-5.5.35]# ./configure --prefix=/usr/local/product/php-5.5.35 --with-config-file-path=/usr/local/product/php-5.5.35/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
[root@bogon php-5.5.35]# make -j 4 && make install
[root@bogon php-5.5.35]# ln -s /usr/local/product/php-5.5.35 /usr/local/php
[root@bogon php-5.5.35]# cp php.ini-production /usr/local/php/etc/php.ini
[root@bogon php-5.5.35]# cd /usr/local/php/etc/
[root@bogon etc]# cp php-fpm.conf.default php-fpm.conf
[root@bogon etc]# vim php.ini
需要修改以下几个参数:
max_execution_time = 300
post_max_size = 16M
max_input_time = 300
date.timezone = PRC
4.启动PHP服务
[root@bogon sbin]# cd /usr/local/php/sbin/
[root@bogon sbin]# ./php-fpm
5.检查php是否启动成功
[root@bogon yinzhengjie]# netstat -untalp | grep :9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 103859/php-fpm
[root@bogon yinzhengjie]#
三.源码安装mysql
1.创建mysql用户
[root@bogon yinzhengjie]# groupadd mysql
[root@bogon yinzhengjie]# mkdir -pv /yinzhengjie/data/mysql
[root@bogon yinzhengjie]# useradd -r -g mysql -d /yinzhengjie/data/mysql/ -s /sbin/nologin mysql
2.获取mysql软件包
这个包我也下载好了:链接:http://pan.baidu.com/s/1gfoOyIJ 密码:6qed
3更换国内阿里云源
[root@bogon yinzhengjie]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@bogon yinzhengjie]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
[root@bogon yinzhengjie]# yum clean all
[root@bogon yinzhengjie]# yum makecache
4.安装依赖包
[root@bogon yinzhengjie]# yum -y install cmake gcc* ncurses-devel
5.源码安装mysql
[root@bogon yinzhengjie]# tar -zxvf mysql-5.5.49.tar.gz
[root@bogon yinzhengjie]# cd mysql-5.5.49
[root@bogon mysql-5.5.49]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/yinzhengjie/data/mysql -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8_general_ci
[root@bogon mysql-5.5.49]# make -j 4 && make install
[root@bogon mysql-5.5.49]# chown -R mysql.mysql /usr/local/mysql
[root@bogon mysql-5.5.49]# cd /usr/local/mysql/support-files/
6.拷贝mysql配置文件
[root@bogon support-files]# cp my-medium.cnf /yinzhengjie/data/mysql/my.cnf
[root@bogon support-files]# cp mysql.server /etc/init.d/mysqld
[root@bogon support-files]# chmod +x /etc/init.d/mysqld
7.初始化mysql
[root@bogon support-files]# cd /usr/local/mysql/scripts
[root@bogon scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/yinzhengjie/data/mysql/
8.修改mysql的数据目录
[root@bogon yinzhengjie]# cd /yinzhengjie/ && more /etc/my.cnf
[mysqld]
datadir=/yinzhengjie/data/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@bogon yinzhengjie]# mkdir -pv /var/lib/mysql/ && ln -s /tmp/mysql.sock /var/lib/mysql/
9.启动mysql
[root@bogon yinzhengjie]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[root@bogon yinzhengjie]# ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
[root@bogon yinzhengjie]# service mysqld start
[root@bogon yinzhengjie]# mysqladmin -uroot password "yinzhengjie"
10.登陆数据库创建一个zabbix库
[root@bogon yinzhengjie]# mysql -pyinzhengjie
mysql> create database zabbix default charset utf8;
mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';
mysql> flush privileges;
mysql> show databases;
mysql> quit
致此:源码搭建LNMP平台完成~
对了,如果你想给php写个启动脚本的话,可以参考我的Nginx启动脚本的哟~
- 源码搭建lnmp平台
lnmp平台是指利用linux操作系统,nginx服务器,mysql数据库和php语言搭建高性能web服务器,负载均衡器和邮件代理服务器. 原理图:‘
- 在CENTOS上源码搭建LNMP环境
前言 1.操作前提: CentOS Linux release 7.5.1804: sudo用户(需要root权限): 2.需要安装的组件: nginx稳定版:nginx-1.14.0: MariaD ...
- CentOS 7 源码搭建LNMP环境
搭建 LNMP 环境 源码包版本 : CentOS Linux 7 nginx-1.15.1.tar.gz mysql-boost-5.7.21.tar.gz php-7.2.7.tar.gz ...
- 用源码搭建LNMP环境+部署WordPress
首先要做的是就是关闭Centos7.4的防火墙及selinux #systemctl stop firewalld #systemctl disable firewalld #sed -ri 's/^ ...
- 利用shell脚本去备份幸运28源码搭建下载所指定的数据库
#! /bin/bash幸运28源码搭建下载Q[115288oo99]logintool=/home/yx/server/mysql/mysql/bin/mysqldumptool=/home/yx/ ...
- linux 手动源码安装lnmp(亲测)
linux 手动源码安装lnmp笔记(亲测)<pre>先安装这2个yum install gccyum install g++</pre><pre>先在linux ...
- CENTOS6.5源码安装LNMP
CENTOS6.5源码安装LNMP 一.安装前准备 ########################################################################## ...
- ARL(资产侦察灯塔系统)-源码搭建
freebuf能力中心开源了一套资产扫描系统(https://github.com/TophantTechnology/ARL),提供docker版,但并无源码搭建的文档(无完整文档).于是在星光哥及 ...
- 直播平台源码搭建教程:微信小程序中的直播如何去掉水印
直播平台源码搭建教程:微信小程序中的直播如何去掉水印 本文与大家分享一下直播平台源码搭建教程,如何去掉直播视频的水印 var services = require('../../lib/service ...
随机推荐
- 127 2016 int
Type Storage Minimum Value Maximum Value (Bytes) (Signed/Unsigned) (Signed/Unsigned) TINYINT 1 -12 ...
- 僵尸传染bfs
#include<stdio.h> int map[4][4]={0,0,0,1, 0,0,1,1, 0,0,1,0, 0,1,0,0}; int mx ...
- ucenter小结
经历了一天的折腾,大概搞清楚的ucenter接入应用的方法.总结如下: 一.下载安装ucenter.这个很简单. 二.然后就是接入应用. 1.先在你项目的根目录copy一份uc_client文件夹. ...
- AP_总体业务及方案
AP关键业务点说明 关键业务点 说明 预付款余额收回 1. 在应付款管理系统中输入一张虚拟发票,该发票的目的是在系统中冲减对供应商的预付款额,其金额等于预付款的未核销金额,供应商为原供应商. 借:其他 ...
- 使用dotTrace6.0进行内存分析
dotTrace6.0提供了内存分析功能,统计抓取的时间段内各个堆栈执行过程中使用的内存大小,按照堆栈执行情况树状排序:和它之前提供的时间统计类似,粗截了几个页面,希望对大家有所帮助. 下载安装Jet ...
- TEST指令
In the x86 assembly language, the TEST instruction performs a bitwise AND on two operands. The flags ...
- 使用多种客户端消费WCF RestFul服务(四)——Jquery篇
Jquery篇 互联网开发中少不了各类前端开发框架,其中JQUERY就是最流行之一,本篇我们就采用JQUERY来消费WCF RestFul服务,其中用到JSON基础知识,如果有想了解的朋友,请访问:& ...
- [LeetCode]题解(python):091 Decode Ways
题目来源 https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encod ...
- A Guide to Creating a Quality Project Schedule
Successful projects start with a good quality project schedule. Creating a schedule is one of the fi ...
- Selenium2学习-003-WebUI自动化实战实例-001-百度搜索
此文主要通过百度搜索功能,进行 Selenium2 的实战实例讲解,文中所附源代码于 2015-01-16 02:01 亲测通过,敬请亲们阅览.希望能对初学 Selenium2 UI 自动化测试编程的 ...