zoukankan      html  css  js  c++  java
  • ubuntu16.04配置php环境

    #进入root权限
    sudo su
    #php环境搭建
    apt-get install apache2
    add-apt-repository -y ppa:ondrej/php
    apt update
    apt install  php7.0
    apt install -y mysql-server mysql-client
    apt-get install libapache2-mod-php7.0
    apt-get install php7.0-mysql
    dpkg-reconfigure  php7.0-mysql
    apt-get install php7.0-xml
    apt-get install php7.0-gd
    apt-get install phpmyadmin
    在安装过程中会要求选择Web server:apache2或lighttpd,使用空格键选定apache2,然后确定,下面界面输入你刚才安装Mysql时设置的密码,确定。再确认一次Mysql密码,确定。
    然后将phpmyadmin与apache2建立连接,
    sudo ln -s /usr/share/phpmyadmin  /var/www/html
    重启apache2
    sudo /etc/init.d/apache2  restart
     
    其他
    重启mysql
    /etc/init.d/mysql restart
     
     

    完全卸载apache2

    apt update

    apt upgrade

    apt remove apache2*

    apt autoremove

     

    搭建nginx服务

    apt install nginx
    service nginx start
    为使Nginx支持PHP,需要修改Nginx的配置文件
    vim /etc/nginx/sites-available/default
    添加以下内容
    server {
            listen       80;
            server_name  your_site_name.com;
            root /usr/share/nginx/html;
            index index.php index.html;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            error_page 404 /404.html;
            error_page 500 502 503 504 /50x.html;
    
            location = /50x.html {
                    root /var/www/html;
            }
    
            location ~ .php$ {
                    try_files $uri =404;
                    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
            }
    }

    修改完Nginx配置,需要重启Nginx

    service nginx restart

    放入一个info.php文件,打开http://本地IP/info.php测试php环境

    php文件代码如下

    <?php
    
    phpinfo();
    
    ?>
    

    最后,可以选择删除创建的info.php文件,避免被攻击者利用。

  • 相关阅读:
    sublimetext ruby 插件
    [C]goto statement, rarely been used. Deprecated???
    [C]union
    [C] Struct Test
    [C,Java,Python]Command Line Argument: argv, argc, sys.argv, args
    [Python]**otherInfo, *other
    [C]parameterized macros 带参数的宏
    [C]指针与结构变量
    [C]结构变量传递给函数
    [C]结构变量数组array of structure varibles
  • 原文地址:https://www.cnblogs.com/xiede/p/8999419.html
Copyright © 2011-2022 走看看