源码搭建LNMP

                                        源码安装LNMP

                                                                                        作者:尹正杰

前言:非常简单的一个平台LNMP,在生产实际环节中我们也经常用到!

二话不说,开始享受我们的搭建过程吧!

一.源码安装nginx

1.安装依赖包

[[email protected] 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软件包

[[email protected] yinzhengjie]# wget http://nginx.org/download/nginx-1.9.15.tar.gz

3.源码安装nginx

[[email protected] yinzhengjie]# useradd nginx -s /sbin/nologin -M

[[email protected] yinzhengjie]# tar -zxvf nginx-1.9.15.tar.gz

[[email protected] yinzhengjie]# cd nginx-1.9.15

[email protected] nginx-1.9.15]# ./configure --prefix=/usr/local/product/nginx1.9.14 --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre

[[email protected] nginx-1.9.15]# make -j 4 && make install

4.编辑nginx配合文件,使其支持fastcgi功能

[[email protected] yinzhengjie]# cd /usr/local/nginx/conf/

[[email protected] conf]# cp nginx.conf nginx.conf.`date +%F` 备份配置文件

[[email protected] 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启动脚本

[[email protected] nginx-1.9.15]# cd /etc/init.d/

[[email protected] 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

[[email protected] init.d]# service nginx start

Starting Nginx... [OK]

二.源码安装php

链接:http://pan.baidu.com/s/1c14SaIk 密码:xwox

[[email protected] yinzhengjie]# yum -y install lrzsz (安装上传工具)

利用上传工具将源码包上传到服务器

2.源码安装php

[[email protected] yinzhengjie]# tar -zxvf php-5.5.35.tar.gz

[[email protected] yinzhengjie]# cd php-5.5.35

[[email protected] 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

[[email protected] php-5.5.35]# make -j 4 && make install

[[email protected] php-5.5.35]# ln -s /usr/local/product/php-5.5.35 /usr/local/php

[[email protected] php-5.5.35]# cp php.ini-production /usr/local/php/etc/php.ini

[[email protected] php-5.5.35]# cd /usr/local/php/etc/

[[email protected] php-5.5.35]# cp php-fpm.conf.default php-fpm.conf

[[email protected] etc]# vim php.ini

需要修改以下几个参数:

max_execution_time = 300

memory_limit = 128M

post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date.timezone = PRC

4.启动PHP服务

[[email protected] sbin]# cd /usr/local/php/sbin/

[[email protected] sbin]# ./php-fpm

5.检查php是否启动成功

[[email protected] yinzhengjie]# netstat -untalp | grep :9000

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 103859/php-fpm

[[email protected] yinzhengjie]#

三.源码安装mysql

1.创建mysql用户

[[email protected] yinzhengjie]# groupadd mysql

[[email protected] yinzhengjie]# mkdir -pv /yinzhengjie/data/mysql

[[email protected] yinzhengjie]# useradd -r -g mysql -d /yinzhengjie/data/mysql/ -s /sbin/nologin mysql

2.获取mysql软件包

[[email protected] yinzhengjie]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49.tar.gz

3更换国内阿里云源

[[email protected] yinzhengjie]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

[[email protected] yinzhengjie]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

[[email protected] yinzhengjie]# yum clean all

[[email protected] yinzhengjie]# yum makecache

4.安装依赖包

[[email protected] yinzhengjie]# yum -y install cmake gcc* ncurses-devel

5.源码安装mysql

[[email protected] yinzhengjie]# tar -zxvf mysql-5.5.49.tar.gz

[[email protected] yinzhengjie]# cd mysql-5.5.49

[[email protected] 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

[[email protected] mysql-5.5.49]# chown -R mysql.mysql /usr/local/mysql

[[email protected] mysql-5.5.49]# cd /usr/local/mysql/support-files/

6.拷贝mysql配置文件

[[email protected] support-files]# cp my-medium.cnf /yinzhengjie/data/mysql/my.cnf

[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld

[[email protected] support-files]# chmod +x /etc/init.d/mysqld

7.初始化mysql

[[email protected] support-files]# cd /usr/local/mysql/scripts

[[email protected] scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/yinzhengjie/data/mysql/

8.修改mysql的数据目录

[[email protected] 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

[[email protected] yinzhengjie]# mkdir -pv /var/lib/mysql/ && ln -s /tmp/mysql.sock /var/lib/mysql/

9.启动mysql

[[email protected] yinzhengjie]# service mysqld start

[[email protected] yinzhengjie]# ln -s /usr/local/mysql/bin/mysql /usr/bin/

[[email protected] yinzhengjie]# ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/

[[email protected] yinzhengjie]# mysqladmin -uroot password "yinzhengjie"

10.登陆数据库创建一个zabbix库

[[email protected] yinzhengjie]# mysql -pyinzhengjie

mysql> create database zabbix default charset utf8;

mysql> grant all privileges on zabbix.* to [email protected]‘localhost‘ identified by ‘zabbix‘;

mysql> flush privileges;

mysql> show databases;

mysql> quit

致此:源码搭建LNMP平台完成~

时间: 2024-10-26 07:37:16

源码搭建LNMP的相关文章

CentOS6.7源码搭建LNMP平台

LNMP是Linux+ Nginx+ MySQL +PHP的简称.先安装mysql:然后是php,php使用fast-cgi的方式运行:最后安装Nginx. 安装平台:CentOS6.7 X86_64 MySql版本:mysql-5.6.27 MySql安装目录:/usr/local/mysql MySql数据库存放目录:/data/mysql MySql的用户和组:mysql:mysql MySql源码存放目录:/usr/local/src 安装前的准备: (1).关闭selinux vim

在CENTOS上源码搭建LNMP环境

前言 1.操作前提: CentOS Linux release 7.5.1804: sudo用户(需要root权限): 2.需要安装的组件: nginx稳定版:nginx-1.14.0: MariaDB 10.3.10 Stable: PHP 7.2.11 Stable: 3.操作步骤: 添加环境依赖包: 安装libiconv,libmcrypt等: 安装nginx: 安装php: 安装mariadb: 下载安装包 wget http://nginx.org/download/nginx-1.1

高性能web服务器nginx(三)之源码搭建LNMP

一.环境准备 1.关闭防火墙及selinux [[email protected] ~]# iptables -F [[email protected] ~]# getenforce  Disabled 2.更改yum源(此步根据自身需要更改) [[email protected] ~]# wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-6.repo [[email protected] ~]# mv /etc/yu

源码搭建lnmp环境

关闭防火墙: [[email protected]_DB ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                              

源码编译lnmp之简介与nginx安装

源码编译lnmp 系统环境:Centos 6.6 相关软件包: nginx-1.11.6.tar.gz mysql-boost-5.7.15.tar.gz php-5.6.28.tar.bz2 下载地址: nginx官网:http://nginx.org mysql官网:http://dev.mysql.com/downloads/mysql/ php官网:http://jp2.php.net/downloads.php 第一部分:安装nginx 一.安装nginx时必须先安装相应的编译工具 1

源码搭建LAMP环境

源码搭建LAMP环境 一,LAMP环境概述: LAMP指的Linux(操作系统).ApacheHTTP 服务器,MySQL(有时也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python) 的第一个字母,一般用来建立web 服务器.是一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台.随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势

linux下源码搭建php环境之mysql(一)

现在已经大半夜了,五一劳动节挺无聊的. 折腾一下吧,实在是睡不着.于是乎在电脑上安装个虚拟机,然后呢,在虚拟机上搭建一个php环境. 首先我得安装MYSQL吧.发现遇到的问题真多..待我娓娓道来. 主要介绍linux操作系统下MySQL源码进行纯手动安装,如果你对linux操作系统下MySQL源码进行纯手动安装的实际操作流程感兴趣的话,你不妨浏览以下的文章. 1.实现linux下纯手动MySQL源码安装,首先要下载MySQL的源码,我下载的是MySQL-5.0.87.tar.gz 2.解压tar

网狐棋牌源码搭建教程之棋牌平台服务器架构(一)

一,棋牌类服务器的特点 1,棋牌类不分区不分服 一般来说,棋牌游戏都是不分区不分服的.所以棋牌类服务器要满足随着用户量的增加而扩展的需要. 2,房间模式 即在同一局游戏中就是在同一个房间中,同一个房间中的人可以接收到其他人的消息. 3,每个房间的操作必须是顺序性 这个特性类似与一般游戏的回合制,每个玩家的操作都是有顺序性的. 二,需要解决的技术点 1,数据共享 因为棋牌类游戏不分区不分服(棋牌源码搭建 www.yasewl.com),我们在设计服务器的时候,是按世界服的思想去设计,即服务器是一个

网狐棋牌源码搭建2017年最新网狐荣耀棋牌源码搭建下载

2017年最新网狐荣耀棋牌源码:含大厅全套源码+客户端+服务端+网站+后台+完整数据库 (更多详情网狐棋牌源码搭建 www.yasewl.com QQ:2189563389)