首页 > 数据库 >Lnmp(mysql分离)(nginx 1.13.6+mysql5.5+php5.3)环境一键搭建

Lnmp(mysql分离)(nginx 1.13.6+mysql5.5+php5.3)环境一键搭建

时间:2024-10-17 20:47:32浏览次数:7  
标签:1.13 nginx mysql5.5 Lnmp -- usr mysql php local

Lnmp(mysql分离)(nginx 1.13.6+mysql5.5+php5.3)环境一键搭建

如果对运维课程感兴趣,可以在b站上、csdn或微信视频号 上搜索我的账号: 运维实战课程,可以关注我,学习更多免费的运维实战技术视频

在192.168.37.128服务器上:(mysql只到make install即可)nginx默认站点html

1.上传lnmp的安装包

[root@localhost ~]# mkdir /nginx

rz上传nginx 1.13.6源码包到/nginx /目录下

[root@localhost ~]# ls /nginx/

nginx-1.13.6.tar.gz

[root@localhost ~]# mkdir /mysql

rz上传mysql5.5包和cmake包

[root@localhost ~]# ls /mysql/

cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz

[root@localhost ~]# mkdir /php

rz上传php5.3和各依赖包

[root@localhost ~]# ls /php/

libiconv-1.14.tar.gz  libmcrypt-2.5.8.tar.gz  mhash-0.9.9.9.tar.gz  php-5.3.27.tar.gz

2.开发一键安装lnmp平台脚本

[root@localhost ~]# cat lnmp_install.sh

#!/bin/bash

LANG=en_US.UTF-8    

#安装nginx1.13.6(单网站域名,在默认站点目录html中)

rpm -q gcc ||yum -y install gcc

rpm -q gcc-c++ || yum -y install gcc-c++

rpm -q openssl-devel || yum -y install openssl-devel

rpm -q zlib-devel || yum -y install zlib-devel

rpm -q pcre-devel || yum -y install pcre-devel

useradd nginx &> /dev/null

cd /nginx/

tar -zxf nginx-1.13.6.tar.gz

cd nginx-1.13.6

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_ssl_module

make && make install

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx

netstat -anptu |grep :80

#安装mysql5.5(单实例)

cd /mysql

           #先安装cmake,并安装最后提示运行gmake方式来安装cmake软件

tar -zxf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

cd ..

yum -y install ncurses-devel   #安装mysql依赖包

                               #用cmake软件包安装mysql5.5

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

tar -zxf mysql-5.5.32.tar.gz

cd mysql-5.5.32

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.32 \

-DMYSQL_DATADIR=/usr/local/mysql-5.5.32/data \

-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.32/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \

-DENABLED_LOCAL_INFILE=ON \

-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_DEBUG=0

make && make install

ln -s /usr/local/mysql-5.5.32/ /usr/local/mysql

#安装php5.3

cd /php/                                                    #先安装php所需的图形lib库

yum -y install zlib libxml libjpeg freetype libpng gd curl  zlib-devel libxml2-devel libjpeg-turbo-devel freetype-devel  \yum -y install libpng-devel gd-devel curl-devel

yum -y install libxslt*                                    #安装普通的依赖包

yum -y install openldap openldap-devel

cp -frp /usr/lib64/libldap* /usr/lib/

                                                           #安装那3个依赖包,编译安装的

tar -zxf mhash-0.9.9.9.tar.gz

tar -zxf libiconv-1.14.tar.gz

tar -zxf libmcrypt-2.5.8.tar.gz

cd mhash-0.9.9.9

./configure

make && make install

cd ..

cd libiconv-1.14

./configure

make && make install

cd ..

cd libmcrypt-2.5.8

./configure

make && make install

cd libltdl/

./configure --enable-ltdl-install

make && make install

ln -s /usr/local/lib/libmhash.* /usr/lib

ln -s /usr/local/lib/libmcrypt* /usr/lib

ln -s /usr/local/lib/libiconv.* /usr/lib

ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/            

#安装php5.3

cd /php/

tar -zxf php-5.3.27.tar.gz

cd php-5.3.27

./configure  \

--prefix=/usr/local/php  \

--enable-fpm  \

--with-mysql=/usr/local/mysql/  \

--with-mysqli=/usr/local/mysql/bin/mysql_config  \

--enable-mbstring  \

--with-config-file-path=/usr/local/php/etc  \

--with-iconv-dir=/usr/local/libiconv/  \

--with-freetype-dir  \

--with-jpeg-dir  \

--with-png-dir  \

--with-zlib  \

--with-libxml-dir=/usr/  \

--enable-xml  \

--disable-rpath  \

--enable-discard-path \

--enable-safe-mode  \

--enable-bcmath  \

--enable-shmop  \

--enable-sysvsem  \

--enable-inline-optimization  \

--with-curl  \

--with-curlwrappers  \

--enable-mbregex  \

--enable-fastcgi \

--enable-force-cgi-redirect \

--enable-mbstring  \

--with-mcrypt  \

--with-gd  \

--enable-gd-native-ttf  \

--with-openssl  \

