(1) treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ sudo apt-get install apache2 下列的額外套件將被安裝: 取得 1,342 kB 用了 7秒 (189 kB/s)
(2) $ sudo systemctl start apache2 $ sudo systemctl enable apache2 (3) $ sudo systemctl status apache2 (4) http://localhost/ 成功看到預設網頁 Apache2 Ubuntu Default Page
(5)
treehrt@treehrt-BM6AE-BM1AE-BP1AE:~$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
: 下列的額外套件將被安裝:
libapache2-mod-php7.0 libmcrypt4 php-common php7.0 php7.0-cli php7.0-common php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline 建議套件: php-pear libmcrypt-dev mcrypt 下列【新】套件將會被安裝: libapache2-mod-php libapache2-mod-php7.0 libmcrypt4 php php-common php-mcrypt php-mysql php7.0 php7.0-cli php7.0-common php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline 升級 0 個,新安裝 15 個,移除 0 個,有 455 個未被升級。 需要下載 3,819 kB 的套件檔。 此操作完成之後,會多佔用 14.0 MB 的磁碟空間。 是否繼續進行 [Y/n]? [Y/n] y :
設定 php-common (1:35ubuntu6.1) ...
設定 php7.0-common (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/calendar.ini with new version Creating config file /etc/php/7.0/mods-available/ctype.ini with new version Creating config file /etc/php/7.0/mods-available/exif.ini with new version Creating config file /etc/php/7.0/mods-available/fileinfo.ini with new version Creating config file /etc/php/7.0/mods-available/ftp.ini with new version Creating config file /etc/php/7.0/mods-available/gettext.ini with new version Creating config file /etc/php/7.0/mods-available/iconv.ini with new version Creating config file /etc/php/7.0/mods-available/pdo.ini with new version Creating config file /etc/php/7.0/mods-available/phar.ini with new version Creating config file /etc/php/7.0/mods-available/posix.ini with new version Creating config file /etc/php/7.0/mods-available/shmop.ini with new version Creating config file /etc/php/7.0/mods-available/sockets.ini with new version Creating config file /etc/php/7.0/mods-available/sysvmsg.ini with new version Creating config file /etc/php/7.0/mods-available/sysvsem.ini with new version Creating config file /etc/php/7.0/mods-available/sysvshm.ini with new version Creating config file /etc/php/7.0/mods-available/tokenizer.ini with new version 設定 php7.0-json (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/json.ini with new version 設定 php7.0-opcache (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/opcache.ini with new version 設定 php7.0-readline (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/readline.ini with new version 設定 php7.0-cli (7.0.32-0ubuntu0.16.04.1) ... update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in auto mode update-alternatives: using /usr/bin/phar7.0 to provide /usr/bin/phar (phar) in auto mode update-alternatives: using /usr/bin/phar.phar7.0 to provide /usr/bin/phar.phar (phar.phar) in auto mode Creating config file /etc/php/7.0/cli/php.ini with new version 設定 libapache2-mod-php7.0 (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/apache2/php.ini with new version Module mpm_event disabled. Enabling module mpm_prefork. apache2_switch_mpm Switch to prefork apache2_invoke: Enable module php7.0 設定 libapache2-mod-php (1:7.0+35ubuntu6.1) ... 設定 libmcrypt4 (2.5.8-3.3) ... 設定 php7.0 (7.0.32-0ubuntu0.16.04.1) ... 設定 php (1:7.0+35ubuntu6.1) ... 設定 php7.0-mcrypt (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/mcrypt.ini with new version 設定 php-mcrypt (1:7.0+35ubuntu6.1) ... 設定 php7.0-mysql (7.0.32-0ubuntu0.16.04.1) ... Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version 設定 php-mysql (1:7.0+35ubuntu6.1) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for libapache2-mod-php7.0 (7.0.32-0ubuntu0.16.04.1) ... (6)
$ sudo vi /etc/apache2/mods-enabled/dir.conf
$ cat /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet (7)$ sudo systemctl restart apache2
(8)$ sudo systemctl status apache2
● apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since 一 2018-12-17 20:38:12 CST; 18s ago Docs: man:systemd-sysv-generator(8) Process: 12791 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCES Process: 12817 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCC CGroup: /system.slice/apache2.service ├─12835 /usr/sbin/apache2 -k start ├─12838 /usr/sbin/apache2 -k start ├─12839 /usr/sbin/apache2 -k start ├─12840 /usr/sbin/apache2 -k start ├─12841 /usr/sbin/apache2 -k start └─12842 /usr/sbin/apache2 -k start 12月 17 20:38:11 treehrt-BM6AE-BM1AE-BP1AE systemd[1]: Starting LSB: Apache2 web 12月 17 20:38:11 treehrt-BM6AE-BM1AE-BP1AE apache2[12817]: * Starting Apache ht 12月 17 20:38:11 treehrt-BM6AE-BM1AE-BP1AE apache2[12817]: AH00558: apache2: Cou 12月 17 20:38:12 treehrt-BM6AE-BM1AE-BP1AE apache2[12817]: * 12月 17 20:38:12 treehrt-BM6AE-BM1AE-BP1AE systemd[1]: Started LSB: Apache2 web lines 1-21/21 (END) (7) http://localhost/index.php
成功的看到
PHP Version 7.0.32-0ubuntu0.16.04.1(8)設計mysql連線程式如下: /var/www/html$ cat m1.php (9) http://localhost/m1.php 程式執行結果如下: Connected to MySQL OK! 0:201801:小新:xxxx
: 19:712003:王一志:B301
: 30:c922006:蛇:xxxx
|