LNMP动态网站环境部署

一.动态网架架构
资源
资源文件识别 语言识别 框架识别
index.php 开源的php Windows/Linux+nginx+php+mysql
index.py 开源python Windows/Linux+apache+python+mysql
index.jsp 商业JAVA windows/Linux+tomcat+JDK+Oracle
index.asp 商业c# Windows+iis+asp.net+sql-server/oracle/mogodb
二.LNMP动态网站环境部署
1.LINUX部署
关闭防火墙
systemctl stop firewalld
setenforce 0
2.Nginx部署
先官网配置nginx源略(我的前面博客有)
在yum -y install nginx
3.php-fpm部署
部署方法(2选1)
RPM部署

1.yum install -y php-fpm php-mysql php-gd
php-fpm:php接收动态请求的程序
php-mysql:php链接mysql的程序
php-gd:图形库程序(GD库可以处理图片,或者生成图片)
php-mysql 安装不上的话,可以进行以下操作
先下载 mysql-community-libs-compat-5.7.29-1.el7.x86_64
安装上这个再安装php-mysql
2.systemctl restart php-fpm
systemctl enable php-fpm     启动
3.netstat -anpt | grep 9000     查看端口
4.vim /usr/share/nginx/html/index.php
<?php
phpinfo();
?>     测试语句
5.vim /etc/nginx/conf.d/default.conf 增加PHP主页名称:index.php
server {
location / {
...
index index.php index.html;
...
}
}
6.vim /etc/nginx/conf.d/default.conf   启动nginx_fastcgi功能,解除#注释修改路径即可。
server {
location / {
index index.php;
}
location ~ \.php$ {
root /usr/share/nginx/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_param:这个配置的意思是 在浏览器中访问的.php文件,实际读取的是 $document_root(网站根目录)下的.php文件 -- 也就是说当访问127.0.0.1/index.php的时候,需要读取网站根目录下面的index.php文件,如果没有配置这一配置项时,nginx不回去网站根目录下访问.php文件,所以返回空白。
通过location指令,将所有以php为后缀的文件都交给127.0.0.1:9000来处理,而这里的IP地址和端口就是FastCGI进程监听的IP地址和端口。
fastcgi_param指令指定放置PHP动态程序的主目录,也就是$fastcgi_script_name前面指定的路径,这里是/usr/local/nginx/html目录,建议将这个目录与Nginx虚拟主机指定的根目录保持一致,当然也可以不一致。
fastcgi_params文件是FastCGI进程的一个参数配置文件,在安装Nginx后,会默认生成一个这样的文件,这里通过include指令将FastCGI参数配置文件包含了进来。
接下来,启动nginx服务。
/usr/local/nginx/sbin/nginx
到此为止,Nginx+PHP已经配置完成。
systemctl restart nginx    重启
http://192.168.152.157/index.php   测试结果

2.源码部署

部署PHP-fpm
1. 以php-fpm的方式安装php
[root@tianyun ~]# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \
libxml2 libxml2-devel libcurl libcurl-devel libxslt-devel openssl-devel

[root@webserver ~]# tar xf php-5.6.29.tar.xz 
[root@webserver ~]# cd php-5.6.29/
[root@webserver ~]# ./configure \
--prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-jpeg-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysql \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
[root@webserver php-5.6.29]# make
[root@webserver php-5.6.29]# make install

2. php-fpm配置文件(影响php处理php程序的性能,例如php进程数、最大连接数配置等,运维人员关注)
[root@webserver php-5.6.29]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

3. php置文件(影响php代码,例如允许客户端最大上传文件的大小,设置的timezone,php所支持的扩展功能例如是否可以连接MySQL、Memcache,程序员关注)
[root@webserver php-5.6.29]# cp php.ini-production /usr/local/php/lib/php.ini

4. init script centos6 [可选]centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 centos6 c
[root@webserver php-5.6.29]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@webserver php-5.6.29]# chmod a+x /etc/rc.d/init.d/php-fpm
[root@webserver php-5.6.29]# chkconfig --add php-fpm
[root@webserver php-5.6.29]# chkconfig php-fpm on
[root@webserver php-5.6.29]# service php-fpm start
Starting php-fpm  done

4. Systemd Script centos7 [可选]
[root@webserver ~]# vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

[root@webserver ~]# systemctl start php-fpm.service 
[root@webserver ~]# systemctl status php-fpm.service


[root@localhost ~]# ss -an |egrep ':80|:9000'
tcp    LISTEN     0      128    127.0.0.1:9000                  *:*                  
tcp    LISTEN     0      128                  *:80                  *:*  

4.mysql 部署

1.RPM部署
	yum -y install mariadb-server mariadb
		安装mysql服务器程序和客户机程序。
	systemctl start mariadb
		启动mysql服务器
	systemctl enable mariadb
		开机启动mysql服务器
	mysqladmin password '123456'
		修改mysql的root密码为‘123456’
	create database bbs;
		准备数据库,存放app
	 grant all on bbs.* to phptest@'192.168.100.10' identified by '123456';
		授权phptest用户管理bbs库
		请注意用户名密码主机参数需要更换。
	flush privileges;
		刷新权限
	vim /usr/share/nginx/html/index.php
		<?php
$link=mysql_connect('192.168.100.10','phptest','123456');
if ($link)
              echo "Successfuly";
else
              echo "Faile";
mysql_close();
?>
			修改主页,测试MYSQL的链接状态
		如果测试为faile,请检查数据库授权结果。

5.示例:业务上线
购买服务器/云主机
购买域名&IP
上传APP

wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.zip   官方下载也可以rz上传本地
unzip wordpress-4.9.4-zh_CN.zip   解压
rm -rf /usr/share/nginx/html/index.php    删除测试页
cp -rf  /root/wordpress/* /usr/share/nginx/html   把内容复制到网站主目录
chown -R nginx.nginx /usr/share/nginx/html/*    更改主人和属组
chmod 777 /usr/share/nginx/html/   授权
访问APP
数据库名称
数据库用户
数据密码
必须和前方授权一致。
如果出现wp-config.php文件不可写。  可以用root或者请手动创建
vim /usr/local/nginx/html/wp-config.php
   //配置连接数据库,非商业的应用需要手动配置连接数据库

在这里插入图片描述
在这里插入图片描述有可能上传的内容在云盘app,就需要在里面下载。
最后一步:产品交付,回复。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值