简单记录一下Linux安装PHP环境

安装PHP+nginx+MySQL




以下命令是在centos 7.2环境下,Linux命令通用,其他版本基本都一样

  1. # 更新源
  2. yum update
  3.  
  4. # 安装nginx
  5. yum install nginx -y
  6.  
  7. # 安装mysql
  8. wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
  9. yum localinstall mysql57-community-release-el7-11.noarch.rpm
  10.  
  11. # 安装PHP7.2
  12. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  13. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  14. yum update
  15. yum install -y php72w-cli php72w-common php72w-dba php72w-devel php72w-fpm php72w-gd php72w-imap php72w-mbstring php72w-mysql php72w-pdo php72w-pdo_dblib php72w-pear php72w-pecl-igbinary php72w-pecl-xdebug php72w-process php72w-xml php72w-xmlrpc php72w-opcache php72w-pecl-memcached php72w-pecl-mongodb php72w-pecl-redis
  16.  
  17. # 启动服务
  18. service nginx start
  19. service mysql start
  20. service php-fmp start
  21. /usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php-fpm.conf > /dev/null 2>&1 &
  22.  
  23. # 编辑配置文件
  24. vim /etc/nginx/nginx.conf
  25. :q! #不保存退出
  26. :wq #保存退出
  27.  
  28. # 1、编辑/etc/nginx
  29. #/nginx.conf,启用如下选项:
  30. location ~ \.php$ {
  31. root html;
  32. fastcgi_pass 127.0.0.1:9000;
  33. fastcgi_index index.php;
  34. fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  35. include fastcgi_params;
  36. }
  37. # 2、在所支持的主页面格式中添加php格式的主页,类似如下:
  38. location / {
  39. root html;
  40. index index.php index.html index.htm;
  41. }
  42. # 3、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:
  43. # cp /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params.bk
  44. # cat /dev/null>/etc/nginx/fastcgi_params
  45. # vim /etc/nginx/fastcgi_params
  46. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  47. fastcgi_param SERVER_SOFTWARE nginx;
  48. fastcgi_param QUERY_STRING $query_string;
  49. fastcgi_param REQUEST_METHOD $request_method;
  50. fastcgi_param CONTENT_TYPE $content_type;
  51. fastcgi_param CONTENT_LENGTH $content_length;
  52. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  53. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  54. fastcgi_param REQUEST_URI $request_uri;
  55. fastcgi_param DOCUMENT_URI $document_uri;
  56. fastcgi_param DOCUMENT_ROOT $document_root;
  57. fastcgi_param SERVER_PROTOCOL $server_protocol;
  58. fastcgi_param REMOTE_ADDR $remote_addr;
  59. fastcgi_param REMOTE_PORT $remote_port;
  60. fastcgi_param SERVER_ADDR $server_addr;
  61. fastcgi_param SERVER_PORT $server_port;
  62. fastcgi_param SERVER_NAME $server_name;
  63.  
  64. # 4、重新载入nginx的配置文件:
  65. nginx -t
  66. service nginx reload
  67.  
  68.  
  69. # 停止nginx
  70. nginx -s stop
  71.  
  72. # 卸载nginx
  73. yum remove nginx
  74.  
  75. # 推送文件
  76. cd /usr/share/nginx/html
  77. lcd C:\DirName
  78. put FileName.zip
  79.  
  80. # zip命令
  81. #  解压:
  82. unzip FileName.zip
  83.  
  84. #  压缩:
  85. zip FileName.zip DirName
本博客所有文章如无特别注明均为原创。作者:小乐复制或转载请以超链接形式注明转自 众众帮
原文地址《简单记录一下Linux安装PHP环境
分享到:更多

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)