yum remove httpd* php*
使用php -v看是否还能看到php的版本信息,如果能,说明没卸载干净,继续进行以下操作:
rpm -qa | grep php
根据列表卸载,注意卸载顺序,先卸载没有依赖的。
正确的卸载顺序为:
rpm -e php-mysql-5.1.6-27.el5_5.3
rpm -e php-pdo-5.1.6-27.el5_5.3
rpm -e php-xml-5.1.6-27.el5_5.3
rpm -e php-cli-5.1.6-27.el5_5.3
rpm -e php-gd-5.1.6-27.el5_5.3
rpm -e php-common-5.1.6-27.el5_5.3
最后,再用php -v,看看是否卸载干净。
1 |
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpmmirror.webtatic.com/yum/el6/latest.rpm |
CentOs 7.X
1 2 |
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm |
如果想删除上面安装的包,使用以下命令:
- rpm -qa | grep webtatic
- rpm -e 上面搜索到的包即可
yum list php* //显示可用的php安装包
安装php7.0
yum -y install php70w.x86_64
php -v //查看安装的php版本
php -m //查看安装的php模块
查找php:
which php 或 whereis php
安装php-fpm
yum -y install php70w-fpm.x86_64
根据需要,安装其他模块,命令为:php -y install XXXXX
查看nginx运行在哪个用户下
1 |
ps -ef | grep nginx |
查看php-fpm运行在哪个用户下
1 |
ps -ef | grep php-fpm |
调整nginx的运行用户
nginx配置文件,第一行
1 |
user XXXX |
调整php-fpm的运行用户
yum安装的php-fpm,配置文件所在路径:/etc/php-fpm.d/www.conf
1 2 |
user = www-data group = www-data |
重启php-fpm
1 |
/etc/init.d/php-fpm restart |
netstat -tln | grep 9000 //查看9000端口使用情况
ps aux | grep php-fpm //查看是否运行在www-data用户
运行用户修改完毕,继续修改文件目录权限
chown www-data:www-data -R /网站目录XXX
添加可执行权限
1 |
chmod +x /etc/init.d/php-fpm |
添加到开机自动启动
1 2 |
chkconfig --add php-fpm chkconfig php-fpm on |
这样后,php-fpm就会开机自动启动了,而且可以使用以下命令进行重启
1 2 3 |
service php-fpm start service php-fpm stop service php-fpm reload或restart |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
server { #监听端口 listen 80; #访问域名 server_name 域名; index index.php index.html index.htm; #编码格式,若网页格式与此不同,将被自动转码 charset utf-8; #设定本虚拟主机的访问日志 #access_log /var/log/nginx/host.access.log main; #注意一下,这里把root放到了location外面 root /data/wwwroot/XXXX; location / { try_files $uri $uri/ /index.php$is_args$args; } #使nginx能够解析php文件 location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; #这个是php-fpm监听的端口,默认为9000 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #这里的$document_root就是上面外层的root include fastcgi_params; } #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/share/nginx/html; } # Whitelist ## Let October handle if static file not exists location ~ ^/favicon\.ico { try_files $uri /index.php; } location ~ ^/sitemap\.xml { try_files $uri /index.php; } location ~ ^/robots\.txt { try_files $uri /index.php; } location ~ ^/humans\.txt { try_files $uri /index.php; } ## Let nginx return 404 if static file not exists location ~ ^/storage/app/uploads/public { try_files $uri 404; } location ~ ^/storage/app/media { try_files $uri 404; } location ~ ^/storage/temp/public { try_files $uri 404; } location ~ ^/modules/.*/assets { try_files $uri 404; } location ~ ^/modules/.*/resources { try_files $uri 404; } location ~ ^/modules/.*/behaviors/.*/assets { try_files $uri 404; } location ~ ^/modules/.*/behaviors/.*/resources { try_files $uri 404; } location ~ ^/modules/.*/widgets/.*/assets { try_files $uri 404; } location ~ ^/modules/.*/widgets/.*/resources { try_files $uri 404; } location ~ ^/modules/.*/formwidgets/.*/assets { try_files $uri 404; } location ~ ^/modules/.*/formwidgets/.*/resources { try_files $uri 404; } location ~ ^/modules/.*/reportwidgets/.*/assets { try_files $uri 404; } location ~ ^/modules/.*/reportwidgets/.*/resources { try_files $uri 404; } location ~ ^/plugins/.*/.*/assets { try_files $uri 404; } location ~ ^/plugins/.*/.*/resources { try_files $uri 404; } location ~ ^/plugins/.*/.*/behaviors/.*/assets { try_files $uri 404; } location ~ ^/plugins/.*/.*/behaviors/.*/resources { try_files $uri 404; } location ~ ^/plugins/.*/.*/reportwidgets/.*/assets { try_files $uri 404; } location ~ ^/plugins/.*/.*/reportwidgets/.*/resources { try_files $uri 404; } location ~ ^/plugins/.*/.*/formwidgets/.*/assets { try_files $uri 404; } location ~ ^/plugins/.*/.*/formwidgets/.*/resources { try_files $uri 404; } location ~ ^/plugins/.*/.*/widgets/.*/assets { try_files $uri 404; } location ~ ^/plugins/.*/.*/widgets/.*/resources { try_files $uri 404; } location ~ ^/themes/.*/assets { try_files $uri 404; } location ~ ^/themes/.*/resources { try_files $uri 404; } } |
重启nginx。
现在试试吧,是不是可以打开octobercms网站了。
附:linux用户管理
from:https://blog.csdn.net/flyhorstar/article/details/88052267