contos7.4 安装lump环境php7.2+mysql7.2+nginx(最全面,无误的)
centos最新版本安装最新的php , nginx , mysql
背景介绍:
我在百度上看到大量的所谓lnmp安装,百分之八十一个抄一个,还给抄错了,剩下的百分之二十还有场景局限, 我现在用纯净的系统开始用压缩包安装(因为我可以很方便的找到我的压缩包,以及安装的文件)配置,我会尽量让这个过程详细一点;后面我会陆续记录gitserver安装,ftp安装配置等等,(有可能今天一起发出来)
准备工作:(php,nginx,mysql需要的一些依赖,可能需要一阵子,耐心等待就好)
#这里的大家都可以执行一下,已经安装的会跳过的,不要跳着安装,大家最好把yum 换成最新的(如果国内网易的,或者阿里的)
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 perl* httpd-devel postgresql-devel
#安装所需其它依赖
1.下载pcre(支持nginx 伪静态)
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz
tar -xzvf pcre-8.41.tar.gz
cd pcre-8.41
./configure --prefix=/usr/local/pcre #配置
make && make install #编译安装
2.安装cmake (用于编译c++)
wget https://cmake.org/files/v3.10/cmake-3.10.1.tar.gz
tar -xzvf cmake-3.10.1.tar.gz
cd cmake-3.10.1
./bootstrap
make && make install
开始安装环境 : (/usr/local/src):
1.下载最新的php :
wget http://cn2.php.net/distributions/php-7.2.0.tar.gz
2.下载最新的nginx:
wget http://nginx.org/download/nginx-1.13.7.tar.gz
3.下载最新的mysql :
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
4.解压缩
for tar in *.tar.gz; do tar xvf $tar; done #这里是批量解压缩========安装配置nginx:
进入nginx
cd nginx-1.13.7
./configure --prefix=/usr/local/nginx #编译配置设置
make && make install #老规矩 安装
echo 'PATH=/echo 'PATH=/usr/local/php/bin/:$PATH' >>
/etc/profile #配置环境变量
source /etc/profile #立即生效
cd /usr/local/nginx/conf #来到nginx 配置目录下
egrep -v "#|^$" nginx.conf.default >nginx.conf #精简配置,方面进去修改
vi /lib/systemd/system/nginx.service #创建nginx 启动文件
内容如下:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx
-s reload
ExecStop=/usr/local/nginx/sbin/nginx
-s quit
PrivateTmp=
true
[Install]
WantedBy=multi-user.target
systemctl start nginx.service #启动nginx
systemctl enable nginx.service #设置开机启动
==========安装php :
配置: ./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-inline-optimization --enable-gd-jis-conv --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem
--enable-xml --enable-zip --enable-pcntl --with-curl --with-fpm-user=nginx --enable-ftp --enable-session --enable-xml --with-apxs2=/usr/bin/apxs --with-pdo-pgsql --with-pdo-pgsql --with-pdo-pgsql --with-libxml-dir=/usr --enable-calendar --with-pgsql -disable-rpath
--enable-inline-optimization --with-bz2 --enable-sysvshm --enable-exif --with-mhash
然后 make && make install #编译安装
echo 'PATH=/usr/local/nginx/sbin/:$PATH' >> /etc/profile #写入环境变量
source /etc/profile #让配置生效
cp php-fpm /etc/init.d/php-fpm #设置启动脚本
报错: [21-Dec-2017 16:08:42] ERROR: [pool www] please specify user and group other than root
解决 : adduser nginx # 添加用户
groupadd nginx #添加用户组
useradd -g nginx nginx #新建用户同时增加工作组
vim vim /usr/local/php/etc/php-fpm.d/www.conf #修改
user = nginx
group = nginx 然后保存
再启就启动成功
========安装mysql
进入mysql:
groupadd -r mysql #添加mysql组
useradd -g mysql -r -s /sbin/nologin mysql #添加mysql 用户
mv mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql #移动./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
Note:是我们的临时密码;
cp support-files/mysql.server /etc/init.d/mysqld #加入系统进程
echo 'PATH=/usr/local/mysql/bin/:$PATH' >> /etc/profile #写入环境变量
source /etc/profile #让配置生效
chkconfig mysqld on #开机启动
mysql -u root -p #进入数据库
update
mysql.
user
set
authentication_string=
password
(
'123qwe'
)
where
user
=
'root'
and
Host
=
'localhost'
; #修改密码
flush
privileges
;
#立刻生效
quit; 退出