LoginSignup
5
5

More than 5 years have passed since last update.

ArchLinuxでLAMP環境作ってみた

Last updated at Posted at 2014-08-01

インストール

インストール
pacman -Sy apache php php-apache mariadb postfix

apache,php

conf/httpd.conf
+ LoadModule php5_module       modules/libphp5.so
+ AddHandler php5-script php
+ Include conf/extra/php5_module.conf

Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.の対応

conf/httpd.conf
- LoadModule mpm_event_module modules/mod_mpm_event.so
+ LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
conf/httpd.conf
- #LoadModule vhost_alias_module modules/mod_vhost_alias.so
+ LoadModule vhost_alias_module modules/mod_vhost_alias.so
- #Include conf/extra/httpd-vhosts.conf
+ Include conf/extra/httpd-vhosts.conf
  • 適宜extra/httpd-vhosts.confの編集

php,mysql

/etc/php/php.ini
- ;date.timezone =
+ date.timezone = Asia/Tokyo

PHP Fatal error: Call to undefined function mysql_connect()の対応

/etc/php/php.ini
- ;extension=mysql.so
+ extension=mysql.so

mysql.so はphp5.5ではdeprecatedだったような。一時しのぎ

postfix

error: open database /etc/postfix/aliases.db: No such file or directory
alias database unavailable の対応

newaliases

サービス登録

for s in mysqld httpd postfix
do
  systemctl enable $s
  systemctl start $s
done
  • DocumentRoot は /srv/http
  • mariadbは標準でutf-8

tips

cgi-scriptが使いたい場合

conf/httpd.conf
- #LoadModule cgi_module modules/mod_cgi.so
+ LoadModule cgi_module modules/mod_cgi.so
- #AddHandler cgi-script .cgi
+ AddHandler cgi-script .cgi
conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ...
+   <Directory "/srv/http/cgi">
+       Options +ExecCGI
+       Require all granted
+   </Directory>
</VirtualHost>

DocumentRootを変更したい場合

  • /srv/http/ から /srv/domainname/ に変更する場合

PHP Warning: Unknown: open_basedir restriction in effect. File(/srv/domainname/public/index.php) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/) in Unknown on line 0

/etc/php/php.ini
- open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/
+ ;open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/

digest認証 + .htaccess

httpd.conf
- #LoadModule auth_digest_module modules/mod_auth_digest.so
+ LoadModule auth_digest_module modules/mod_auth_digest.so
extra/httpd-vhosts.conf
  <Directory "/srv/httpd/admin/">
+   AllowOverride AuthConfig
    Require all granted   
  </Directory>
.htaccess
AuthType Digest
AuthName "member only"
AuthUserFile "/srv/digest/.htdigest"
require valid-user
.htdigest作成
$ htdigest -c /srv/digest/.htdigest "member only" user1
Adding password for user1 in realm member only.
New password:
Re-type new password:
$ cat .htdigest
user1:member only:e9fc3e4e6f5fd3a18be2006b6a1964b9

.htaccessでphp_value値の変更するために

.htaccess: php_value not allowed here

extra/httpd-vhosts.conf
  <Directory "/srv/httpd/admin/">
+   AllowOverride Options
    Require all granted   
  </Directory>

.htaccessでアップロードの設定変更

.htaccess
php_value max_execution_time 600
php_value post_max_size 50M
php_value upload_max_filesize 50M

userdir

extra/httpd-userdir.conf
  UserDir public_html
+ UserDir disabled
+ UserDir enabled username1 username2
chown :http /home/username[12]/
chmod g+rx /home/username[12]/

public_htmlをhttpユーザでアクセスできるように権限に気をつける。

その他

netstatがない場合

pacman -Sy net-tools
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5