Warning: Cannot modify header information - headers already sent in /home/dacelo/html/DocumentRoot/wp-includes/feed-rss2.php on line 8
/etc/httpd/conf/httpd.conf それぞれ一体何が違うのかというと…。 リクエストに対して子プロセスを起動していく方式=prefork という事のようです。 じゃあ自分が動かしているApacheは一体どっちの方式で動いているのか? それを調べるコマンドはこちら。 環境によってはapache部分が違います。 いずれにせよ、これでバージョン情報がズラズラと返ってきますが、その中に という記述があります。この場合はprefork型ですね。 という箇所を探してください。 これで、Apacheの設定をちゃんとピンポイントで適切に行なうことができるようになって、めでたしめでたし。 No related posts. Related posts brought to you by Yet Another Related Posts Plugin. サーバをDreamHost(米サーバ。糞重い)からDTIのVPS(国産VPS)に移転しました。 ソースからコンパイルするのは面倒だし、PHPのバージョンと依存関係があったりするそうなので、peclでインストールすることにしました。 お。エラーです。PAYHが通ってない、と言われていますが、どうやらいくつかのモジュールが足りないようです。 もう一度試行。 まだエラーが出ます。 成功しました。 以上! No related posts. Related posts brought to you by Yet Another Related Posts Plugin. ちょっとこのDreamHostのサーバーが重くて仕方ない、あとWordPressサイトで404やら500が発生しすぎなので、引っ越しを画策しています。 そこでとりあえず、最近はやりのVPSサーバーを借りてみたんですが、色々設定してみたところ、ドメインを設定してApacheでルートを設定させるところまでは出来たんですが、肝心のPHPが動かない。こんなエラーが出ます。 Warning: Unknown: open_basedir restriction in effect. File(/home/user/html/index.php) is not within the allowed path(s): (/tmp/:/var/lib/php/session/) in Unknown on line 0 これは、PHPの設定で、PHPを動かすベースディレクトリを設定してしまっているためで、「そのパスではPHPが動かない」と怒られている状態のようです。 /etc/php.ini を開いて… となっているところをコメントアウトして Apacheを再起動すればOKです。 Related posts:
を見ると、KeepAliveとかMaxClientとかの設定をする部分が、2つあることに気付きます。 # prefork MPM
StartServers 2
MinSpareServers 5
MaxSpareServers 20
ServerLimit 32
MaxClients 32
MaxRequestsPerChild 0
# worker MPM
StartServers 2
MaxClients 30
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
apacheの prefork.cとworker.cの違い
リクエストをスレッドにより対応していく方式=worker
これは、コンパイル時にオプションで設定するんですが、おそらくデフォルトではprefork型のようです。どっちで動いているかを調べる
もしくは、コンパイル情報の
-D APACHE_MPM_DIR=”server/mpm/prefork”CentOSでAPCをインストール(DTIのVPS)
しかしWordPressの動作がそんなに速くならなかったので、PHP Acceleratorを何か入れることにしました。
VPSはルート権限があるのでこういうことも試せていいですね。
APCのインストール手順
[root@dti-vps ]# pecl install APC
downloading APC-3.0.19.tgz ...
Starting to download APC-3.0.19.tgz (115,735 bytes)
.........................done: 115,735 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20050922
Zend Extension Api No: 220051025
Use apxs to set compile flags (if using APC with Apache)? [yes] : yes
building in /var/tmp/pear-build-root/APC-3.0.19
running: /tmp/tmpu4u0H7/APC-3.0.19/configure --with-apxs
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
ERROR: `/tmp/tmpu4u0H7/APC-3.0.19/configure --with-apxs' failed
# yum -y install gcc gcc-c++[root@dti-vps ]# pecl install APC
(略)
Sorry, I was not able to successfully run APXS. Possible reasons:
1. Perl is not installed;
2. Apache was not compiled with DSO support (--enable-module=so);
3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs
The output of apxs follows
/tmp/tmpuAcvYD/APC-3.0.19/configure: line 3232: apxs: command not found
configure: error: Aborting
ERROR: `/tmp/tmpuAcvYD/APC-3.0.19/configure --with-apxs' failed
http-develも必要のようです。# yum install httpd-devel[root@dti-vps ]# pecl install APC
略
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).
running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-APC-3.0.19" install
Installing shared extensions: /var/tmp/pear-build-root/install-APC-3.0.19/usr/lib/php/modules/
running: find "/var/tmp/pear-build-root/install-APC-3.0.19" -ls
241026596 4 drwxr-xr-x 3 root root 4096 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19
241026657 4 drwxr-xr-x 3 root root 4096 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19/usr
241026658 4 drwxr-xr-x 3 root root 4096 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19/usr/lib
241026659 4 drwxr-xr-x 3 root root 4096 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19/usr/lib/php
241026660 4 drwxr-xr-x 2 root root 4096 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19/usr/lib/php/modules
241026656 408 -rwxr-xr-x 1 root root 412650 9月 29 09:41 /var/tmp/pear-build-root/install-APC-3.0.19/usr/lib/php/modules/apc.so
Build process completed successfully
Installing '/var/tmp/pear-build-root/install-APC-3.0.19//usr/lib/php/modules/apc.so'
install ok: channel://pecl.php.net/APC-3.0.19
You should add "extension=apc.so" to php.ini
php.iniを開いて、「extension=apc.so」の一行を追加して、ApacheをリスタートすればOKです。[root@dti-vps ]# pecl install
[PHP]
extension=apc.so
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
[root@dti-vps ]# service httpd restart
APC(Alternative PHP Cache) インストール | php MySQL apache などの設定メモ
APC インストール時のエラー | php MySQL apache などの設定メモ
エラーや試行錯誤の記録も公開してくれてると、エラーメッセージでググったときに助かりますね
Installing PHP APC on GNU/Linux Centos 5 | 2bits.com, Inc. – Drupal Performance Optimization, Development, Managed Hosting, Customization and Consulting
Tatsuya Blog » [WordPress]ServerMan@VPSでの高速化のためのチューニング
Related posts brought to you by Yet Another Related Posts Plugin.]]>open_basedir = /tmp/:/var/lib/php/session/
; open_basedir = /tmp/:/var/lib/php/session/
service httpd restart
Related posts brought to you by Yet Another Related Posts Plugin.
]]>2分に1回、死活監視をするプログラムを走らせてたんですけど、それだとApacheのログがそのアクセスで一杯になっちゃうんですね。
あんまりアクセスのないサイトだと、9割方それで埋まります…。
そこで今日のお題。
CustomLog logs/access_log common env=!nolog SetEnvIf Remote_Addr 192.168.1. nolog SetEnvIf Remote_Addr 192.168.2. nolog
これで当該サーバからのアクセスはログに記録されなくなり、めでたしめでたし。
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>.htaccessでの指定で、HTTPのアクセスをHTTPSにリダイレクトします。
RewriteEngine on RewriteCond %{SERVER_PORT} ^443$ RewriteRule ^/home/dacelo/html/(.*) http://%{HTTP_HOST}/$1 [R=301,L]
解説
443ポート、すなわちHTTPSに来たアクセスを、HTTPにリライトしています。
逆にHTTP→HTTPSにする場合は、リライトルールを 80番ポートにして、HTTPSに送るようにすればOKです。
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Apacheが突然死しているようなので再起動してみたら、どうもおかしい。
一旦立ち上がったんだけど、もう一度リスタートかけようとすると、こんなエラーメッセージが出て、停止もできない。
これは通常、ポート80を他のプロセスが使用しているときに出るエラーメッセージ。
どうやらApacheが異常終了したせいで、古いApacheのプロセスが残っているのを、新しいApacheが「80番ポートが使われている!?」と誤解しているらしい。
lsofでhttpのプロセスを調べ、一つずつ強制KILLすると解決する。
こいつらが80番ポートに居残っているプロセス。
キル!キル!
全部キルしたらすっきりリスタートできるようになりました。
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>apacheのServerAliasには、果たしてどのくらいまで登録できるのか?
検証してみました。
【結論:8719byteまでOK】
ドメイン数ではなく、文字数で限界が設定されていました。
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
]]>皆様、明けましておめでとうございます。いやぁ、早いものでこのブログも2年目なんですね。今年もちょぼちょぼと更新してまいりますのでよろしくお願いいたします。
さて、今回はsafe_modeについて。
phpのsafe_modeは、PHP6で正式に削除されることが決定しているので、使わないことが推奨されているんですが、まぁ諸々の事情で使わざるを得ないことがあります。
通常、php.iniでon/offを切り替えるんですが、使うんであれば限定的に、あるサイトのバーチャルホストの中だけで有効にしたい、というような気持ちってありますね。
そんなときは、httpd.confにて次のように書きます。
<VirtualHost 192.168.11.111:80> DocumentRoot /home/blog.dacelo.info/ ServerName blog.dacelo.info <Directory "/home/blog.dacelo.info"> AllowOverride All Options ExecCGI FollowSymlinks </Directory> <IfModule mod_php5.c> php_admin_flag safe_mode on </IfModule> </VirtualHost>
これで、blog.dacelo.infoの中でだけsafe_modeがonになりました。
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Webサイトの移転で必須のRedirect設定、.htaccessでやることが多いですが、
Apacheの設定ファイル・httpd.confでやってしまうと一括指定できて早いです。
<VirtualHost 192.168.0.200> ServerName old.example.jp Redirect permanent / http://www.example.com/ </VirtualHost>
上記例では、使わなくなったサブドメイン「old」をwwwに恒久的リダイレクトさせています。
複数のサブドメインを指定する際には、ServerAliasで設定すればOKです。

No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
]]>Apacheを再起動した際に、
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
というエラーが出る場合がある。
これでも起動はするので、Apache自体は動くのだが、エラーをそのままにしておくのは気持ちが悪いし、あとあと問題を引き起こす可能性が高い。
日本語訳をすると
ServerNameに127.0.0.1を使用した、FQDN(完全に適切なドメイン名)が確定できませんでした。
といった感じか。
このエラーは、/etc/hosts にlocalhost以外に自分で設定したホスト名が、Apacheの設定ファイルに定義されていないために発生する。
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 dacelo localhost.localdomain localhost
と書いた場合、/etc/httpd/conf/httpd.conf のServerNameの設定にも次のように書いておく。
# ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If this is not set to valid DNS name for your host, server-generated # redirections will not work. See also the UseCanonicalName directive. # # If your host doesn't have a registered DNS name, enter its IP address here. # You will have to access it by its address anyway, and this will make # redirections work in a sensible way. # #ServerName www.example.com:80 ServerName dacelo:80
Related posts:
Related posts brought to you by Yet Another Related Posts Plugin.
]]>