iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >centos6.5搭建lnmp过程
  • 772
分享到

centos6.5搭建lnmp过程

2024-04-02 19:04:59 772人浏览 薄情痞子
摘要

一个不写博客的运维,不是一个好开发1、安装Centos6.5操作系统2、下载Nginx,www.nginx.org3、下载PHP,www.php.net3.2、下载libmcrypt Http:/

一个不写博客的运维,不是一个好开发


1、安装Centos6.5操作系统

2、下载Nginx,www.nginx.org

3、下载PHP,www.php.net

3.2、下载libmcrypt Http://pan.baidu.com/s/1mhHxXzU

4、下载mariadb,downloads.mariadb.org

4.1、下载cmake(Mysql编译工具) http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz

5、关闭selinux

  selinux三个状态,用getenforce命令查看,disable(关闭)permissive(宽松)enforcing(强迫)

  setenforce 0,使其暂时变为宽松模式

  vi /etc/selinux/config

  屏蔽所有行,加上
  SELINUX=disable

6、关闭防火墙

  service iptables stop(临时关闭)

  chkconfig iptables off(使其下次重启为关闭状态)

7、安装编译工具和库文件

  

yum install make apr* autoconf automake curl-devel GCc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libGomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel  libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

  

8、安装cmake
tar zxvf cmake-2.8.8.tar.gz 
cd cmake-2.8.8
./configure 
make
make install

9、安装mysql
groupadd mysql #添加mysql组
useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
mkdir -p /data/mysql #创建MySQL数据库存放目录 
chown -R mysql:mysql /data/mysql #设置权限
mkdir -p /usr/local/mysql #创建安装目录
tar zxvf mysql-5.5.37.tar.gz 
cd mysql-5.5.37  
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #指定安装目录,大家都懂;指定datadir,目前我还没有发现其有什么意义,因为后面还要配置;指定/etc,会使mysql/bin下的一些脚本执行的时候,读取这个位置的my.cnf,但是启动脚本貌似不会读取,反正我是配置了my.cnf的datadir,但是启动脚本还是报错,在启动脚本里配置了datadir就不报错了 
make #编译  
make install #安装  
cd /usr/local/mysql  
cp ./support-files/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:/etc目录下面默认有一个my.cnf,直接覆盖即可)  
vi /etc/my.cnf #编辑配置文件,在 [mysqld] 部分增加  
datadir = /data/mysql #添加MySQL数据库路径(这里加路径,是因为很多mysql的脚本会读取这个文件,例如下一句执行的脚本;不管这里加不加路径,不会影响mysql启动,因为启动脚本里面都必须要加)  
./scripts/mysql_install_db --user=mysql #生成mysql系统数据库(生成三个系统数据库,如果上一句没有加路径,这一句也没有指定路径,会生成到默认目录./mysql/data)  
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动  
chmod 755 /etc/init.d/mysqld #增加执行权限  
chkconfig mysqld on #加入开机启动(这一步会直接加入系统服务,再加入开机启动;如果只想加入系统服务,可以用chkconfig --add mysqld) 
vi /etc/rc.d/init.d/mysqld #编辑  
basedir = /usr/local/mysql #MySQL程序安装路径  
datadir = /data/mysql #MySQl数据库存放目录(这个是必须要加的,不管my.cnf里面加没加)  
service mysqld start #启动 

以下内容可以先不做 
vi /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行,重启系统后生效(可以不加)  
export PATH=$PATH:/usr/local/mysql/bin  
下面这两行把myslq的库文件链接到系统默认的位置,这样你在编译类似PHP等软件时可以不用指定mysql的库文件地址(可以不加)  
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql  
ln -s /usr/local/mysql/include/mysql /usr/include/mysql  
shutdown -r now #需要重启系统,等待系统重新启动之后继续在终端命令行下面操作(可以先不重启,操作指定脚本位置)  
mysql_secure_installation #设置Mysql密码(我一般用第二种,也可以先不修改)
根据提示按Y 回车输入2次密码  
或者直接修改密码/usr/local/mysql/bin/mysqladmin -u root -p passWord "123456" #修改密码  
service mysqld restart #重启


10、安装nginx

cd /usr/local/src

groupadd www

useradd -g www www -s /bin/false

tar zxvf nginx-1.5.13.tar.gz

cd nginx-1.5.13

./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.35

make

make install

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #启动nginx,也可以用下面的脚本,非必须



#设置nginx自启动,加入以下脚本

vi /etc/init.d/nginx


#!/bin/bash

# nginx Startup script for the Nginx HTTP Server

