CentOS7搭建Nginx + PHP + MySQL

來源:互聯網
上載者:User

標籤:

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

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/atomicsh ./atomic

    yum命令安裝:

yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

   )

 

  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-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

 

  安裝完成後你會發現,在/usr/local/php/etc下面沒有php的設定檔,建立一個: 

cd /usr/local/php/etc/cp php-fpm.conf.default php-fpm.confcd /home/weichen/php-5.6.3cp php.ini-production /usr/local/php/etc/php.ini

 

  5. 啟動php:
/usr/local/php/sbin/php-fpm

 

  查看進程:  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.rpmrpm -ivh mysql-community-release-el7-5.noarch.rpmyum 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.chenwei.ws> 

CentOS7搭建Nginx + PHP + MySQL

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.