Blogger Information
Blog 21
fans 2
comment 3
visits 44056
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CentOS系列之LNPM环境搭建
李洋
Original
1709 people have browsed it

Centos6.9系统配置LNMP环境并安装落larvael54

1、         更换yum源

进入网站跟着步骤走  网址( http://mirrors.163.com/.help/centos.html)

2、         安装nginx

创建文件  vim /etc/yum.repos.d/nginx.repo

# 粘贴下列代码到nginx.repo 
[nginx] 

name=nginx repo

baseurl=http://nginx.org/packages/centos/6/$basearch/ 

gpgcheck=0 

enabled=1

 

开始安装 

sudo yum install –y nginx

初始化nginx

service nginx restart

3、         安装Mysql

下载发行包  网址(http://dev.mysql.com/downloads/repo/yum/)

释放包 sudo rpm -Uvh mysql57-community-release-el6-11.noarch.rpm

开始安装   sudo yum install mysql-community-server

初始化Mysql服务  sudo service mysqld restart

获取初始化密码  sudo grep 'temporary password' /var/log/mysqld.log

登陆  mysql –uroot –p

修改密码  set password=PASSWORD("新密码")  (必须包含大写字母 小写字母 数字 符号)

4、         安装php

安装杂项

yum install -y epel-release

yum makecache fast

yum install -y gcc gcc-c++ perl libpng-devel libjpeg-devel libwebp-devel libXpm-devel libtiff-devel libxml2-devel libcurl-devel libmcrypt-devel fontconfig-devel freetype-devel libzip-devel bzip2-devel gmp-devel readline-devel recode-devel GeoIP-devel bison re2c

创建PHP管理用户

groupadd www

useradd www -g www

安装必要的包

 

 

安装libiconv

下载并解压 libiconv

cd /tmp

curl -O --retry 3 https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz

tar -zxf libiconv-1.15.tar.gz

 

# 编译

cd libiconv-1.15

./configure --prefix=/usr/local/libiconv

make -j && make install

 

# 增加到动态链接库:

echo '/usr/local/libiconv/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

 

安装pcre

# 下载并解压 pcre

cd /tmp

curl -O --retry 3 https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz

tar -zxf pcre-8.40.tar.gz

 

# 编译

cd pcre-8.40

./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties

make -j && make install

 

# 增加到动态链接库

echo '/usr/local/pcre/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

 

安装zlib

# 下载并解压 zlib

cd /tmp

curl -O --retry 3 http://zlib.net/zlib-1.2.11.tar.gz

tar -zxf zlib-1.2.11.tar.gz

 

# 编译

cd zlib-1.2.11

./configure --prefix=/usr/local/zlib

make -j && make install

 

# 增加到动态链接库

echo '/usr/local/zlib/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

 

 

安装libgd

# 下载并解压 libgd

cd /tmp

curl -O --retry 3 -L https://github.com/libgd/libgd/releases/download/gd-2.2.4/libgd-2.2.4.tar.gz

tar -zxf libgd-2.2.4.tar.gz

 

# 编译

cd libgd-2.2.4

./configure \

  --prefix=/usr/local/libgd \

  --with-libiconv-prefix=/usr/local/libiconv \

  --with-zlib=/usr/local/zlib \

  --with-jpeg=/usr \

  --with-png=/usr \

  --with-webp=/usr \

  --with-xpm=/usr \

  --with-freetype=/usr \

  --with-fontconfig=/usr \

  --with-tiff=/usr

make -j && make install

 

# 增加到动态链接库

echo '/usr/local/libgd/lib' >> /etc/ld.so.conf.d/custom-libs.conf

ldconfig

 

 

安装openssl

# 下载并解压 openssl

cd /tmp

curl -O --retry 3 https://www.openssl.org/source/openssl-1.0.2k.tar.gz

tar -zxf openssl-1.0.2k.tar.gz

 

# 编译

cd openssl-1.0.2k

./config --prefix=/usr/local/openssl -fPIC

make -j && make install

 

安装php

# 下载并解压 php

cd /tmp

curl -O --retry 3 http://cn.php.net/distributions/php-7.1.27.tar.gz

tar -zxf php-5.6.32.tar.gz

 

# 编译

cd php-5.6.32

./configure \

  --prefix=/usr/local/php71 \

  --sysconfdir=/etc/php71 \

  --with-config-file-path=/etc/php71 \

  --with-config-file-scan-dir=/etc/php71/php-fpm.d \

  --with-fpm-user=www \

  --with-fpm-group=www \

  --with-curl \

  --with-mhash \

  --with-mcrypt \

  --with-gd \

  --with-gmp \

  --with-bz2 \

  --with-recode \

  --with-readline \

  --with-gettext \

  --with-mysqli=mysqlnd \

  --with-pdo-mysql=mysqlnd \

  --with-openssl=/usr/local/openssl \

  --with-openssl-dir=/usr/local/openssl \

  --with-pcre-regex=/usr/local/pcre \

  --with-pcre-dir=/usr/local/pcre \

  --with-zlib=/usr/local/zlib \

  --with-zlib-dir=/usr/local/zlib \

  --with-iconv-dir=/usr/local/libiconv \

  --with-libxml-dir=/usr \

  --with-libzip=/usr \

  --with-gd=/usr/local/libgd \

  --with-jpeg-dir=/usr \

  --with-png-dir=/usr \

   --with-xpm-dir=/usr \

  --with-freetype-dir=/usr \

  --enable-fpm \

  --enable-ftp \

  --enable-gd-native-ttf \

  --enable-gd-jis-conv \

  --enable-calendar \

  --enable-exif \

  --enable-pcntl \

  --enable-soap \

  --enable-shmop \

  --enable-sysvmsg \

  --enable-sysvsem \

  --enable-sysvshm \

  --enable-wddx \

  --enable-inline-optimization \

  --enable-bcmath \

  --enable-mbstring \

  --enable-mbregex \

  --enable-re2c-cgoto \

  --enable-xml \

  --enable-mysqlnd \

  --enable-embedded-mysqli \

  --enable-opcache \

             --enable-sockets\

  --disable-debug

make -j && make install

 

添加软连接

ln -sf /usr/local/php71/bin/php /usr/bin/php

ln -sf /usr/local/php71/bin/phpize /usr/bin/phpize

ln -sf /usr/local/php71/sbin/php-fpm /usr/bin/php-fpm

配置PHP-fpm

cp /www/php-7.1.15/php.ini-development /etc/php71/php.ini

cp /usr/local/php71/sbin/php-fpm /usr/bin/php-fpm

cp /etc/php71/php-fpm.conf.default /etc/php56/php-fpm.conf

 

配置Nginx

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak

vim /etc/nginx/conf.d/default.conf

将文件代码替换为

 

 

server

{

    listen 80;

    server_name 127.0.0.1; #server_name end

    index index.html index.htm index.php; #index end

    charset utf-8;

    if ($host ~* ^([^\.]+)\.([^\.]+\.[^\.]+)$) {

     set $subdomain $1;

     set $domain $2;

    }

    # set $subdomain '/';

    root  /home/wwwroot/index/$subdomain/;

    #include rewrite/nomal.conf; #rewrite end

 

    location ~ .*\.php$

    {

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            fastcgi_param  PATH_INFO  $fastcgi_path_info;

            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;

    }

 

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$

    {

        expires      30d;

    }

 

    location ~ .*\.(js|css)$

    {

        expires      12h;

    }

 

    location ~* /templates(/.*)\.(bak|html|htm|ini|old|php|tpl)$ {

        allow 127.0.0.1;

        deny all;

    }

 

    location ~* \.(ftpquota|htaccess|htpasswd|asa|mdb)?$ {

        deny all;

    }

 

    location ~ /node_modules/ {

        deny all;

    }

  location / {

    try_files $uri $uri/ /index.php?$query_string;

   }

    access_log /var/log/nginx/index-access.log main; #access_log end

    error_log /var/log/nginx/index-error.log crit; #error_log end

}

调试

service mysqld restart

service nginx restart

php-fpm

 

 

在/home目录下建立/wwwroot/index/目录

 

修改文件夹权限命令  chown –R 777  index

利用Xftp将larvael54项目上传至该目录  然后浏览器访问   OK

 

 

 

注释:

启动php出现如下错误

[23-Mar-2018 21:18:01] WARNING: Nothing matches the include pattern '/etc/php71/php-fpm.d/*.conf' from /etc/php71/php-fpm.conf at line 125.

[23-Mar-2018 21:18:01] ERROR: No pool defined. at least one pool section must be specified in config file

[23-Mar-2018 21:18:01] ERROR: failed to post process the configuration

[23-Mar-2018 21:18:01] ERROR: FPM initialization failed

 

解决方法:

cd /etc/php71/php-fpm.d/

cp www.conf.default www.conf

php-fpm

 

 

在centos7中

重启nginx命令systemctl  restart nginx

不重启直接加载配置命令:systemctl reload nginx

重启mysql命令 systemctl restart mysql


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post