ubuntu下面配置nginx+phpmyadmin

用 apt-get install 方式安装nginx ,php7,mysql等

  • sudo apt-get install nginx
  • sudo add-apt-repository ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get install php7.0 php-fpm php-mysql php-mbstring

php7.0的 配置环境在 /etc/php/7.0/fpm里,有php-fpm.confphp.ini两个重要的配置文件

  • php.ini:
  1. 设置 short_open_tag = On
  2. extension_dir = "/usr/lib/php/20151012",目录通过catfish搜索mysql.so找到,用于安装各种扩展,应该是apt-get install时自动放入。
  3. 开启对mysql的支持:extension=mysqli.soextension=pdo_mysql.so
  4. 设置”cgi.fix_pathinfo=0”
  • php-fpm.conf:
    在里面可以看到 include=/etc/php/7.0/fpm/pool.d/*.conf,里面有www.conf文件
  1. 找到“listen” : listen = /run/php/php7.0-fpm.sock,配置nginx时会用到
  2. 重启php-fpm:sudo service php-fpm restart

nginx的配置是在 /etc/nginx/里,在sites-enabled目录下建立本次要用到的phpmyadmin配置文件phpmyadmin.conf:

server{
listen 80;
server_name 127.0.0.1 localhost;
access_log /home/leoatchina/www/phpmyadmin/access.log;
error_log /home/leoatchina/www/phpmyadmin/error.log;
root /home/leoatchina/www;
location / {
index index.html;
root /home/leoatchina/www;
}
location /phpmyadmin{
index index.php;
root /home/leoatchina/www/phpmyadmin;
try_files $uri $uri/ /phpmyadmin/index.php?$args;
}
location ~ .php$ {
root /home/leoatchina/www;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .(htm|html|gif|jpg|png|js|css)$ {
root /home/leoatchina/www;
}
}

- 重启nginx:``sudo service nginx restart``

phpmyadmin的配置
> 1. 我的www目录是``/home/leoatchina/www``
2. 首先要chmod和chown
3. 在根目录下``cp config.sample.inc.php config.inc.php``
4. 修改``$cfg['Servers'][$i]['user']``和``$cfg['Servers'][$i]['password']``为msyql里设置好的值
5. 为了解决“语言包报错”问题,修改``libraries``目录里的config.default.php大概**2566**行为 ``$cfg['Lang'] = 'en';``
点赞