搭建LNMP架构 ---- PHP配置+安装论坛
程序员文章站
2022-05-17 18:05:23
...
搭建LNMP架构 ---- PHP配置
一:PHP 概述
PHP(超文本预处理器),是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言是常用的网站编程语言。有利于学习,使用广泛,主要适用于web开发领域。 具有成本低、速度快、可移植性好、 内置丰富的函数库等优点 。
二:PHP有三个配置文件
核心配置文件 ------ php.ini
进程服务配置文件 ------ php-fpm.conf
扩展配置文件 ------ www.conf
三:安装 PHP 过程
1、安装依赖包
[aaa@qq.com ~]# yum install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel durl curl-devel openssl openssl-devel -y
2、解压php压缩包
[aaa@qq.com abc]# tar jxvf php-7.1.10.tar.bz2 -C /opt/ ‘解压php压缩包’
[aaa@qq.com abc]# cd /opt/
[aaa@qq.com opt]# ls
ab.conf mysql-5.7.20 nginx-1.12.2 php-7.1.10 rh
3、configure 编译
[aaa@qq.com php-7.1.10]# ./configure \
--prefix=/usr/1ocal/php \
--with-mysq1-sock=/usr/local/mysq1/mysql.sock \
--with-mysqli \ '客户端支持库'
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
[aaa@qq.com php-7.1.10]# make && make install
4、修改配置文件
[aaa@qq.com php-7.1.10]# cp php.ini-development /usr/local/php/lib/php.ini ‘先复制一份到lib路径下’
[aaa@qq.com php-7.1.10]# vim /usr/local/php/lib/php.ini
1170 mysqli.default_socket = /usr/local/mysql/mysql.sock ‘指定路径’
939 date.timezone = Asia/shanghai ‘ 前面 ; 去掉 ’ ‘指定时区’
5、验证安装模块
[aaa@qq.com php-7.1.10]# /usr/local/php/bin/php -m ‘验证安装模块’
6、配置及优化FPM模块
[aaa@qq.com php-7.1.10]# cd /usr/local/php/
[aaa@qq.com php]# ls
bin etc include lib php sbin var
[aaa@qq.com php]# cd etc/
[aaa@qq.com etc]# ls
pear.conf php-fpm.conf.default php-fpm.d
[aaa@qq.com etc]# cp php-fpm.conf.default php-fpm.conf ‘复制一份到 php-fpm.conf’
[aaa@qq.com etc]# cd /usr/local/php/etc/php-fpm.d/
[aaa@qq.com php-fpm.d]# ls
www.conf.default
[aaa@qq.com php-fpm.d]# cp www.conf.default www.conf ‘复制扩展包’
[aaa@qq.com php-fpm.d]# cd /usr/local/php/etc/
[aaa@qq.com etc]# vim php-fpm.con ‘进入文件’
17 pid = run/php-fpm.pid ‘前面 ; 去掉’ ‘开启pid’
[aaa@qq.com etc]# /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini ‘开启PHP’
[aaa@qq.com etc]# netstat -ntap | grep 9000 ‘检测是否成功’
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 36269/php-fpm: mast
[aaa@qq.com etc]# ln -s /usr/local/php/bin/* /usr/local/bin/ ‘创建软链接,便于系统识别’
7、让nginx 支持PHP
[aaa@qq.com etc]# ps aux | grep -c "php-fpm" ‘查看fpm进程’
4
[aaa@qq.com etc]# ln -s /usr/local/nginx/conf/nginx.conf /etc/
[aaa@qq.com etc]# vim /etc/nginx.conf ‘进入文件,修改路径’
8、创建PHP首页
[aaa@qq.com etc]# cd /usr/local/nginx/html/
[aaa@qq.com html]# ls
50x.html index.html
[aaa@qq.com html]# mv index.html index.html.bak ‘把index.html 移动到index.html.bak’
[aaa@qq.com html]# ls
50x.html index.html.bak
[aaa@qq.com html]# vim index.php ‘创建PHP首页’
<?php
phpinfo();
?>
[aaa@qq.com html]# systemctl restart nginx ‘开启nginx’
9、到win10客户机验证,网页访问PHP 首页
这时 LNMP 架构搭建成功了。
四:测试数据库工作是否正常
[aaa@qq.com html]# mysql -uroot -p
Enter password: ‘输入密码,安装mysql时设置的密码’
mysql> CREATE DATABASE bbs; ‘在mysql创建bbs库’
Query OK, 1 row affected (0.01 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; ‘给用户授权’
Query OK, 0 rows affected, 1 warning (0.05 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123'; ‘给用户授权’
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges; ‘刷新Musql的系统权限相关表’
Query OK, 0 rows affected (0.01 sec)
[aaa@qq.com html]# vim index.php ‘把原来的测试页内容更改’
<?php
$link=mysqli_connect('192.168.34.149','bbsuser','admin123');
if($link) echo "<h1>Success!!</h1>"; ‘会在网页上显示’
else echo "Fail!!";
?>
[aaa@qq.com html]# systemctl restart nginx ‘开启nginx’
在win10客户机上验证,可以看到在配置文件编写的内容
五:安装论坛
可接着上面的步骤继续
1、解压Discuz 论坛文件
[aaa@qq.com html]# cd /abc
[aaa@qq.com abc]# unzip Discuz_X3.4_SC_UTF8.zip -d /opt/ ‘解压’
[aaa@qq.com abc]# cd /opt/ ‘查看/opt/目录下被解压的文件’
[aaa@qq.com opt]# ls
ab.conf dir_SC_UTF8 mysql-5.7.20 nginx-1.12.2 php-7.1.10 rh 说明.htm
2、授权
[aaa@qq.com opt]# cd dir_SC_UTF8/
[aaa@qq.com dir_SC_UTF8]# ls
readme upload utility
[aaa@qq.com dir_SC_UTF8]# cp -r upload/ /usr/local/nginx/html/bbs
[aaa@qq.com dir_SC_UTF8]# cd /usr/local/nginx/html/
[aaa@qq.com html]# ls
50x.html bbs index.html.bak index.php
‘授权’
[aaa@qq.com html]# cd /usr/local/nginx/html/bbs/
[aaa@qq.com bbs]# chown -R root:nginx ./config/
[aaa@qq.com bbs]# chown -R root:nginx ./data/
[aaa@qq.com bbs]# chown -R root:nginx ./uc_client/
[aaa@qq.com bbs]# chown -R root:nginx ./uc_server/
[aaa@qq.com bbs]# chmod -R 777 ./config/
[aaa@qq.com bbs]# chmod -R 777 ./data/
[aaa@qq.com bbs]# chmod -R 777 ./uc_client/
[aaa@qq.com bbs]# chmod -R 777 ./uc_server/
3、在win10客户机验证,在网页中安装论坛
点击下一步:
这边注意修改数据库用户名、密码等信息。
上一篇: Tengine安装手册
下一篇: nginx 服务器搭建
推荐阅读
-
CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤
-
CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
-
安装配置php-fpm来搭建Nginx+PHP的生产环境
-
PHP开发环境搭建一:PHP集成环境XAMPP的安装与配置
-
直播源码怎样搭建直播系统LNMP环境——PHP配置
-
PHP开发环境搭建一:PHP集成环境XAMPP 的安装与配置
-
Linux Debian 下LNMP服务器nginx+mysql+php环境搭建及配置_MySQL
-
Linux Debian 下LNMP服务器nginx+mysql+php环境搭建及配置_MySQL
-
CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)
-
CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