首先更新系统yum源:
yum -y update
安装nginx
yum -y localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.安装nginx
yum -y install nginx
3.启动nginx
systemctl start nginx
4.访问 http://你的ip/
如果成功安装会出来nginx默认的欢迎界面!
安装MySQL 8.0
1.下载mysql的repo源
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
2.安装 rpm 包
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
3.修改 MySQL 的repo源,使MySQL8.0可用【通常情况下,此步是多余的,可忽略】
vi /etc/yum.repos.d/mysql-community.repo
找到 [mysql80-community]
确保 enabled=1
修改,保存并退出。
4.安装msyql
yum -y install mysql-server
安装mysql的开发包,以后会有用【可忽略】
yum -y install mysql-community-devel
5.启动mysql
systemctl start mysqld
6.查看mysql启动状态
systemctl status mysqld
出现 Active: active (running) 表示MySQL运行正常!证明启动成功!
7.获取mysql默认生成的密码
grep 'temporary password' /var/log/mysqld.log
8.换成自己的密码
mysql -uroot -p
Enter password:输入上面的密码
成功输入后进入一下步,这里你估计会输入好几次才进去,因为密码输入是看不到内容的,啊哈哈~
9. 更换密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
这个密码一定要足够复杂,否则会提示密码不合法。
10.退出mysql
mysql> exit
11.用新密码再登录,试一下新密码
mysql -uroot -p
Enter password:输入你的新密码
12.确认密码正确后,退出mysql
编译安装php7.2.0 【参考:CentOS 7源码编译安装PHP7.2.0】
所以,下载压缩包,解压,安装php依赖包等等我就不多说了,咱直接到这编译配置一步,将可能会遇到的报错情况进行分析,至于编译完成之后的,请看参考文章。
编译配置,这一步我们会遇到很多configure error,我们一一解决,基本都是相关软件开发包没有安装导致
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm \ --with-fpm-user=nginx --with-fpm-group=nginx \ --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype \ --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath \ --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring \ --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets \ --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl
configure error:
1.configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
yum -y install libxml2 libxml2-devel
2.configure: error: Cannot find OpenSSL's <evp.h>
解决:
yum -y install openssl openssl-devel
3.configure: error: Please reinstall the BZip2 distribution
解决:
yum -y install bzip2 bzip2-devel
4.configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
解决:
yum -y install libcurl libcurl-devel
5.If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.
解决:
yum -y install libjpeg libjpeg-devel
6.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
解决:
yum -y install libpng libpng-devel
7.If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
解决:
yum -y install freetype freetype-devel
8.configure: error: Unable to locate gmp.h
解决:
yum -y install gmp gmp-devel
9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
yum -y install libmcrypt libmcrypt-devel
10.configure: error: Please reinstall readline - I cannot find readline.h
解决:
yum -y install readline readline-devel
11.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决:
yum -y install libxslt libxslt-devel
参考原文:阿里云 Centos 7 PHP7环境配置 LNMP
没有难的技术,当你弄清它的原理时,你会发现原来如此简单~ 欢迎加群【536501561】讨论