首先更新系统软件

1

$ yum update

第一步:安装nginx

1.安装nginx源

1

$ yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安装nginx

1

$ yum install nginx

3.启动nginx

1

$ service nginx start

Redirecting to /bin/systemctl start  nginx.service

4.访问http://你的ip/

如果成功安装会出来nginx默认的欢迎界面

第二步:安装mysql

RPM安装MySQL:

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpmyum install -y mysql-community-server

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

  service mysqld restart 或 systemctl restart mysqld.service

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

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

第三步: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.安装依赖输入命令

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

注意:libmcrypt 和libmcrypt依赖无法安装,自己可以去网上找解决办法

3. 配置

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

4. 编译安装:

  make && make install

5.添加 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

6.配置php-fpm

$ cp php.ini-production /etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

7.启动php-fpm

1

$ /etc/init.d/php-fpm start

8、输入命令

cd  /etc/conf.d

vi  default.conf

配置根目录:

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  /var/log/nginx/log/host.access.log  main;

location / {

root   /usr/www;  //根目录

index  index.html index.htm;

}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   /usr/www;  //根目录

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root           /usr/www;  //根目录

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

#    deny  all;

#}

}

重启nginx

service nginx reload

在根目录写一段程序,测试数据库

最新文章

  1. pm2 开机自动运行
  2. 26、Jquery 基础
  3. Codeforces Round #371 (Div. 2) C 大模拟
  4. socket字符流循环截取
  5. 安装cmake
  6. shell脚本实例-case 删除用户判断的小案例
  7. 用django实现一个资产管理的系统
  8. VS2010编译Boost 1.56
  9. visual c++ 中的stdafx.h头文件的作用
  10. November 13th 2016 Week 47th Sunday The 1st Day
  11. spring中的控制反转
  12. su: Authentication failure 的解决方案
  13. [翻译]CSS模块-未来的编码方式
  14. Jenkins自动构建VS的代码20150607
  15. SQLite3开发接口函数详解
  16. oracle系统包——dbms_random用法
  17. PCA算法理解及代码实现
  18. 如何优雅地进行错误处理(clean code阅读笔记之六)
  19. SSH后台管理系统,实现查询+分页
  20. iOS 【资源篇】

热门文章

  1. 一个DRF框架的小案例
  2. 38 是否要使用memory引擎的表
  3. 安装node和npm和vue-cli和webpack-cli
  4. js数组,运算符
  5. [Usaco2005 mar]Yogurt factory 奶酪工厂
  6. es6 export及export default 的使用 及 区别
  7. [Web 前端] 007 css 常见的七种选择器
  8. BZOJ 1875(DP+矩阵快速幂)
  9. Java JDK在Mac下的配置方法
  10. java NIO介绍