[メモ] CentOS4.9/RHEL4(i386)で、LAMPP(5.6.23 2016-06-28)を動かす



phpinfo()にて、
> **System:**	`Linux localhost.localdomain 2.6.9-103.ELsmp #1 SMP Fri Dec 9 04:31:51 EST 2011 i686`

![image.png](https://qiita-image-store.s3.amazonaws.com/0/75594/802c2d58-1f1a-2478-04d9-ff869e111646.png)



# 概要

- 古いLinuxで、xamppを動かす。

    ```shell-session
[vagrant@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.9-103.ELsmp #1 SMP Fri Dec 9 04:31:51 EST 2011 i686 i686 i386 GNU/Linux
```

- `xampp-linux-5.6.23-0-installer.run (2016-06-28)` が32bit対応版最後のリリースなようなので、これを使う。(以降は、linuxは、64bitのみ. xampp-linux-x64-xxx)
- ただし、そのまま実行すると、`error while loading shared libraries: requires glibc 2.5 or later dynamic linker`と怒られる
- 対応したglibcなどのライブラリを /li1 に入れて、実行ファイル内の `/lib/ld-linux.so.2` を `/li1/ld-linux.so.2` に書き換える



# 環境

- Vagrant 2.10 + VirtualBox 5.2.8
- box: [`mt08/centos49-i386`](https://app.vagrantup.com/mt08/boxes/centos49-i386)

	```rb:Vagrantfile
	VM_MEMORY=4096
	VM_CORES=2

	Vagrant.configure("2") do |config|
	  config.vm.box = "mt08/centos49-i386"
	  config.vm.network "forwarded_port", guest: 80, host: 30080
	  config.vm.network "forwarded_port", guest: 443, host: 30443
	  config.vm.network "forwarded_port", guest: 3000, host: 33000
	  config.vm.network "public_network"

	  config.vm.provider :virtualbox do |vb|
			vb.cpus = VM_CORES
			vb.memory = VM_MEMORY
			vb.customize ["modifyvm", :id, "--ioapic", "on"]
	  end
	end
	```

- ファイル
    - [xampp-linux-5.6.23-0-installer.run](https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.6.23/)
    - https://github.com/mt08xx/centos49_gcc482/raw/master/binary/lampp/tools482-lib.tar.gz




# 手順

1. xamppをインストールする<br>`sudo ./xampp-linux-5.6.23-0-installer.run`

	```shell-session:参考
	[vagrant@localhost ~]$ sudo ./xampp-linux-5.6.23-0-installer.run
	----------------------------------------------------------------------------
	Welcome to the XAMPP Setup Wizard.
	----------------------------------------------------------------------------
	Select the components you want to install; clear the components you do not want
	to install. Click Next when you are ready to continue.
	XAMPP Core Files : Y (Cannot be edited)
	XAMPP Developer Files [Y/n] :n
	Is the selection above correct? [Y/n]: y
	----------------------------------------------------------------------------
	Installation Directory
	XAMPP will be installed to /opt/lampp
	Press [Enter] to continue:
	----------------------------------------------------------------------------
	Setup is now ready to begin installing XAMPP on your computer.
	Do you want to continue? [Y/n]: y
	----------------------------------------------------------------------------
	Please wait while Setup installs XAMPP on your computer.
	 Installing
	 0% ______________ 50% ______________ 100%
	 #########################################
	----------------------------------------------------------------------------
	Setup has finished installing XAMPP on your computer.
	[vagrant@localhost ~]$
	```

2. glibcのインストール　(tools482-lib.tar.gz) 

	```bash:コピペ
	sudo tar zxf ./tools482-lib.tar.gz -C /
	sudo ln -sf /opt/tools482/ /tools482
	sudo ln -sf /opt/tools482/lib /li1
	```

3. xamppの実行ファイルを書き換える

	```bash:こぴぺ
	cd /opt/lampp/
	for i in bin/* sbin/* ; do echo $i ; sudo sed -e 's@/lib/ld-linux.so.2@/li1/ld-linux.so.2@g' -i $i; done
	```


4. lamppスタート<br>`sudo /opt/lampp/lampp start`

	```shell-session:実行例
	[vagrant@localhost ~]$ sudo /opt/lampp/lampp start
	Starting XAMPP for Linux 5.6.23-0...
	XAMPP: Starting Apache...ok.
	XAMPP: Starting MySQL...ok.
	XAMPP: Starting ProFTPD...ok.
	[vagrant@localhost ~]$
	```

5. ファイヤーウォールを切る

	```bash:Stop_Firewall
	sudo /etc/rc.d/init.d/iptables stop
	sudo chkconfig iptables off
	chkconfig --list iptables
	```

6. ブラウザでアクセスする. `http://__IP_ADDRESS__/`
![image.png](https://qiita-image-store.s3.amazonaws.com/0/75594/23601ebd-cffe-37a5-8b5b-5f68450842ec.png)


7. `phpinfo()`確認<br>以下を実行して、`http://__IP_ADDRESS__/phpinfo.php`にアクセス

	```bash:ファイル作成
	cat << 'EOF' | sudo tee /opt/lampp/htdocs/phpinfo.php
	<?php phpinfo(); ?>
	EOF
	cat /opt/lampp/htdocs/phpinfo.php
	```

	![image.png](https://qiita-image-store.s3.amazonaws.com/0/75594/802c2d58-1f1a-2478-04d9-ff869e111646.png)

	> **System:**	`Linux localhost.localdomain 2.6.9-103.ELsmp #1 SMP Fri Dec 9 04:31:51 EST 2011 i686`


8. phpmyadmin<br>以下を実行して、`http://__IP_ADDRESS__/phpmyadmin`にアクセス

	```bash:phpmyadmin関係の設定のパーミッションを書き換える
	sudo sed -i -e 's/Require local/Require all granted/g' /opt/lampp/etc/extra/httpd-xampp.conf
	sudo /opt/lampp/lampp restart
	```
	![image.png](https://qiita-image-store.s3.amazonaws.com/0/75594/e9695bb0-6317-1fe2-9f11-487bd72efbdc.png)



9. lampp付属のcurlを使ってみる。

    ```txt:Version比較
CentOS4付属: curl 7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6
xampp  付属: curl 7.45.0 (i686-pc-linux-gnu)     libcurl/7.45.0 OpenSSL/1.0.2h zlib/1.2.8
```

    ```shell-session:tlstest
[vagrant@localhost ~]$ curl https://tlstest.paypal.com
curl: (35) error:0D0890A1:asn1 encoding routines:ASN1_verify:unknown message digest algorithm
[vagrant@localhost ~]$ /opt/lampp/bin/curl https://tlstest.paypal.com
PayPal_Connection_OK[vagrant@localhost ~]$
```