美文网首页
Ubuntu配置Apache2, PHP,phpMyadmin,

Ubuntu配置Apache2, PHP,phpMyadmin,

作者: 2010jing | 来源:发表于2017-11-07 23:45 被阅读109次

install apache2

    $ sudo apt-get update
    $ sudo apt-get install apache2
启动,重启,停止apache服务
Task: Start Apache 2 Server /启动apache服务
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
Task: Restart Apache 2 Server /重启apache服务
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
Task: Stop Apache 2 Server /停止apache服务
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop

install MySQL

    $ sudo apt-get update
    $ sudo apt-get install mysql-server
    $ mysql_secure_installation

设置Ubuntu允许远程连接MySQL
需要修改 Mysql 配置文件

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
  将 bind-address = 127.0.0.1 这一行注释掉, 即修改为:
  #bind-address = 127.0.0.1

修改 root 密码

步骤一:登录mysql

sudo mysql -u root -p

步骤二:查看user表:

select user, plugin from mysql.user;
image.png

发现root的plugin并不是本地密码,因此需要修改它,但由于MySQL5.6.6版本之后增加了密码强度验证插件validate_password,相关参数设置的较为严格。

如果要设置为简单密码,则需修改密码规则的配置,参考博客:https://blog.csdn.net/kuluzs/article/details/51924374

步骤三:修改mysql参数配置:

set global validate_password_policy=0;
set global validate_password_mixed_case_count=0;
set global validate_password_number_count=3;
set global validate_password_special_char_count=0;
set global validate_password_length=3;

步骤四:修改root密码

update mysql.user set authentication_string=PASSWORD('123'), plugin='mysql_native_password' where user='root';

步骤五:刷新

flush privileges;

到此 Mysql-Server 端配置就完成了.

install phpMyadmin

    $ sudo apt install phpmyadmin

软件安装在了/usr/share/下,所以你的phpmyadmin在/usr/share下可以找到.
建立一个软连接,使得第三步中显示的文件和/var/www/html下的某个文档链接起来,回到/var/www/html,输入一下代码

$ sudo ln -s /usr/share/phpmyadmin phpmyadmin
mbstring.png

解决办法:

# php.ini 路径 : :/etc/php/7.0/apache2/php.ini
sudo apt-get install php7.0-mbstring
phpMyadmin 隐藏 数据库

找到了phpmyadmin/config.inc.php文件,位置在

/etc/phpmyadmin

修改

$cfg['Servers'][$i]['hide_db']       = '';          // Database name to be hidden from listings

我们只要把information_schema填写在引号里面就好了。
填玩以后重新登录到PHPMyAdmin,会发现这个数据库已经不会显示了。

如果要隐藏多个可以用"|"来隔开其他数据库名,例如:

$cfg['Servers'][$i]['hide_db'] = '(information_schema|phpmyadmin|mysql| performance_schema | sys)';

只是为了安全的目的隐藏起来。

如果想要隐藏全部以a开头的数据库,可以使用'^a'。

apache2 配置 phpmyadmin

进入到 目录 /etc/apache2/sites-available
从默认配置复制一份

sudo cp 000-default.conf phpmyadmin.conf

修改内容,修改 DocumentRoot

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/phpmyadmin

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

重启 apache2

sudo systemctl restart apache2.service

ubuntu设置ssh登陆

install openssh-server
$ sudo apt-get install openssh-server
启动服务。
$ sudo service ssh start
或者是:
$ sudo /etc/init.d/ssh restart

关闭了ssh server的服务,不再允许别人通过ssh远程登陆你的操作系统

$ sudo service ssh stop

安装ftp服务器

sudo apt-get update
sudo apt-get install vsftpd 

执行完该步骤,vsftpd服务已经安装

  1. 修改ftp的配置文件 /etc/vsftpd.conf

(a)向文件中添加如下内容:


userlist_deny=NO 
userlist_enable=YES 
#允许登录的用户 
userlist_file=/etc/allowed_users 
seccomp_sandbox=NO 
local_enable=YES 
#设置文件上传 
write_enable=YES 
#使用utf8
utf8_filesystem=YES
修改ftp的配置文件

使文件中的"local_enable=YES"保存。

(b)新建/etc/allowed_users文件

sudo vim /etc/allowed_users

假设我只想让xuanxufeng和root访问ftp服务器,那么输入xuanxufeng,root-->保存OK!以后还有其它用户使用ftp时直接添加用户名就可以了!

(c)使用vim查看/etc/ftpusers文件中的内容

sudo vim /etc/ftpusers

打开这个文件后,看一看有没有uftp这个用户名,如果没有,就直接退出。如果有就删除uftp,因为这个文件中记录的是不能访问FTP服务器的用户清单。

重启vsftp服务器。

  1. 启动, 停止, 重启服务
sudo /etc/init.d/vsftpd start
sudo /etc/init.d/vsftpd stop
sudo /etc/init.d/vsftpd restart
  1. 访问ftp服务器
sudo ftp 127.0.0.1

浏览器访问

ftp://127.0.0.1 

或者

ftp://localhost

远程访问时使用实际ip:

 ftp://your_ip 

ubuntu16.04 無法安裝 google chrome

下载

$ wget -c https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

安装

$ sudo dpkg -i google-chrome-stable_current_amd64.deb

安装遇到

把電腦重灌ubuntu 16.04 ,去google官網下載chrome穩定版後,點擊檔案後,按安裝卻一直卡住沒有反應
這個情況,是某個相依的套件沒有事先安裝,所以導致發生例外了,

只要執行下面的指令,就可以幫你把相依的套件補齊了

$ sudo apt-get install -f

若上面還不能解決,就執行下面的指令,讓安裝系統恢復可運作的狀態

$ sudo apt-get remove chrome-chrome-stable

相关文章

网友评论

      本文标题:Ubuntu配置Apache2, PHP,phpMyadmin,

      本文链接:https://www.haomeiwen.com/subject/popsmxtx.html