--with-mhash  \

--enable-pcntl  \

--enable-sockets  \

--with-ldap \

--with-ldap-sasl  \

--with-xmlrpc  \

--enable-zip  \

--enable-soap  \

--enable-short-tags  \

--enable-zend-multibyte  \

--enable-static  \

--with-xsl  \

--with-fpm-user=nginx  \

--with-fpm-group=nginx

make ZEND_EXTRA_LIBS='-liconv'     #编译时,支持编码转换的扩展库

make install

cp php.ini-production /usr/local/php/etc/php.ini  #拷贝php配置文件

echo "/usr/local/mysql/lib" >> /etc/ld.so.conf  #将mysql的lib库文件目录加入到ldconfig

ldconfig

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf   #拷贝fast-cgi动态网页配置文件

                                       #修改fast-cgi配置文件,配置动态网页参数

sed -i '25s#;pid = run/php-fpm.pid#pid = run/php-fpm.pid#g' php-fpm.conf

sed -i '32s#;error_log = log/php-fpm.log#error_log = log/php-fpm.log#g' php-fpm.conf

sed -i '50s#;log_level = notice#log_level = notice#g' php-fpm.conf

sed -i '89s#;daemonize = yes#daemonize = yes#g' php-fpm.conf

cd /php/php-5.3.27/sapi/fpm/

cp init.d.php-fpm /etc/init.d/php-fpm   #拷贝启动动态网页的fast-cgi服务脚本

chmod +x /etc/init.d/php-fpm

/etc/init.d/php-fpm start

#修改nginx配置文件,调用fast-cgi动态网页

sed -i '45s#index  index.html index.htm#index index.php index.html index.htm#g' /usr/local/nginx/conf/nginx.conf

sed -i '65s#\#location#location#g' /usr/local/nginx/conf/nginx.conf

sed -i '66s#\###g' /usr/local/nginx/conf/nginx.conf

sed -i '67s#\###g' /usr/local/nginx/conf/nginx.conf

sed -i '68s#\###g' /usr/local/nginx/conf/nginx.conf

sed -i '69s#\#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name#    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name#g' /usr/local/nginx/conf/nginx.conf

sed -i '70s#\###g' /usr/local/nginx/conf/nginx.conf

sed -i '71s#\###g' /usr/local/nginx/conf/nginx.conf

echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s stop

/usr/local/nginx/sbin/nginx

/etc/init.d/php-fpm restart

/etc/init.d/mysqld restart

netstat -anptu |grep 80

netstat -anptu |grep 3306

netstat -anptu |grep 9000

wq

3.服务器建立测试连接mysql程序的代码,测试php是否能连接mysql

[root@localhost ~]# cat /usr/local/nginx/html/linkdb.php

<?php

$linkdb=mysql_connect("192.168.37.129","test1","test1");  #mysqL数据库的IP,用户名和密码

if($linkdb){

        echo "db ok";

}else{

        echo "db no";

}

?>

wq

在192.168.37.128服务器上安装mysql5.5.32

1.上传mysql包

[root@localhost ~]# mkdir /mysql

rz上传mysql5.5包和cmake包

[root@localhost ~]# ls /mysql/

cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz

2.开发安装mysql的脚本

[root@localhost ~]# cat install_mysql

#!/bin/bash

LANG=en_US.UTF-8    

#安装编译工具

rpm -q gcc ||yum -y install gcc

rpm -q gcc-c++ || yum -y install gcc-c++

#安装mysql5.5(单实例)

cd /mysql

           #先安装cmake,并安装最后提示运行gmake方式来安装cmake软件

tar -zxf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

cd ..

yum -y install ncurses-devel   #安装mysql依赖包

                               #用cmake软件包安装mysql5.5

groupadd mysql

useradd mysql -s /sbin/nologin -M -g mysql

tar -zxf mysql-5.5.32.tar.gz

cd mysql-5.5.32

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.32 \

-DMYSQL_DATADIR=/usr/local/mysql-5.5.32/data \

-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.32/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \

-DENABLED_LOCAL_INFILE=ON \

-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_DEBUG=0

make && make install

ln -s /usr/local/mysql-5.5.32/ /usr/local/mysql

cd ..

\cp -f mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf        #拷贝配置文件

echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile   #配置环境变量

source /etc/profile

chown -R mysql.mysql /usr/local/mysql/data/             #授权数据目录和初始化mysql5.5

chmod -R 1777 /tmp/                                     #1是粘贴位,授权是防止/tmp权限有问题

cd /usr/local/mysql/scripts/

./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --user=mysql

\cp -f /mysql/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld  #拷贝启动脚本

chmod +x /etc/init.d/mysqld

/etc/init.d/mysqld start

netstat -anptu |grep 3306

/usr/local/mysql/bin/mysqladmin -u root password '123'   #为mysql增加密码,不是修改,初始没密码

chkconfig mysqld on

wq

3.创建一个测试库,供php程序连接mysql

[root@localhost ~]# mysql -uroot -p123

mysql> create database test1;                                   #创建一个库,供php连接mysql

