CentOS 7.3 下 安装LNMP(Nginx1.10+MySQL5.7+PHP7.0.20)(2)

nginx安装完成,等php安装好后,可以配置nginx文件

三、安装mysql5.7 // 在MySQL官网中下载YUM源rpm安装包 # wget // 安装mysql源 # yum localinstall mysql57-community-release-el7-8.noarch.rpm // 检查mysql源是否安装成功 # yum repolist enabled | grep "mysql.*-community.*" > mysql-connectors-community/x86_64 MySQL Connectors Community 3 > mysql-tools-community/x86_64 MySQL Tools Community 4 > mysql57-community/x86_64 MySQL 5.7 Community Server 18 // 安装mysql # yum install mysql-community-server # yum install mysql-community-devel // 启动mysql # service mysqld start // 查看mysql启动状态 # service mysqld status // 设置开机启动 # systemctl enable mysqld # systemctl daemon-reload // 获取mysql默认生成的密码 # grep 'temporary password' /var/log/mysqld.log > 2017-07-04T06:06:06.824762Z 1 [Note] A temporary password is generated for root@localhost: h8wob/ou+wpC // :(冒号)后的就是自动生成的密码 h8wob/ou+wpC ,换成自己的密码 # mysql -uroot -p > Enter password:h8wob/ou+wpC > mysql> // 更换密码 > mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123IsYourNewPassword!';

注意:这里的新密码必须包含数字、小写或大写字母、特殊字符串。这个密码的复杂程度,和validate_password_policy的值有关。

PolicyTests Performed
0 or LOW   Length  
1 or MEDIUM   Length; numeric, lowercase/uppercase, and special characters  
2 or STRONG   Length; numeric, lowercase/uppercase, and special characters; dictionary file  

默认是1,即MEDIUM。如果想要降低密码复杂度,可以进入mysql后设置。

> mysql> set global validate_password_policy=0; // 退出后再确认一次 > mysql> quit; # mysql -uroot -p123IsYourNewPassword! > mysql>

至此,mysql安装完毕

四、安装php7 // 官网下载7.0.20版本后,用ftp将源码包传到服务器中,保存在/root下 # tar -zxvf php-7.0.20.tar.gz # cd php-7.0.20 // 安装依赖包 # yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel // 编译配置。如果按照我的步骤一步步来,应该一步到位,直接看见 Thank you for using PHP。如果报错,基本就是相关依赖未安装完全。 # ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/etc \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mcrypt \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-freetype-dir \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache // 编译安装 # make && make install // 添加 PHP 命令到环境变量 # vim /etc/profile // 立即生效 # source /etc/profile // 查看PHP版本 # php -v > PHP 7.0.20 (cli) (built: Jul 4 2017 14:39:02) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies // 配置php-fpm # cp php.ini-production /etc/php.ini # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm // 添加php-fpm至服务列表并设置开机自启。 # chkconfig --add php-fpm # chkconfig --list php-fpm # chkconfig php-fpm on // 启动php-fpm # /etc/init.d/php-fpm start

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7d2b83cfe7d1e3c10ac0774f37a7ba10.html