User Tools

Site Tools


php:setup-env

CentOS搭建PHP环境

各种信息

Operation System: CentOS 7.2
Language Interpreter: PHP 5.4.16
Web Server: Nginx 1.6.3
Database: MySQL 5.5.52-MariaDB
Website Code: wordpress-4.7.4-zh_CN

新建一个文件,放在文件根目录下,方便查看各种信息。

phpinfo.php
  <?php phpinfo();

数据库相关

由运维帮忙安装的mysql,我远程登录到上面,然后用命令行:

mysql -uroot -p   
(因为新建的root帐号 不支持 远程直接连接,所以需要 远程登录到那台机器然后用命令行 本地连接mysql。 
当然可以进去以后改掉root的设置,但是建议别改)

新建一个帐号, %表示允许其他机器用这个帐号登录
 insert into mysql.user(Host,User,Password) values("%","userA",password("123456"));

为了能及时看到 执行一下:
flush privileges;

赋予这个帐号权限:
grant all on *.* to userA@"%" identified by "123456";

以下是数据库操作基本命令:
列出所有数据库  show database;
切换数据库    use '数据库名';
列出所有表   show tables;
显示数据表结构  describe 表名;
删除数据库 drop database 数据库名;
删除数据表 drop table 数据表名;

PHP相关

安装
yum install php php-mysql php-fpm

起动php-fpm
systemctl start php-fpm
设置php-fpm开机启动
systemctl enable php-fpm
查看启动状态:
systemctl status php-fpm

配置php处理器

vim /etc/php.ini
查找cgi.fix_pathinfo
将 ;cgi.fix_pathinfo=1改为cgi.fix_pathinfo=0

NGINX相关

F.Y.I. http://www.cnblogs.com/cglWorkBook/p/5431571.html

安装nginx    yum install nginx
设置nginx开启起动   systemctl start nginx
或者重启:  systemctl restart nginx

测试访问:  访问http://你的域名或IP/
查看nginx安装位置   whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz


配置www.conf
vim /etc/php-fpm.d/www.conf
将
user = nobody
group = nobody
改为
user = nginx
group = nginx
前提是已经创建了nginx用户和nginx组。



用whereis nginx命令找到并编辑  /etc/nginx/nginx.conf
添加:
<code>
        location ~ \.php$ {
          include fastcgi.conf;
          fastcgi_pass 127.0.0.1:9000;
        }

Install Wordpress

php/setup-env.txt · Last modified: 2018/07/24 08:13 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: 沪ICP备12046235号-2
Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki