CentOS7搭建Nginx + PHP + MySQL

-------------------------------------------------------------------------------------

Nginx安装参考地址:http://www.cnblogs.com/farwish/p/3807289.html

 

PHP源码安装:

  1. 下载源码包并解压:

wget http://cn2.php.net/distributions/php-5.6.3.tar.gz
 
tar zxvf php-5.6.3.tar.gz
 
cd php-5.6.3

 

  2. 安装依赖:

  这些依赖有libxml, libpng, libjpeg, libmcrypt...等

  根据提示进行操作,如:yum install libxml2 按Tab键查看所有libxml包,我这里安装 yum install libxml2-devel.i686,然后进行配置。

  注:libmcrypt不在centos的网络yum仓库中,需要自行下载。

  (  一. 源码安装方法:

    cd /usr/local/src

    wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz

    tar -zxvf libmcrypt-2.5.8.tar.gz

    cd /usr/local/src/libmcrypt-2.5.8

    ./configure --prefix=/usr/local

    make && make install

    

      二. 使用第三方yum源
    下载:

wget http://www.atomicorp.com/installers/atomic
sh ./atomic

    yum命令安装:

yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

   )

 

  gd中的一些函数依赖freetype, 需要安装:

    wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.gz

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

    make && make install

 

  3. 配置: 

./configure --with-libdir=lib64 --prefix=/Data/apps/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-inline-optimization --enable-fpm --with-freetype-dir=/usr/local/freetype/ --with-gd --with-zlib --with-png-dir --with-jpeg-dir --enable-mbstring --with-iconv --enable-sockets --with-curl --with-mcrypt --with-openssl --enable-pcntl --enable-soap --enable-dba

 

  4. 编译安装:

  make && make install

 

  复制一份php的配置文件,新建一个: 

cd /usr/local/php/lib  # 可以在phpinfo中查看
cp php-fpm.conf.default php-fpm.conf
cd /home/weichen/php-5.6.3
cp php.ini-production /usr/local/php/lib/php.ini

 

  5. 启动php:
/usr/local/php/sbin/php-fpm  (注意:需要root权限进行操作)

 

  查看进程:
  ps aux | grep php
 
  修改网站根目录:  
vim /usr/local/nginx/conf/nginx.conf
  将
  location / {
            root   html;
            index  index.php index.html index.htm;
        }
  改为
location / {
      root   /home/www;
      index  index.php index.html index.htm;
}

 

  此处的目录地址也需要修改对:  
location ~ \.php$ {
      root           /home/www;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
      include        fastcgi_params;
}

 

-------------------------------------------------------------------------------------------------

 
安装MySQL:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

 

成功安装之后重启mysql服务:

  service mysqld restart

 

初次安装mysql是root账户是没有密码的:

  mysql -u root -p   遇到密码提示,回车即可进入

 

设置root密码的方法:

   mysqladmin -u root password "root"
 
进入mysql:
  mysql -u root -p
  Enter Password: root
 
----------------------------------------------------------------------------------------
 
Link: http://www.cnblogs.com/farwish/p/4161417.html
@黑眼诗人 <www.farwish.com>

你可能感兴趣的:(centos)