LNMP、LAMP

LNMP
Linux+Nginx+Mysql+PHP
Nginx (编译安装)
rpmbuild -bb nginx.spec
PHP (编译安装)
rpmbuild -bb php.spec
注意:Nginx 和 PHP 结合要使用 fastcgi
修改 /usr/local/php/etc/php-fpm.d/www.conf
修改 /usr/local/nginx/conf/nginx.conf
Mysql
yum 安装 mysql-5.7.17

[root@nginx ~]# rpm -ivh nginx-1.10-3.src.rpm
#如过rpm发布源码就是以src格式发布的
安装完之后,会在root下生成一个rpmbuild
[root@nginx ~]# cd /root/rpmbuild
[root@nginx rpmbuild]# ls
SOURCES SPECS
[root@nginx rpmbuild]# cd SOURCES/
[root@nginx SOURCES]# ls
conf.patch myconf.patch nginx-1.10.3.tar.gz nginx.service
#配置文件,nginx的源码包,服务文件
[root@nginx rpmbuild]# cd SPECS/
[root@nginx SPECS]# ls
nginx.spec #应答文件
[root@nginx SPECS]# vim nginx.spec

#

Name: nginx
Version: 1.10 #版本号
Release: 3 #稳定本版号
Summary: NGINX is the fastest growing and highest performing software for modern web architectures. #说明

Group: mysoft
License: GPLv2
URL: http://nginx.org/
Source0: nginx-%{version}.%{release}.tar.gz
Source1: myconf.patch
Source2: nginx.service
Source3: conf.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

%define debug_package %{nil}
BuildRequires: glibc gcc perl pkgconfig zlib-devel lua-devel pcre-devel openssl-devel nss-devel
#编译所需要的依赖包
Requires: nss-tools nss-util bash lua pcre openssl
#安装所需要的依赖包
Packager: luck #作者#
%description
Nginx WWW services . #描述#

%prep
%setup -q -c -n nginx-1.10.3 #解包#

%build
cd nginx-%{version}.%{release}
./configure –prefix=/usr/local/nginx \
–with-http_ssl_module –with-http_v2_module \
–with-http_realip_module –with-http_stub_status_module –with-pcre \
–without-mail_pop3_module –without-mail_imap_module –without-mail_smtp_module
make
#配置,编译#
%install
cd nginx-%{version}.%{release}
make DESTDIR=${RPM_BUILD_ROOT} install #安装#
cd %{buildroot}/usr/local/nginx
cp %{SOURCE1} %{buildroot}/usr/local/nginx/conf/
patch -p1 -i %{SOURCE3}
mkdir -p %{buildroot}/{usr/lib/systemd/system,var/log/weblog}
cp %{SOURCE2} %{buildroot}/usr/lib/systemd/system/

%clean
rm -rf %{buildroot} %{_builddir}

%files
%defattr(-,root,root,-)
/usr/local/nginx #主程序文件#
/usr/lib/systemd/system/nginx.service #服务启动文件#
%defattr(-,web,web,0775)
/var/log/weblog #日志文件#
#需要打包的文件#
%pre #表示安装这个软件包之前,执行的命令#
if ! $(id web &>/dev/null);then
groupadd -g 1000 web
useradd -u 1000 -g 1000 web -s /sbin/nologin
fi

%post #安装之后执行的命令#

%preun #卸载之前执行的命令#
systemctl stop nginx

%postun #卸载之后执行的命令#
rm -rf /var/cache/nginx

%changelog

#

[root@nginx SPECS]# rpmbuild -bs nginx.spec
写道:/root/rpmbuild/SRPMS/nginx-1.10-3.src.rpm
#报错,需要安装依赖#
[root@nginx SPECS]# yum -y install glibc gcc perl pkgconfig zlib-devel lua-devel pcre-devel openssl-devel nss-devel
[root@nginx SPECS]# rpmbuild -b#build#b#编译二进制可安装文件# nginx.spec
[root@nginx SPECS]# tree ..
..
├── BUILDROOT
├── RPMS
│ └── x86_64
│ └── nginx-1.10-3.x86_64.rpm
├── SOURCES
│ ├── conf.patch
│ ├── myconf.patch
│ ├── nginx-1.10.3.tar.gz
│ └── nginx.service
├── SPECS
│ └── nginx.spec
└── SRPMS

6 directories, 6 files

root@nginx SPECS]# cd ../RPMS/x86_64/
[root@nginx x86_64]# ls
nginx-1.10-3.x86_64.rpm
[root@nginx x86_64]# yum install ./nginx-1.10-3.x86_64.rpm -y
[root@nginx x86_64]# systemctl start nginx
[root@nginx x86_64]# ss -ltunp
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 127.0.0.1:323 : users:((“chronyd”,pid=444,fd=1))
tcp LISTEN 0 128 :80 :* users:((“nginx”,pid=3560,fd=6),(“nginx”,pid=3559,fd=6),(“nginx”,pid=3558,fd=6))
tcp LISTEN 0 128 :22 :* users:((“sshd”,pid=641,fd=3))
nginx安装完毕。用浏览器访问测试

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@nginx ~]# ls
anaconda-ks.cfg original-ks.cfg rpmbuild
[root@nginx ~]# rm -rf rpmbuild/
[root@nginx 01]# rpm -ivh php-7.2-2.src.rpm
正在升级/安装…
1:php-7.2-2 ################################# [100%]
[root@nginx ~]# ls
anaconda-ks.cfg original-ks.cfg rpmbuild
[root@nginx rpmbuild]# tree .
.
├── SOURCES
│ ├── php-7.2.2.tar.bz2
│ ├── php-fpm.conf
│ └── www.conf
└── SPECS
└── php.spec

2 directories, 4 files
[root@nginx rpmbuild]# cd SPECS/
[root@nginx SPECS]# ls
php.spec#应答文件#
[root@nginx SPECS]# yum -y install glibc gcc perl pkgconfig curl-devel gd-devel libXpm-devel zlib-devel readline-devel libxml2-devel
[root@nginx SPECS]# rpmbuild -bb php.spec
[root@nginx rpmbuild]# ls
BUILDROOT RPMS SOURCES SPECS SRPMS
[root@nginx rpmbuild]# cd RPMS/
[root@nginx RPMS]# ls
x86_64
[root@nginx RPMS]# cd x86_64/
[root@nginx x86_64]# ls
php-7.2-2.x86_64.rpm
[root@nginx x86_64]# yum install ./php-7.2-2.x86_64.rpm -y
[root@nginx ~]# cd /usr/local/nginx/html/
[root@nginx html]# vim info.php

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值