Warning: Undefined variable $kind in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $vers in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $kind in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $vers in /home4/wgate/public_html/include/checkfunpdo.php on line 662
:::| 目前位置圖示目前位置:首頁圖示回首頁 | 主功能頁圖示相關問答
安裝舊版php5

[日期]:2024/06/03  [瀏覽人數]:1025

目前FreeBSD的PORT已經不再支援安裝PHP5,新的版本只支援安裝PHP8,

PHP5升至PHP7是一個大更版,PHP7升PHP8又是另一個障礙。

使用舊系統的客戶在多次勸說,都因為升級程式要一筆費用而未接受升級,但主機總有一天會故障。

若是不願意升級程式,主機要故障要換新,若安裝新的OS系統版本,會因已經無法安裝舊版本而無法使用,以前主機的BIOS能設定CSM,來支援舊系統,把硬碟換到新主機仍可以正常啟動執行。

今天裝了ASUS RS300-E12 RS4發現已經沒有這個功能可以設定相容舊作業系統了,因此就得想其辦法讓PHP5能裝在新主機上。

在FreeBSD的資料中,在10.1版的安裝光碟有UEFI的版本可以下載,雖然可以用來燒錄可以開機的USB或DVD,但是用燒錄好的開機碟開機,最後的結果就是當機。

由10.1~11.3都發生了能開機但卻無法安裝的問題,最後只是向版本12了,在版本12中,只有12.0還保有PHP5.6的PORT,因此也就只能挑戰FreeBSD12.0來安裝PHP5+Mysql5.X

FreeBSD12.0就可正常啟動,也能正常安裝FreeBSD,

注意的筆記如下:

1.注意不可以更新PORTS,在下載FreeBSD最好能下載含PORTS的USB .img

要如何將下載的.img燒錄至USB成可開機的安裝碟,可以下載balenaEtcher網址

https://etcher.balena.io/

這個工具在燒錄時可以直接選取網址進行燒錄,也可下載後再選取檔案燒錄,值得推薦。

2.安裝apache24會出現錯誤,texinfo的PORT有問題,可以至

https://ftp.gnu.org/gnu/texinfo/

下載https://ftp.gnu.org/gnu/texinfo/texinfo-6.5.tar.gz

將檔案上傳至安裝好的freeBSD,

可以先安裝proftpd,安裝好用FTP上傳至主機,也可在主機直fetch檔案,下載後執行

如下載至/tmp

cd /tmp

tar zxvf texinfo-6.5.tar.gz
cd texinfo-6.5
./configure
make install

安裝成功後,再重安裝apache24,應該就能順利安裝,接下來安裝php56、php56-extensions、mod_php56

MYSQL5.6安裝設定如下:

#cd /usr/ports/databases/mysql56-server

#make install clean BATCH=yes install

#sysrc mysql_enable=YES

# service mysql-server start

# mysql_secure_installation
mysql_secure_installation: [ERROR] unknown variable 'prompt=\u@\h [\d]>\_'

Securing the MySQL server deployment.

Connecting to MySQL server using password in '/root/.mysql_secret'

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:NO
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) :yes
New password:XXXX

Re-enter new password:XXXX
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!

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.7.24-log

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]> show databases;

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改密碼

root@localhost [(none)]> SET password = password('newpassword');
Query OK, 0 rows affected, 1 warning (0.00 sec)

接下來設定apache24的httpd.conf、及常用的安裝設定可以參考

另一文章:freebsd 12.3安裝筆記

最後測試將程式及mysql放入資料庫,程式出現了錯誤訊息:mysql_query要改用mysqli_query或PDO,

這時可以設定php.ini 讓錯誤訊息不要顯示,但,一但不顯示當程式出錯時便會造成不知道到底出現什麼錯????

可以將:error_reporting = E_ALL & ~E_NOTICE
改為:error_reporting = E_ALL & ~E_NOTICE^E_DEPRECATED

這樣就可以不顯示棄用的錯誤。