lnmp配置

一、nginx安装配置

nginx源码安装后配置_spring℡的博客-CSDN博客

二、php安装

1、下载php包

官网下载 PHP: Downloads

​[root@host1 ~]# wget -c https://www.php.net/distributions/php-7.4.27.tar.xz

将php解压到指定位置

[root@host1 ~]# tar xf php-7.4.27.tar.xz -C /usr/local/src/

2、安装所缺包以及依赖包

2.1、 安装依赖包

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2.2、启用常用功能

./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--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

#安装扩展源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2.3、安装所缺包

yum install sqlite-devel -y
yum install oniguruma-devel -y
yum install libxslt-devel -y

接下来

make

make install

三、安装数据库

1、安装数据库

[root@host1 php-7.4.27]# yum install mariadb-server -y

2、启动数据库

[root@host1 php-7.4.27]# systemctl start mariadb

[root@host1 php-7.4.27]# mysql_secure_installation

进入之后设置密码

数据库登录

[root@host1 php-7.4.27]# mysql -uroot -p123456

四、配置页面

1、编写mysql.php页面

[root@host1 php-7.4.27]# vim /usr/local/nginx/html/mysql.php

<?php
$con = mysqli_connect("127.0.0.1","root","123456");

if (!$con) {
        die("could not connect to the db:\n" . mysql_error());
}
else { echo "success"; }
mysqli_close($con);
?>

2、编写phpinfo.php页面

[root@host1 php-7.4.27]# vim /usr/local/nginx/html/phpinfo.php

<?php phpinfo(); ?>
[root@host1 php-7.4.27]# cp php.ini-development /usr/local/php/lib/php.ini
[root@host1 php-7.4.27]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@host1 php-7.4.27]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@host1 php-7.4.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

配置php-fpm

vim /etc/init.d/php-fpm

添加如下:  第九行——chkconfig 

添加进程php-fpm

[root@host1 php-7.4.27]# chkconfig --add php-fpm

[root@host1 php-7.4.27]# chkconfig php-fpm on

vim /usr/local/php/lib/php.ini

 vim /usr/local/nginx/conf/nginx.conf

            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

重启nginx 和 php-fpm

[root@host1 php-7.4.27]# systemctl restart nginx

[root@host1 php-7.4.27]# systemctl restart php-fpm

安装php-myql

yum install php-mysql -y

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值