阿里云 Centos 7 PHP7环境配置 LNMP
阿里云 Centos 7 PHP7环境配置 LNMP (centos7+nginx+MySQL5.7.9+PHP7)
首先更新系统软件$ yum update
安装nginx
1.安装nginx源
1. |
|
2.安装nginx
1. |
$ yum install nginx |
3.启动nginx
1. |
$ service nginx start |
Redirecting to /bin/systemctl start nginx.service
4.访问http://你的ip/
如果成功安装会出来nginx默认的欢迎界面
安装MySQL5.7.*
1.安装mysql源
1. |
|
2.安装mysql
1. |
$ yum install mysql-community-server |
确认一下mysql的版本,有时可能会提示mysql5.6
3.安装mysql的开发包,以后会有用
1. |
$ yum install mysql-community-devel |
4.启动mysql
1. |
$ service mysqld start |
Redirecting to /bin/systemctl start mysqld.service
5.查看mysql启动状态
1. |
$ service mysqld status |
出现pid
证明启动成功
6.获取mysql默认生成的密码
1. |
$ grep 'temporary password' /var/log/mysqld.log |
2015-12-05T05:41:09.104758Z 1 [Note] A temporary password is generated for root@localhost: %G1Rgns!dD!v</str></str>
加粗的就是生成的密码
7.换成自己的密码
1. |
$ mysql -uroot -p |
Enter password:输入上面的密码
成功输入后进入一下步,这里你估计会输入 好几次才进去
8. 更换密码
1. |
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; |
这个密码一定要足够复杂,不然会不让你改,提示密码不合法;
9.退出mysql;
1. |
mysql> quit; |
10.用新密码再登录,试一下新密码
1. |
$ mysql -uroot -p |
Enter password:输入你的新密码
11.确认密码正确后,退出mysql;
1. |
mysql> quit; |
编译安装php7.0.0
1.下载php7源码包
1. |
|
2.解压源码包
1. |
$ tar -xvf php7.tar.gz |
3.
1. |
$ cd php-7.0.1 |
4.安装php依赖包
1. |
$ 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 |
5.编译配置,这一步我们会遇到很多configure error,我们一一解决,基本都是相关软件开发包没有安装导致
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68. |
$ ./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 |
configure error:
1.configure: error: xml2-config not found. Please check your libxml2 installation.
解决:
1. |
$ yum install libxml2 libxml2-devel |
2.configure: error: Cannot find OpenSSL's <evp.h>
解决:
1. |
$ yum install openssl openssl-devel |
3.configure: error: Please reinstall the BZip2 distribution
解决:
1. |
$ yum install bzip2 bzip2-devel |
4.configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
解决:
1. |
$ yum install libcurl libcurl-devel |
5.If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.
解决:
1. |
$ yum 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.
解决:
1. |
$ yum 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.
解决:
1. |
$ yum install freetype freetype-devel |
8.configure: error: Unable to locate gmp.h
解决:
1. |
$ yum install gmp gmp-devel |
9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
$ yum install libmcrypt libmcrypt-devel
10.configure: error: Please reinstall readline - I cannot find readline.h
解决:
1. |
$ yum install readline readline-devel |
11.configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决:
1. |
$ yum install libxslt libxslt-devel |
6.编译与安装
1. |
$ make && make install |
这里要make好久,要耐心一下
7.添加 PHP 命令到环境变量
1. |
$ vim /etc/profile |
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改动立即生效执行
1. |
$ ./etc/profile |
或
1. |
$ source /etc/profile |
查看环境变量
1. |
$ echo $PATH |
查看php版本
1. |
$ php -v |
8.配置php-fpm
1. |
$ cp php.ini-production /etc/php.ini |
1.2.3. |
$ 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 |
1. |
$ cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm |
1. |
$ chmod +x /etc/init.d/php-fpm |
9.启动php-fpm
1. |
$ /etc/init.d/php-fpm start |
配置nginx虚拟机,绑定域名
1.
1. |
$ vim /etc/nginx/conf.d/php7.thinkcmf.com.conf |
这里可以把php7.thinkcmf.com.conf改成自己的域名
把下面的内容复制到php7.thinkcmf.com.conf里
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51. |
server{listen 80;server_name php7.thinkcmf.com;root /var/www/html/php7.thinkcmf.com; # 该项要修改为你准备存放相关网页的路径location / {index index.php index.html index.htm;#如果请求既不是一个文件,也不是一个目录,则执行一下重写规则if (!-e $request_filename){#地址作为将参数rewrite到index.php上。rewrite ^/(.*)$ /index.php/$1;#若是子目录则使用下面这句,将subdir改成目录名称即可。#rewrite ^/subdir/(.*)$ /subdir/index.php/$1;}}#proxy the php scripts to php-fpmlocation ~ \.php {include fastcgi_params;##pathinfo支持start#定义变量 $path_info ,用于存放pathinfo信息set $path_info "";#定义变量 $real_script_name,用于存放真实地址set $real_script_name $fastcgi_script_name;#如果地址与引号内的正则表达式匹配if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {#将文件地址赋值给变量 $real_script_nameset $real_script_name $1;#将文件地址后的参数赋值给变量 $path_infoset $path_info $2;}#配置fastcgi的一些参数fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;###pathinfo支持endfastcgi_intercept_errors on;fastcgi_pass 127.0.0.1:9000;}location ^~ /data/runtime {return 404;}location ^~ /application {return 404;}location ^~ /simplewind {return 404;} } |
2.重启nginx
1. |
$ service nginx reload |
3.
1. |
|
把下面的代码复制到这个文件 里
<?php
phpinfo();
4.查看访问http://php7.thinkcmf.com
阿里云 Centos 7 PHP7环境配置 LNMP相关推荐
- 阿里云Centos 安装 Docker 环境
更新yum # 确保系统环境不低于 3.10 uname -r // 3.10.0-1062.1.2.el7.x86_64# 更新yum 包 (多余但省事 下面的yum install 省了) yum ...
- 阿里云安装数据库mysql数据库服务器_阿里云CentOs服务器 安装与配置mysql数据库...
Linux 安装mysql 数据库 一下为mysql 安装教程 Using username"root". Last login: Tue Oct8 09:30:34 2019 f ...
- 阿里云centos环境之Let's Encrypt SSL证书配置十一
阿里云centos环境之Let's Encrypt SSL证书配置<十一> 1.目标 Let's Encrypt是国外一个公共的免费SSL项目.这里记录的是可执行的生成免费SSL证书Let ...
- 阿里云CentOS 7.4 配置Nginx、PHP、Mariadb
2019独角兽企业重金招聘Python工程师标准>>> 阿里云CentOS 7.4 基本环境配置 添加 yum 第三方源 常用的第三方源有两个:EPEL 和 IUS,可在 https ...
- 阿里云centos 安装和配置 DokuWiki
DokuWiki 是一个开源的 wiki 项目, 可方便进行知识和内容的管理和分享,不用安装数据库,内置权限管理,书写直观方便,有大量的插件支持. 特别适用于企业内部的内容和知识管理,只允许内部员工编 ...
- 阿里云centos环境之vsftpd安装(十五)
阿里云centos环境之vsftpd安装(十五) 文章目录 前言 安装 检测 安装 配置文件路径 启动服务器 启动ftp命令: 其它相关命令 停止ftp命令: 重启ftp命令: 设置开机自启动 看是否 ...
- 在阿里云购买Linux服务器,配置宝塔环境,全图文,最最详细图解,保姆级教学
在阿里云购买Linux服务器( CentOs 7 ),配置宝塔环境 一.在阿里云购买CentOs服务器(Linux系统) CentOS是免费的.开源的.可以重新分发的开源操作系统 ,CentOS(Co ...
- 阿里云CentOS环境之-实战docker集群swarm(十五)
前言 docker1.12版本之前版本配置 准备工作 开始 拉取swarm 开放2375远程访问端口 创建集群的token 向集群里添加结点 查看集群里有哪些结点 创建管理者容器 使用集群 离开集群 ...
- 阿里云centos环境之linux上redis安装及踩过的坑(七)
阿里云centos环境之linux上redis安装及踩过的坑<七> 文章目录 阿里云centos环境之linux上redis安装及踩过的坑<七> 第一:下载上传 第二:解压安装 ...
最新文章
- [译] 解密 Airbnb 的数据科学部门如何构建知识仓库
- 在word中的公式以代码形式体现在web上的方法
- fraction函数的分数处理
- 英语口语-文章朗读Week8 Friday
- python绘制混淆矩阵_如何实现python绘制混淆矩阵?
- maven配置(myeclipse版)
- 安装完MySQL后启动报错_MySQL数据库之mysql编译安装完成后,启动时报错The server quit without updating PID file...
- SpringBoot项目配置明文密码泄露问题处理
- 计算机中URL是指什么 ?
- Git还能这样玩?居然被他玩出了新花样
- vnc远程软件,四款值得使用的vnc远程软件推荐
- BUUCTF misc 专题(22)隐藏的钥匙
- Mac打不开别人的.one文件
- 近地天体撞击地球原理的设想
- jquery如何为元素设置style?
- 损失函数理解汇总,结合PyTorch和TensorFlow2
- python 导入离线地图_Geo地图导入python数据分析--(重点推荐)
- 组件服务 我的电脑 不可用解决办法
- 通过URL访问韩国Naver地图
- FTP服务器的安装,用户的添加,密码的设置