# it is v.0.0.2 version.

# chkconfig: - 85 15

# description: Nginx is a high-perfORMance WEB and proxy server.

#              It has a lot of features, but it's not for everyone.

# processname: nginx

# pidfile: /var/run/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/var/run/nginx.pid

RETVAL=0

prog="nginx"

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 0

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then

   echo "nginx already running...."

   exit 1

fi

   echo -n $"Starting $prog: "

   daemon $nginxd -c ${nginx_config}

   RETVAL=$?

   echo

   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

   return $RETVAL

}

# Stop nginx daemons functions.

stop() {

        echo -n $"Stopping $prog: "

        killproc $nginxd

        RETVAL=$?

        echo

        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid

}

# reload nginx service functions.

reload() {

    echo -n $"Reloading $prog: "

    #kill -HUP `cat ${nginx_pid}`

    killproc $nginxd -HUP

    RETVAL=$?

    echo

}

# See how we were called.

case "$1" in

start)

        start

        ;;

stop)

        stop

        ;;

reload)

        reload

        ;;

restart)

        stop

        start

        ;;

status)

        status $prog

        RETVAL=$?

        ;;

*)

        echo $"Usage: $prog {start|stop|restart|reload|status|help}"

        exit 1

esac

exit $RETVAL



chmod 775 /etc/rc.d/init.d/nginx

chkconfig nginx on

/etc/rc.d/init.d/nginx restart

service nginx restart


11、安装 libmcrypt

cd /usr/local/src

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make

nake install


11.2.安装php

cd /usr/local/src

tar -zvxf php-5.5.10.tar.gz 

cd php-5.5.10

mkdir -p /usr/local/php5


./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-Sockets --with-xmlrpc --enable-zip --enable-soap --with-pear --with-gettext --enable-session --with-mcrypt --with-curl


make

make install


cp php.ini-production /usr/local/php5/etc/php.ini

rm -rf /etc/php.ini

ln -s /usr/local/php5/etc/php.ini /etc/php.ini

cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf 

vi /usr/local/php5/etc/php-fpm.conf

user = www #设置php-fpm运行账号为www 

group = www #设置php-fpm运行组为www 

pid = run/php-fpm.pid #取消前面的分号

cp /usr/local/src/php-5.5.10/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm#拷贝php-fpm到启动目录

chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限

chkconfig php-fpm on #设置开机启动

vi /usr/local/php5/etc/php.ini #编辑配置文件

修改为:date.timezone = PRC #设置时区


12、配置nginx支持php 

vi /usr/local/nginx/conf/nginx.conf #编辑配置文件,需做如下修改

user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否则php运行出错 

index index.php index.html index.htm; #添加index.php

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

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; 

}

#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为

$document_root$fastcgi_script_name,或者使用绝对路径

/etc/init.d/nginx restart #重启nginx


13、测试

cd /usr/local/nginx/html/ #进入nginx默认网站根目录

rm -rf /usr/local/nginx/html/* #删除默认测试页 

vi index.php #编辑

phpinfo();

chown www.www /usr/local/nginx/html/ -R #设置目录所有者

chmod 700 /usr/local/nginx/html/ -R #设置目录权限

shutdown -r now #重启系统



14、相关命令

service nginx restart #重启nginx 
service mysqld restart #重启mysql
/usr/local/php5/sbin/php-fpm #启动php-fpm
/etc/rc.d/init.d/php-fpm restart #重启php-fpm
/etc/rc.d/init.d/php-fpm stop #停止php-fpm


您可能感兴趣的文档:

--结束END--

本文标题: centos6.5搭建lnmp过程

本文链接: https://www.lsjlt.com/news/42872.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • centos6.5搭建lnmp过程
    一个不写博客的运维,不是一个好开发1、安装centos6.5操作系统2、下载nginx,www.nginx.org3、下载php,www.php.net3.2、下载libmcrypt http:/...
    99+
    2022-10-18
  • LNMP搭建
    一、编译安装nginx1.1 关闭防火墙,将安装nginx所需软件包传到/opt目录下并解压1.2 安装依赖包1.3 创建运行用户与组1.4 编译安装Nginx1.5 检查配置文件是否配置...
    99+
    2023-09-02
    nginx 运维 服务器
  • Centos6.5搭建LAMP
    1.首先安装apache(具体文档请联系本博主,首页有博主邮箱)2.设置系统让 Apache 开机自动启动。3.防火墙设置4.vi /etc/sysconfig/iptables   添...
    99+
    2022-10-18
  • RHEL6.5/Centos6.5 搭建bugzilla
    一、安装httpd、 mod_ssl、 mysql-server 、 mysql 、php-mysql 、 gcc 、 perl* 、 mod-perl-devel[root@localhost ~]# y...
    99+
    2022-10-18
  • LNMP环境搭建ZABBIX3.0
    1.LNMP环境搭建,这里就不详细介绍了,但是有几点需要注意    1)mysql如果是二进制或者编译安装,php编译的时候需要一下编译参数  &...
    99+
    2022-10-18
  • Centos6.5下搭建Mongodb服务
    1.系统版本  [root@test2 ~]# cat /etc/issue    CentOS release&n...
    99+
    2022-10-18
  • centos6.5搭建私有云盘
    CentOS6.5搭建owncloud私有云盘基本配置关闭防火墙                        &nbs...
    99+
    2023-06-06
  • 搭建lnmp+nfs+调度器
    →→→大虾好吃吗←←← 目录 搭建lnmp平台 nginx配置 mysql配置 php配置 验证 nfs+调度器 安装服务 nfs配置 调度器配置 验证 →→→大虾好吃吗←←←        实验目标:搭建...
    99+
    2023-09-09
    nginx php 服务器
  • Linux(ubuntu) LNMP环境搭建
    Linux(ubuntu) LNMP环境搭建 1. 配置源地址 Ubuntu默认使用的官方源的服务器在欧洲,从国内访问速度很慢 先修改软件源为国内的, 例如: 阿里云源, 清华源等等 整体步骤: 查询...
    99+
    2023-09-02
    ubuntu linux 服务器 php
  • CentOS6.5下搭建oracle 11g Dataguard(一)
    一、环境准备 主机 1 (主库) 主机 2 (备库) 操作系统 Centos6.5 64 位 Centos6.5...
    99+
    2022-10-18
  • linux怎么搭建LNMP环境
    搭建LNMP环境是在Linux系统上部署Nginx、MySQL和PHP的组合,下面是搭建LNMP环境的步骤:1. 安装Nginx:-...
    99+
    2023-10-10
    linux LNMP
  • docker怎么搭建lnmp环境
    要搭建一个LNMP环境(即 Linux + Nginx + MySQL + PHP),可以使用Docker来实现。 以下是基本的步骤...
    99+
    2023-10-23
    docker lnmp
  • Ubuntu怎么搭建LNMP环境
    这篇文章主要介绍“Ubuntu怎么搭建LNMP环境”,在日常操作中,相信很多人在Ubuntu怎么搭建LNMP环境问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Ubuntu怎么搭建LNMP环境”的疑惑有所帮助!...
    99+
    2023-06-13
  • 麒麟系统+lnmp+laravel 搭建
    银河麒麟系统安装 官网选择对应的镜像下载 https://eco.kylinos.cn/partners/mirror.htmlclass_id=1&query_key= 下载rufus 制作启动...
    99+
    2023-09-29
    laravel php html
  • docker如何搭建lnmp环境
    要在Docker中搭建LNMP环境(即Linux、Nginx、MySQL和PHP),可以按照以下步骤进行操作:1. 安装Docker...
    99+
    2023-08-23
    docker lnmp
  • CentOS6.5的部署过程
    这篇文章主要介绍“CentOS6.5的部署过程”,在日常操作中,相信很多人在CentOS6.5的部署过程问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS6.5的部署过程”的疑惑有所帮助!接下来,请跟...
    99+
    2023-06-03
  • Ubuntu 搭建LNMP环境的方法
    本篇内容介绍了“Ubuntu 搭建LNMP环境的方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!调出命令行界面,键入“cd /u...
    99+
    2023-06-13
  • centos6.5系统快速搭建mysql方法
    下面一起来了解下centos6.5系统快速搭建mysql方法,相信大家看完肯定会受益匪浅,文字在精不在多,希望centos6.5系统快速搭建mysql方法这篇短内容是你想要的。1、查看系统是否已经有自带的数...
    99+
    2022-10-18
  • Centos6.5 + Oracle 11g r2 + nfs搭建RAC环境
       ...
    99+
    2022-10-18
  • CentOS6.5下搭建文件共享服务Samba的教程
    Samba服务:   本内容为samba服务学习者提供参考 案例描述:   某公司的管理员需要搭建SAMBA服务器,IP地址及允许的访问网段自定义。SAMBA服务器的安全级别为user级,所在工作组为WORKGROUP,...
    99+
    2022-06-04
    CentOS6.5 共享服务 搭建文件共享服务
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作