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

2,599次阅读
一条评论

安装PHP+nginx+MySQL

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

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

# 更新源
yum update

# 安装nginx
yum install nginx -y

# 安装mysql
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm

# 安装PHP7.2
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum update
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

# 启动服务
service nginx start
service mysql start
service php-fmp start
/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php-fpm.conf > /dev/null 2>&1 &

# 编辑配置文件
vim /etc/nginx/nginx.conf
:q! #不保存退出
:wq #保存退出

# 1、编辑/etc/nginx
#/nginx.conf,启用如下选项:
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    include        fastcgi_params;
}
# 2、在所支持的主页面格式中添加php格式的主页,类似如下:
location / {
    root   html;
    index  index.php index.html index.htm;
}
# 3、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:
# cp /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params.bk
# cat /dev/null>/etc/nginx/fastcgi_params
# vim /etc/nginx/fastcgi_params
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# 4、重新载入nginx的配置文件:
nginx -t               
service nginx reload 


# 停止nginx
nginx -s stop

# 卸载nginx
yum remove nginx 

# 推送文件
cd /usr/share/nginx/html
lcd C:\DirName
put FileName.zip

# zip命令
#  解压:
unzip FileName.zip

#  压缩:
zip FileName.zip DirName

Hasukannal
版权声明:本站原创文章,由 Hasukannal 2019-06-10发表,共计2194字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(一条评论)
验证码
载入中...
小学生 评论达人 LV.1
2019-08-14 23:35:09 回复

对我很实用,哈哈,谢谢博主