CentOS7配置Ngnix+PHP
2015-11-15 22:01
676 查看
首先安装nignx
安装php和相关包
编辑php和php-fpm的配置文件
vim /etc/php-fpm.d/*.conf
user = nginx #设置php-fpm运行账号为nginx
group = nginx #设置php-fpm运行组为nginx
编辑 nginx的配置文件
server里面和 location 进行修改。
然后
然后启动php-fpm和nginx服务
service nginx start
service php-fpm restart
这样php和nginx 就能建立了
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-devel pecl 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.conf pid = 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 / { root /usr/share/nginx/html; index index.html index.htm index.php; } 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 <?php phpinfo(); ?>
然后启动php-fpm和nginx服务
service nginx start
service php-fpm restart
这样php和nginx 就能建立了
相关文章推荐
- 一个关于if else容易迷惑的问题
- nginx代理指定目录
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- 访问Nginx发生SSL connection error的一种情况
- Centos6 编译安装Python
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- Nginx+Naxsi部署专业级Web应用防火墙
- 什么是设计模式
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- PHP数据库长连接mysql_pconnect的细节
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3