韌館-LearnHouse

[Raspberry Pi 3] Ubuntu-mate 16.04 Apache, PHP 7和MySQL安裝

當初買樹梅派就是想要架一台小型不占空間,又省電的一台Server
首要工作就是把我的Blog移回來自己管理,所以LAMP(Linux, Apache, MySQL, PHP)是必要的

安裝MySQL

#apt-get -y install mysql-server mysql-client
下列的額外套件將被安裝:
libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.0-5 libfcgi-perl libhtml-template-perl linux-firmware mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7
mysql-server-core-5.7
建議套件:
libipc-sharedcache-perl mailx tinyca
下列【新】套件將會被安裝:
libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.0-5 libfcgi-perl libhtml-template-perl mysql-client mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server
mysql-server-5.7 mysql-server-core-5.7
下列套件將會被升級:
linux-firmware


MySQL的安全性設定,可以參考我標註為紅色的設定

#mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

安裝Apache

#apt-get -y install apache2
下列的額外套件將被安裝:
apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
建議套件:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
下列【新】套件將會被安裝:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0

安裝PHP 7

#apt-get -y install php7.0 libapache2-mod-php7.0
下列的額外套件將被安裝:
php-common php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
建議套件:
php-pear
下列【新】套件將會被安裝:
libapache2-mod-php7.0 php-common php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline

使MySQL支援PHP

#apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext
下列的額外套件將被安裝:
libc-client2007e libmcrypt4 librecode0 libtidy-0.99-0 libxmlrpc-epi0 mlock php-xml php7.0-xml ttf-dejavu-core
建議套件:
uw-mailutils libmcrypt-dev mcrypt memcached
下列【新】套件將會被安裝:
libc-client2007e libmcrypt4 librecode0 libtidy-0.99-0 libxmlrpc-epi0 mlock php-gettext php-imagick php-memcache php-pear php-xml php7.0-curl php7.0-gd
php7.0-imap php7.0-intl php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xml php7.0-xmlrpc php7.0-xsl ttf-dejavu-core

安裝phpMyAdmin

#apt-get -y install phpmyadmin
下列的額外套件將被安裝:
dbconfig-common dbconfig-mysql libjs-sphinxdoc libjs-underscore php-phpseclib php-tcpdf
建議套件:
php-libsodium php-gmp
下列【新】套件將會被安裝:
dbconfig-common dbconfig-mysql libjs-sphinxdoc libjs-underscore php-phpseclib php-tcpdf phpmyadmin

安裝過程自動帶出設定,一樣可以參考我標註為紅色的設定

Please choose the web server that should be automatically configured to run phpMyAdmin.
Web server to reconfigure automatically: apache2
The phpmyadmin package must have a database installed and configured before it can be used. This can be optionally handled with dbconfig-common.
If you are an advanced database administrator and know that you want to perform this configuration manually, or if your database has already been
installed and configured, you should refuse this option. Details on what needs to be done should most likely be provided in /usr/share/doc/phpmyadmin.
Otherwise, you should probably choose this option.
Configure database for phpmyadmin with dbconfig-common? Yes
Please provide a password for phpmyadmin to register with the database server. If left blank, a random password will be generated.
MySQL application password for phpmyadmin: ********
Password confirmation: ********

重啟Apache

#systemctl restart apache2

管理網址
http://10.0.0.49/phpmyadmin

另外安裝

安裝Opcache + APCu PHP cache來加速PHP
apt-get -y install php7.0-opcache php-apcu

啟動SSL
a2enmod ssl
a2ensite default-ssl

2017年10 月 posted by admin in Linux and have No Comments

Place your comment

Please fill your data and comment below.
名稱:
信箱:
網站:
您的評論: