源码搭建lnmp环境

lnmp

mkdir /data/{soft,server} -p

nginx

useradd www -s /sbin/nologin -M
wget http://nginx.org/download/nginx-1.6.3.tar.gz
tar xzf nginx
./configure --prefix=/data/server/nginx
[./configure: error: C compiler cc is not found]
yum -y install gcc
[he HTTP rewrite module requires the PCRE library.]
 yum -y install pcre-devel
[./configure: error: the HTTP gzip module requires the zlib library.]
yum install -y zlib-devel

make && make install

 vim /data/server/nginx/conf/nginx.conf
 修改第一行
 user nobody
 为
 user www;
启动
./sbin/nginx
关闭
./sbin/nginx -s stop
重启
./sbin/nginx -s reload

mysql

useradd -s /sbin/nologin -M mysql
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.26-el7-x86_64.tar.gz

tar xzf mysql-8.0.26-el7-x86_64.tar.gz -C /data/server
cd /data/server
mv mysql-8.0....  mysql 改名
cd mysql
#bin/mysqld --initialize --user=mysql --basedir= 安装目录  --datadir= 数据存放目录
bin/mysqld --initialize --user=mysql --basedir=/data/server/mysql  --datadir=/data/server/mysql/data
#这里会有密码,记住
#密码
root@localhost: brQaLw.Qu6bV

vim /etc/my.cnf
[mysqld]
basedir = /data/server/mysql
datadir=/data/server/mysql/data
#socket=/data/server/mysql/mysql.sock
character-set-server=utf8
port=3306
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
#
[client]
# # 设置mysql客户端连接服务端时默认使用的端口和默认字符集
port=3306
default-character-set=utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

chown -R mysql.mysql /data/server/mysql/

#启动
cd /support-files/mysql.server
./mysql.server start
#进入mysql 
cd /mysql/bin/
./mysql -uroot -p
show databases
#修改密码
 alter user user() identified by "123456";
 #退出 
 quit;

PHP

wget https://www.php.net/distributions/php-7.4.22.tar.gz
tar xzf php-7.4.22.tar.gz
cd php-7.4.22
./configure --prefix=/data/server/php74  --enable-fpm --with-mysqli --with-curl --with-pdo_mysql --with-pdo_sqlite --enable-mysqlnd --enable-mbstring 
    //从源代码编译
//编译 PHP 时需要 --enable-fpm 配置选项来激活 FPM 支持。
   // https://www.php.net/manual/zh/install.fpm.install.php
https://blog.csdn.net/have_a_cat/article/details/115208121  yum install libxml2-devel
https://www.inbeijing.org/archives/2079    yum -y install sqlite-devel
https://blog.csdn.net/weixin_43930641/article/details/106198442  libcurl  yum install -y libcurl-devel.x86_64
https://blog.csdn.net/qq_17631419/article/details/106803807  oniguruma  yum -y install oniguruma-devel
https://blog.csdn.net/shuiyuetianwy/article/details/86070213  提示没有软件包  yum install -y epel-release
make 
make install
cp /data/soft/php-7.4.22/php.ini-development /data/server/php74/lib/php.ini
    cp /data/server/php74/etc/php-fpm.conf.default /data/server/php74/etc/php-fpm.conf
    cp /data/server/php74/etc/php-fpm.d/www.conf.default  /data/server/php74/etc/php-fpm.d/www.conf
修改php.ini  cgi.fix_pathinfo=0   https://www.laruence.com/2010/05/20/1495.html
如果报错:
    failed to open configuration file '/data/server/php7/etc/php-fpm.conf': No such file or directory (2)
[22-Aug-2021 16:19:29] ERROR: failed to load configuration file '/data/server/php7/etc/php-fpm.conf'
[22-Aug-2021 16:19:29] ERROR: FPM initialization failed
cp php74 php7
./sbin/php-fpm 启动
        netstat -tnulp |grep php  查看  
        [bash: netstat: command not found
]        yum -y install net-tools
        关闭   pkill php-fpm
        
        vim nginx.conf
          server {
        listen       80;
        server_name  localhost;
        #静态请求location

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index index.php  index.html index.htm;
        }
        #动态请求处理的locatuion
        location ~* .*\.(php|php7)?$ {
                root html;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi.conf;
        }

#关闭防火墙
 一、防火墙的开启、关闭、禁用命令

(1)设置开机启用防火墙:systemctl enable firewalld.service

(2)设置开机禁用防火墙:systemctl disable firewalld.service

(3)启动防火墙:systemctl start firewalld

(4)关闭防火墙:systemctl stop firewalld

(5)检查防火墙状态:systemctl status firewalld 
     
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值