Cenos7下nginx+mysql+php环境的搭建
首先更新系统软件
1 |
|
第一步:安装nginx
1.安装nginx源
1 |
|
2.安装nginx
1 |
|
3.启动nginx
1 |
|
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 |
|
在末尾加入
PATH=$PATH:/usr/local/php/bin
export PATH
要使改动立即生效执行
1 |
|
或
1 |
|
查看环境变量
1 |
|
查看php版本
1 |
|
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 |
|
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
在根目录写一段程序,测试数据库
最新文章
- pm2 开机自动运行
- 26、Jquery 基础
- Codeforces Round #371 (Div. 2) C 大模拟
- socket字符流循环截取
- 安装cmake
- shell脚本实例-case 删除用户判断的小案例
- 用django实现一个资产管理的系统
- VS2010编译Boost 1.56
- visual c++ 中的stdafx.h头文件的作用
- November 13th 2016 Week 47th Sunday The 1st Day
- spring中的控制反转
- su: Authentication failure 的解决方案
- [翻译]CSS模块-未来的编码方式
- Jenkins自动构建VS的代码20150607
- SQLite3开发接口函数详解
- oracle系统包——dbms_random用法
- PCA算法理解及代码实现
- 如何优雅地进行错误处理(clean code阅读笔记之六)
- SSH后台管理系统,实现查询+分页
- iOS 【资源篇】