我正在尝试按照这个Ansible教程,并将其调整为在Ubuntu 16.04上使用php7。 在此消息下方,您将找到我的Ansible文件。 运行后,在浏览器中尝试访问页面后,我遇到了404错误,并在nginx错误日志中找到了以下内容:
2016/10/15 13:13:20 [crit] 28771#28771: *7 connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 93.xxx.xxx.xx, server: 95.xx.xx.xx, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "95.xx.xx.xx"
所以我检查了套接字文件是否存在,似乎确实存在,但是ls
行为怪异:
$ sudo ls -l /var/run/php
total 4
-rw-r--r-- 1 root root 5 Oct 15 13:00 php7.0-fpm.pid
srw-rw---- 1 www-data www-data 0 Oct 15 13:00 php7.0-fpm.sock
$ sudo ls -l /var/run/php7
ls: cannot access '/var/run/php7': No such file or directory
$ sudo ls -l /var/run/php7.0-fpm.sock
ls: cannot access '/var/run/php7.0-fpm.sock': No such file or directory
如果我用部分名字php
搜索,为什么ls
可以找到套接字文件,但是当我列出大于那个名称php7
甚至完整的名称php7.0-fpm.sock
时,无法找到套接字文件呢?
最重要的是,我如何使它与nginx配合使用?欢迎所有提示!
下面是我粘贴的Ansible文件
---
- hosts: php
become: true
tasks:
- name: install packages
apt: name={{ item }} update_cache=yes state=latest
with_items:
- git
- mcrypt
- nginx
- php-cli
- php-curl
- php-fpm
- php-intl
- php-json
- php-mcrypt
- php-mbstring
- php-sqlite3
- php-xml
- sqlite3
- name: enable mbstring
shell: phpenmod mbstring
notify:
- restart php7.0-fpm
- restart nginx
- name: create /var/www/ directory
file: dest=/var/www/ state=directory owner=www-data group=www-data mode=0700
- name: Clone git repository
git: >
dest=/var/www/laravel
repo=https://github.com/laravel/laravel.git
update=no
become: true
become_user: www-data
register: cloned
- name: install composer
shell: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
args:
creates: /usr/local/bin/composer
- name: composer create-project
composer: command=create-project working_dir=/var/www/laravel optimize_autoloader=no
become: true
become_user: www-data
when: cloned|changed
- name: set APP_DEBUG=false
lineinfile: dest=/var/www/laravel/.env regexp='^APP_DEBUG=' line=APP_DEBUG=false
- name: set APP_ENV=production
lineinfile: dest=/var/www/laravel/.env regexp='^APP_ENV=' line=APP_ENV=production
- name: Configure nginx
template: src=nginx.conf dest=/etc/nginx/sites-available/default
notify:
- restart php5-fpm
- restart nginx
handlers:
- name: restart php7.0-fpm
service: name=php7.0-fpm state=restarted
- name: restart nginx
service: name=nginx state=restarted
- name: reload nginx
service: name=nginx state=reloaded
ls -l /var/run/php
列出目录内容。 请尝试ls -l /var/run/php/php7.0-fpm.sock
。 - oneindelijk