1. 云栖社区>
  2. PHP教程>
  3. 正文

CentOS7配置Ngnix+PHP

作者:用户 来源:互联网 时间:2017-12-01 17:02:10

配置

CentOS7配置Ngnix+PHP - 摘要: 本文讲的是CentOS7配置Ngnix+PHP, 首先安装nignx yum install -y nginx 安装php和相关包 yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pec

首先安装nignx

yum install -y nginx

安装php和相关包

yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap php-develpecl install apc

编辑php和php-fpm的配置文件

vim /etc/php.ini找到:;date.timezone =修改为:date.timezone = Aisa/Shanghai找到:disable_functions =修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
vim /etc/php-fpm.confpid = run/php-fpm.pid 

vim /etc/php-fpm.d/*.conf
user = nginx #设置php-fpm运行账号为nginx

group = nginx #设置php-fpm运行组为nginx

编辑 nginx的配置文件

[root@node1 nginx]# cat nginx.conf# For more information on configuration, see:#   * Official English Documentation: http://nginx.org/en/docs/#   * Official Russian Documentation: http://nginx.org/ru/docs/**user nginx nginx;**  这里要做修改改成nginx的用户组和密码worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;......[root@node1 nginx]# vim /etc/nginx/nginx.conf   server {        listen       80 default_server;        listen       [::]:80 default_server;        server_name  _;        **root         /usr/share/nginx/html;** 这个就是nginx服务器放置网页界面的路径        **index       index.html index.php index.htm**        # Load configuration files for the default server block.        include /etc/nginx/default.d/*.conf;        location ~ /.php$ {              root html;              fastcgi_pass 127.0.0.1:9000;              fastcgi_index index.php;              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;              include fastcgi_params;             }

server里面和 location 进行修改。
然后

[root@node1 nginx]# cd /usr/share/nginx/html[root@node1 html]# rm -rf *[root@node1 html]# vim index.php<?phpphpinfo();?>

然后启动php-fpm和nginx服务
service nginx start
service php-fpm restart
这样php和nginx 就能建立了

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索配置 ,以便于您获取更多的相关知识。