mysql> grant all on test1.* to test1@"%" identified by "test1"; #授权一个用户,供php连接mysql

mysql> flush privileges;

mysql> quit

[root@localhost scripts]# /etc/init.d/mysqld stop

[root@localhost scripts]# /etc/init.d/mysqld start

widows客户端访问服务器页面:

1)能解析php

2)php能够连接mysql

如果对运维课程感兴趣,可以在b站上、csdn或微信视频号 上搜索我的账号: 运维实战课程,可以关注我,学习更多免费的运维实战技术视频

标签:1.13,nginx,mysql5.5,Lnmp,--,usr,mysql,php,local
From: https://blog.csdn.net/qq_34953582/article/details/143028156

相关文章

  • Fileheader 1.13.1 - ColorLinux
    为了在控制台打印彩色内容而设计的头文件早就想封了,今天实现一下普通输出这是第一版写的,因为觉得不好就弃用,但是并没有删,在某些场合可能会用的方便点这一版定义了一个color_print()其定义为#definecolor_print(x)printf("%s",((string)""+(x)+color.NONE).c_str())可以......
  • 基于LNMP快速搭建WordPress平台
    1、案例目标(1)了解LNMP环境的组成。(2)了解LNMP环境的部署与安装。(2)了解WordPress应用的部署与使用。2、案例分析2.1、规划节点        Linux操作系统的单节点规划,见表3-1-1。IP主机名节点192.168.20.20lnmplnmp服务节点表3-1-1节点规划 2.2、基础准备   ......
  • LNMP一键安装
    PHP环境快捷搭建工具: https://lnmp.org/ [安装]wgethttps://soft.lnmp.com/lnmp/lnmp2.1.tar.gz-Olnmp2.1.tar.gz&&tarzxflnmp2.1.tar.gz&&cdlnmp2.1&&./install.shlnmp自动进行安装,根据计算机的性能与带宽情况,预计再半个小时左右即可全部完成nginx+php+m......
  • 随机组句小游戏-V1.13版本
    玩法:随机抽取地点人物事件,来组句2024/10/03进行微调.\(代码/Code:\)#include<bits/stdc++.h>#include<windows.h>#defineSM_printf("%c%c%c%c%c%c",-64,-18,-278,-59,-319,-40);usingnamespacestd;ints1,s2,s3,xz1,bool01;stringcopy_;stringplace[105]......
  • 阿里云服务器手动部署LNMP环境(Alibaba Cloud Linux 3/2、CentOS 7/8)
    LNMP是目前主流的网站服务器架构之一,适合运行大型和高并发的网站应用,例如电子商务网站、社交网络、内容管理系统等。LNMP分别代表Linux、Nginx、MySQL和PHP。本文介绍如何在AlibabaCloudLinux3/2、CentOS7/8操作系统的ECS实例上搭建LNMP环境。部署环境的实例要求手动部署LNMP环......
  • 构建LNMP+WordPress
    一、案例实施1.安装LNMP环境1.1修改主机名[root@localhost~]#hostnamectlset-hostnamelnmp[root@localhost~]#bash[root@lnmp~]#hostnamectl1.2使用脚本安装lnmp将提供的lnmp1.6-full.tar.gz软件包,上传到虚拟机的/root目录下,并解压[root@lnmp~]#ls[root......
  • mysql5.5源码主从复制搭建(以两台机器的单实例为例)
    mysql5.5源码主从复制搭建(以两台机器的单实例为例)如果对运维课程感兴趣,可以在b站上、csdn或微信视频号上搜索我的账号:运维实战课程,可以关注我,学习更多免费的运维实战技术视频项目1  配置mysql服务器的主从结构(开始时主从数据不一致时需要找到临界点的主从同步,主库初始......
  • Windows下批处理文件导入sql文件到MySQL5.5.50
    用来试验的MySQL的版本为5.5.50run.bat::DOS的UTF-8字符集chcp65001@ECHOOFF::到MySQL下新建文件夹set/pvar="请输入MySQL安装路径(如“C:\ProgramFiles(x86)\MySQL\MySQLServer5.5”):"set/pdirsql="请输入sql文件路径(如“C:\Users\Administrator\Desktop”):"c......
  • Centos7编译安装LNMP和搭建WordPress网站
    步骤1:安装依赖包 yum-yinstallgcc-c++&&yuminstall-ypcrepcre-devel&&yuminstall-yzlibzlib-devel&&yuminstall-yopensslopenssl-devel步骤2:编译安装nginx1.下载nginxwgethttp://nginx.org/download/nginx-1.26.2.tar.gz2.解压......
  • rpm安装lnmp,搭建知乎
    实验目标:安装lnmp,搭建知乎wecenter实验步骤安装nginx安装php安装mysql,并设置用户密码搭建wordpress复制wordpress安装包,到虚拟机/,解压并赋权unzipwordpress-4.9.4-zh_CN.zipchmod-R777/wordpressvim/etc/nginx/conf.d/blog.confsystemctlrestartnginxecho192.168.8.5blog.......