lnmp部署以及相关应用

lnmp实现多个虚拟主机,部署wordpress和phpmyadmin,并为后一个主机提供https;

(1)yum安装部署

安装nginx

[[email protected] yum.repos.d]# vim nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

[[email protected] ~]# yum install -y nginx

安装php

[[email protected] ~]# yum install php-fpm -y

[[email protected] ~]# vim /etc/php-fpm.d/www.conf

listen = 127.0.0.1:9000

user = nginx

group = nginx

配置nginx对接php,把nginx 通过fastcgi作为fastcgi的客户端,将php网页反向代理给fastcgi服务端

[[email protected] ~]# vim /etc/nginx/nginx.conf

worker_processes  3;

gzip  on;

include /etc/nginx/conf.d/*.conf;

[[email protected] ~]# vim /etc/nginx/conf.d/default.conf

index  index.php
index.html index.htm;

root   /data/www

location ~ \.php$ {

root           /data/www;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param 
SCRIPT_FILENAME 
/data/www/$fastcgi_script_name;

include        fastcgi_params;

}

[[email protected] ~]# mkdir -p /data/www

[[email protected] ~]# nginx -t

[[email protected] ~]# nginx

[[email protected] ~]# systemctl start php-fpm.service

测试nginx和php的连接

[[email protected] ~]# vim /data/www/index.php

<?php

phpinfo();

?>

安装mariadb和php与maridb之间的驱动

[[email protected] html]# yum
install mariadb-server php-mysql -y

[[email protected] html]# systemctl start mariadb

MariaDB [(none)]> grant all on *.* to [email protected]‘localhost‘
identified by ‘123.comer‘;

MariaDB [(none)]> create database wordpress;

MariaDB [(none)]> grant all on wordpress.* to
‘wpuser‘@‘localhost‘ identified by ‘wppasswd‘;

MariaDB [(none)]> flush privileges;

[[email protected] ~]# vim /data/www/index.php

<?php

$conn=mysql_connect(‘localhost‘,‘zou‘,‘123.comer‘);

if($conn)

echo "web is ok";

else

echo fault;

mysql_close();

phpinfo();

?>

[[email protected] html]# systemctl reload php-fpm

[[email protected] html]# yum install httpd-tools -y

[[email protected] html]# ab -c
100 -n 1000 http://172.16.1.1/index.php        (在没有缓存的情况下是1450)

准备搭建wordpress了

把wordpress下载下来,并解压缩到/data/www目录下面

[[email protected] wordpress]# pwd

/data/www/wordpress

[[email protected] wordpress]# cp wp-config-sample.php wp-config.php

[[email protected] wordpress]# vim wp-config.php

define(‘DB_NAME‘, ‘wordpress‘);

define(‘DB_USER‘, ‘wpuser‘);

define(‘DB_PASSWORD‘, ‘wppasswd‘);

define(‘DB_HOST‘, ‘localhost‘);

在浏览器键入:http://172.16.1.1/wordpress/

之后输入已经设定好的网页版的管理者zou和密码

准备设置phpmyadmin

[[email protected] phpmyadmin]# pwd

/data/www/phpmyadmin

[[email protected] phpmyadmin]# vim libraries/config.default.php

$cfg[‘Servers‘][$i][‘host‘] = ‘localhost‘;

$cfg[‘Servers‘][$i][‘user‘] = ‘zou‘;

$cfg[‘Servers‘][$i][‘password‘] = ‘123.comer‘;

[[email protected] phpmyadmin]# yum install php-mbstring

[[email protected] html]# systemctl reload php-fpm

[[email protected] phpmyadmin]# nginx -s reload

在浏览器输入http://172.16.1.1/phpmyadmin

有错,php.ini的session问题

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

session.use_cookies = 1

session.save_path = "/tmp"

在phpmyadmin中找到,config.sample.inc.php,改成config.inc.php,找到
$cfg[‘blowfish_secret‘] 将后面的赋值,加入数字和字母组合(最好位数在16位左右)

[[email protected] php]# mkdir /var/lib/php/session

[[email protected] php]# chmod 777 /var/lib/php/session/

[[email protected] php]# nginx -s reload

[[email protected] php]# systemctl reload php-fpm

(2)编译安装LNMP

# yum groupinstall "Development Tools"
"Server Platform Development" -y

gzip模块需要zlib库,rewrite模块需要pcre库,ssl功能需要openssl,所以要安装

# yum install pcre-devel
zlib-devel openssl-devel  -y

# useradd -r nginx

[[email protected] src]# tar zxvf nginx-1.10.1.tar.gz

[[email protected] src]# cd nginx-1.10.1/

# ./configure --prefix=/usr/local/nginx
--sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock --user=nginx --group=nginx
--with-http_ssl_module --with-http_v2_module --with-http_dav_module  --with-http_stub_status_module --with-threads
--with-file-aio

# make -j 4

#  make install


nginx -t   检查语法

# nginx -s {stop|start|reopen|reload}  进程的管理

mariadb客户端编译安装服务

(这里实际上并算不上是编译安装,mariadb压缩包解压完之后就可以安装,二进制格式安装)

[[email protected] src]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz

[[email protected] src]# mv
mariadb-5.5.46-linux-x86_64 /usr/local/mysql

[[email protected]
local]# useradd -r mysql

[[email protected] local]# cd /usr/local/mysql/

[[email protected] mysql]# chown -R root:mysql ./*

[[email protected]mysql]# ll

[[email protected] mysql]# mkdir -p /data/mariadb

[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mariadb

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

[[email protected] mysql]# support-files/my-large.cnf  /etc/my.cnf

[[email protected] ~]#  vim /etc/my.cnf

添加三个选项:

datadir = /data/mariadb

innodb_file_per_table = ON

skip_name_resolve = ON

[[email protected] ~]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

[[email protected] ~]# ss -ntlp    查看3306端口

[[email protected] ~]#
/usr/local/mysql/bin/mysql  可以登录即可

MariaDB [(none)]> grant all on *.* to ‘zou‘@‘%‘ identified
by ‘123.comer‘;

MariaDB [(none)]> flush privileges;

编译安装php

[[email protected] src]# yum install mariadb mariadb-devel

[[email protected] src]# yum install libxml2-devel gd-devel
freetype-devel libmcrypt-devel

[[email protected] php-5.4.40]# mkdir /usr/lib/mysql

[[email protected] php-5.4.40]#
cp -r /usr/lib64/mysql/*
/usr/lib/mysql/

[[email protected] php54]# ./configure --prefix=/usr/local/php54
--with-mysql=/usr --with-openssl --with-mysqli=/usr/bin/mysql_config
--enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd
--with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt
--enable-fpm 
--with-config-file-path=/etc/php54/php.ini
--with-config-file-scan-dir=/etc/php54/php.d

[[email protected] php-5.4.40]# make -j 2

[[email protected] php-5.4.40]# make install

[[email protected] php54]# cd /usr/local/php54

[[email protected] php54]# cp etc/php-fpm.conf.default etc/php-fpm.conf

[[email protected] php54]# vim etc/php-fpm.conf

listen = 127.0.0.1:9000    (如果对外响应也可以写上主机的ip加上9000端口)

user = nginx

group = nginx

[[email protected] php54]# sbin/php-fpm   启动服务 (如果关闭就用pkill php-fpm)

[[email protected] php54]# ss -ntlp     查看监听的服务

[[email protected] php54]# vim /etc/nginx/nginx.conf

location / {

root   /data/www;

index  index.php index.html index.htm;

}

location ~ \.php$ {

root           /data/www;

fastcgi_pass   127.0.0.1:9000;  如果php服务端不在本地,那就要写php的ip和端口了

fastcgi_index  index.php;

fastcgi_param 
SCRIPT_FILENAME 
/data/www/$fastcgi_script_name;

include        fastcgi_params;

}

[[email protected] php54]# mkdir -p /data/www

[[email protected] php54]# vim /data/www/index.php

[[email protected] php54]# iptables -F

[[email protected] php54]# setenforce 0

[[email protected] php54]# nginx -s reload

时间: 2024-08-07 21:20:44

lnmp部署以及相关应用的相关文章

编译LNMP部署动态网站环境

title: 编译LNMP部署动态网站环境 date: 2018-11-08 13:59:59 tags: Linux 服务配置 categories: Linux 服务配置 copyright: true --- LNMP动态网站部署架构是由一套 Linux+Nginx+MySQL+PHP 组成的动态网站系统解决方案. 以下配置环境为:Linux=RHEL7 --> Nginx=1.13 --> MySQL=5.6 --> PHP=7.0 无错误版. 安装编译环境 在使用源码包安装服务

lnmp部署 -----1

基本环境 系统 : centos 6.4 nginx-1.2.0 mysql-5.5.13 php-5.4.9 [[email protected] ~]# service httpd stop     //确认httpd服务已关闭 [[email protected] ~]# service mysqld stop    //确认系统中的mysql数据库没有启动 [[email protected] ~]# yum -y groupinstall "Development    //安装开发环

lnmp部署cacti+nagios

关于lnmp架构整合cacti+nagios中,nginx的配置文件是最难搞的,个人感觉 nginx.conf的配置文件 ##里面用重写 server { listen 80; server_name laimai365.org www.laimai365.org; location / { # root /opt/nagios/; root html; index index.php index.html index.htm ; } error_page 500 502 503 504 /50

LNMP部署及应用理论及实操

LNMP部署及应用 LNMP架构解读 LNMP平台就是Linux.Ngnix. MySQL. PHP的组合架构,需要Linux服务器.MySQL 数据库.PHP解析环境 MySQL安装配置 为了与Nginx.PHP环境保持一致,此处选择采用源代码编译的方式安装MySQL组件MySQL部署的方法编译安装MySQL优化调整初始化数据库启动mysql服务并设置root数据库账号的密码 配置网页动静分离,解析PHP,有两种方法可以选择使用PHP的FPM模块将访问PHP页面的Web请求转交给Apache服

部署LNMP平台和相关的实验

该实验分为四个部分,实验一为搭建LNMP平台,实验二为测试能否解析php的文件 和连接数据库的效果,实验三为实现地址重写的功能,实验四为不同的浏览器,给出不同样式的页面 实验一:部署LNMP环境 一.目标 安装部署Nginx.MariaDB.PHP环境 安装部署Nginx.MariaDB.PHP.PHP-FPM: 启动Nginx.MariaDB.FPM服务: 并测试LNMP是否工作正常. 二.各软件的安装 1.安装源码包安装时需要的依赖包 yum -y install gcc openssl-d

linux(centos) 项目部署阶段相关命令汇总

1.ssh免密码登陆 主要命令 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys-->添加公钥 service sshd restart -->重启ssh服务 参考链接: http://jingyan.baidu.com/article/2fb0ba4043124a00f2ec5f0f.html 2.查看系统相关信息: uname -a 查看OS详细信息 file /bin/ls 显示系统程序信息,就能看出多少位 获得机器字长 getc

LNMP 部署(Linux+Nginx+Mysql+Php)

1. 安装所需各种依赖包 yum –y install gcc gcc-c++autoconf automakebison flex freetype freetype-devel fontconfig-develgettext-devel libjpeglibjpeg-devel libpng libpng-devel libxml2 libxml2-devellibtool libtool-ltdllibtool-ltdl-devel libtiff-devel libXpm-devel l

IIS部署站点相关经验总结

1.IIS和.net4.0安装是有先后顺序的,应该先安装.net framework 4.0,再安装IIS.如果按相反顺序安装的话,IIS中看不到4.0相关的东西,那么只能执行命令启用: C:\Windows\system32> C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regii.exe -ir -enable 2. IIS的应用程序池标识有“ApplicatonPoolIdentity”,”LocalSystem”,”Local

LNMP部署、Nginx+FastCGI、Nginx高级技术

1 案例1:部署LNMP环境1.1 问题安装部署Nginx.MariaDB.PHP环境?安装部署Nginx.MariaDB.PHP.PHP-FPM:?启动Nginx.MariaDB.FPM服务:?并测试LNMP是否工作正常.1.2 方案在RHEL7系统中,源码安装Nginx,使用RPM包安装MariaDB.PHP.PHP-FPM软件.操作过程中需要安装的软件列表如下:?nginx [源码](web服务器,接收用户请求)?mariadb(客户端软件mysql).mariadb-server(服务)