serversman@vpsのエントリー(メモリ1GB)のサーバ設定について

serversman@vpsのエントリー(メモリ1GB)のサーバ設定について

ブログセットでも良いかな?と思ったけど、PHPやMySQLのバージョンが古いのでlaravelなど新しいフレームワークが使えないので自分でセットアップする事にした。
せっかくなので、CentOS7にしようかと思ったがyum updateがマトモに走らないらしい。

# アップデートすると
yum update

# エラーで何も出来ない…。
Error: systemd conflicts with initscripts-9.49.17-1.el7_0.1.x86_64
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

諦めて、CentOS6.5にする。

1, 公開鍵方式にログイン方法を変更
ここいらへんは、debian系でもredhat系でも同じ

RaspberryPiのsshにパスワード無しでログインする方法(公開鍵認証方式とは)

2, コマンドプロンプトをログインユーザとフルパスに変更
vi ./bashrc

# コマンドプロンプトをログインユーザとフルパスに変更
export PS1=”[\u@\w]\\$ ”

# 即座に反映させる
[root@/var/log]# source ~/.bashrc

3, nginxをインストール(apacheは止める)

# 標準レポジトリにはnginxは無いので追加する。
vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

[root@/etc/yum.repos.d]# yum install nginx

# apache停止&nginx開始
[root@/etc/yum.repos.d]# service httpd stop
Stopping httpd: [ OK ]
[root@/etc/yum.repos.d]# service nginx start
Starting nginx: [ OK ]

# apacheの自動起動を止める。
chkconfig httpd off

4, phpをインストールする
centosのレポジトリは、なぜか低いバージョンしかないので、追加レポジトリからインストールする。

# システムにepelとremiのリポジトリを追加
% sudo rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
% sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

# PHP本体と関連パッケージをインストール
yum install –enablerepo=remi –enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

# nginxからphpを実行できるようにする
yum -y install php56-php-fpm.x86_64

vi /opt/remi/php56/root/etc/php-fpm.d/www.conf
– user = apache
+ user = nginx

– group = apache
+ group = nginx

#ドキュメントルートなど設定を書き換える。
/etc/nginx/conf.d/default.conf
location / {
– root /usr/share/nginx/html;
+ root /var/www;
– index index.html index.htm;
+ index index.php;
}

– #location ~ \.php$ {
– # root html;
– # fastcgi_pass 127.0.0.1:9000;
– # fastcgi_index index.php;
– # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
– # include fastcgi_params;
– #}
+ location ~ \.php$ {
+ root /var/www;
+ fastcgi_pass 127.0.0.1:9000;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
+ include fastcgi_params;
+ }

# php-fpmの自動起動
/etc/init.d/php56-php-fpm start
chkconfig php56-php-fpm on

# nginxの再起動
/etc/init.d/nginx restart

# phpinfo()を表示してみる
vi /var/www/index.php
http://サーバのIP/ 5, mysqlをインストールする yum --enablerepo=remi install -y mysql-server # (自動)起動する service mysqld start chkconfig mysqld on # rootの初期パスワードを設定 /usr/bin/mysqladmin -u root password 'new-password' # mysqlにログインできるか確認 mysql -u root -p パスワード入力 6, phpmyadminをインストール http://qiita.com/wakaba260/items/9b06c4d64239a2b0bd48 yum -y install --enablerepo=remi gd-last yum -y install --enablerepo=remi-php56 php-gd yum -y install --enablerepo=remi ImageMagick-last yum -y install --enablerepo=remi-php56 phpMyAdmin # インストールされた事を確認 /usr/share/phpMyAdmin The mbstring extension is missing. Please check your PHP configuration. /etc/php.iniを修正 yum --enablerepo=epel install -ylibmcrypt t1lib recode dejavu-sans-fonts libtidy yum --enablerepo=remi install -y php-common php-gmp phpmyadmin 7, WordPressのインストール