搭建lnmp
L:linux系统
N:nginx
M:mysql
P:php
一、安装nginx
使用Nginx官方提供的rpm包
[root@lnmp ~]# vim /etc/yum.repos.d/nginx.repo
添加:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
执行yum安装及启动并开机自启
[root@lnmp ~]# yum -y install nginx
[root@lnmp ~]# systemctl start nginx
[root@lnmp ~]# systemctl enable nginx
[root@lnmp ~]# nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
二、 安装php
使用第三方扩展epel源安装PHP7.2:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装 php72 版本
yum -y install php72w php72w-cli php72w-common php72w-devel \
php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm \
php72w-mysqlnd php72w-opcache
这里我用提前准备好的包
[root@lnmp php-7.2]# ls
autoconf-2.69-11.el7.noarch.rpm
automake-1.13.4-3.el7.noarch.rpm
libargon2-20161029-3.el7.x86_64.rpm
m4-1.4.16-10.el7.x86_64.rpm
mod_php72w-7.2.27-1.w7.x86_64.rpm
pcre-devel-8.32-17.el7.x86_64.rpm
perl-Data-Dumper-2.145-3.el7.x86_64.rpm
perl-Test-Harness-3.28-3.el7.noarch.rpm
perl-Thread-Queue-3.02-2.el7.noarch.rpm
php72w-cli-7.2.27-1.w7.x86_64.rpm
php72w-common-7.2.27-1.w7.x86_64.rpm
php72w-devel-7.2.27-1.w7.x86_64.rpm
php72w-embedded-7.2.27-1.w7.x86_64.rpm
php72w-fpm-7.2.27-1.w7.x86_64.rpm
php72w-gd-7.2.27-1.w7.x86_64.rpm
php72w-mbstring-7.2.27-1.w7.x86_64.rpm
php72w-mysqlnd-7.2.27-1.w7.x86_64.rpm
php72w-opcache-7.2.27-1.w7.x86_64.rpm
php72w-pdo-7.2.27-1.w7.x86_64.rpm
php72w-xml-7.2.27-1.w7.x86_64.rpm
安装,启动并开机自启
[root@lnmp php-7.2]# yum -y install localinstall *.rpm
[root@lnmp ~]# systemctl start php-fpm
[root@lnmp ~]# systemctl enable php-fpm
三、安装mysql
安装mysql(mariadb):
rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server -y
同样我这里使用提前准备好的包
[root@lnmp mysql5.6]# ls
mysql-community-client-5.6.47-2.el7.x86_64.rpm
mysql-community-common-5.6.47-2.el7.x86_64.rpm
mysql-community-libs-5.6.47-2.el7.x86_64.rpm
mysql-community-server-5.6.47-2.el7.x86_64.rpm
perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm
perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm
perl-Data-Dumper-2.145-3.el7.x86_64.rpm
perl-DBI-1.627-4.el7.x86_64.rpm
perl-IO-Compress-2.061-2.el7.noarch.rpm
perl-Net-Daemon-0.48-5.el7.noarch.rpm
perl-PlRPC-0.2020-14.el7.noarch.rpm
安装,启动并开机自启
[root@lnmp mysql5.6]# yum -y install localinstall *.rpm
[root@lnmp ~]# systemctl start mysqld
[root@lnmp ~