您的位置:首页 > 运维架构 > Linux

centos7.2 安装lnmp环境 (非集成)

2017-08-02 17:36 411 查看

centos7.2 安装lnmp环境 (非集成)

发表于2017/7/13 22:20:12 42人阅读
关于php-fpmnginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端。nginx一般是把请求发fastcgi管理进程处理,fascgi管理进程选择cgi子进程处理结果并返回被nginx。PHP-FPM是一个PHP FastCGI管理器,是只用于PHP的。PHP在 5.3.3 之后已经讲php-fpm写入php源码核心了。所以已经不需要另外下载了。获取PHP下载地址为什么选择5.6.30这个版本,因为学习,不是研究。诚然,7.0新增了很多PHP的新特性,性能上面也有些提升,如果是研究,倒是可以折腾一番,后面得空再讲7.0的版本以及如何在各个PHP版本之间切换。打开php的官网:http://php.net/,查看php的版本列表 右击,复制链接地址,在远程主机登录,下载该软件(我选的是Australia的主机mirror下载的)# wget http://au1.php.net/get/php-5.6.30.tar.gz/from/this/mirror下载下来的是一个mirror文件,改成我们需要的文件名 #mv mirror php-5.6.30.tar.gz#tar zxvf php-5.6.30.tar.gz#cd php-5.6.30 安装libxml2相关组件 #yum install libxml2#yum install libxml2-devel -y安装curl相关组件 #yum install curl curl-devel安装libpng相关组件 #yum install libpng#yum install libpng-devel安装freetype相关组件 #yum install freetype-devel安装libxslt相关组件#yum install libxslt-devel #yum install openssl openssl-devel#ln -s /usr/lib64/libssl.so /usr/lib/ 配置安装进入到目录,我们需要在安装的时候将安装目录配置到/usr/local/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-MySQL --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-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip 好的,当我们看到下面这句话的时候,说明你的php已经配置完成啦! 接下来我们只需要编译安装即可完成php的安装 #make && make install看到这句话,表明安装完成! 为了保险起见,我们make test一把,看看是否真的成功了。配置相关php.ini配置首先我们需要配置的是php.ini这个文件安装目录有2个文件:php.ini-development和php.ini-productionphp.ini-production 线上版本使用php.ini-development 开发版本使用我们选择development进行配置 # cp php.ini-development /usr/local/php/lib/php.iniphp-fpm配置拷贝php-fpm配置文件 #cp -R ./sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf拷贝启用文件#cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm(已弃用,详细的见注1)启动 /usr/local/php/sbin/php-fpm查看php是否启动成功 #ps aux | grep php 看到这些,表明你的php已经启动成功啦!重启及关闭#kill -9 进程号/usr/local/php/sbin/php-fpm 配置Nginx支持PHPvi /usr/local/nginx/conf/nginx.conf location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 源码编译Nginxyum -y install gcc gcc-c++ pcre-devel zlib zlib-develcd /usr/src/wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gztar zxvf pcre-8.39.tar.gzwget http://zlib.net/zlib-1.2.11.tar.gztar zxvf zlib-1.2.11.tar.gz第二步:下载Nginx并解压 wget http://nginx.org/download/nginx-1.11.13.tar.gz tar -zxvf ./nginx-1.11.13.tar.gz cd nginx-1.11.13
第三步: ./configure --prefix=/usr/local/nginx/ --with-pcre=/usr/src/pcre-8.39 --with-zlib=/usr/src/zlib-1.2.11第四步: make && make installnginx启动方式/usr/local/nginx/sbin/nginx 安装mysql 检测mysql是否卸载干净rpm -aq | grep -i mysql MYSQL安装1.先下载mysql的repo源;相关命令: wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm2.安装mysql-community-release-el7-5.noarch.rpm包(安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo) rpm -ivh mysql-community-release-el7-5.noarch.rpm3.安装MYSQL sudo yum install mysql-server重启服务: systemctl restart mysql.service 修改数据库登录密码:use mysql;update user set password=password('root') where user='root';设置外部连接权限,密码grant all privileges on *.* to 'root'@'%' identified by 'jiacheng123.';更新:flush privileges;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LNMP 安装步骤