LoginSignup
2
2

More than 5 years have passed since last update.

CentOS7にLAMP環境を構築する

Last updated at Posted at 2016-07-25

参考サイト

isoの取得

ネットワーク周りについて

nmtui

デバイスの接続

  • デバイス一覧
    nmcli device

  • 特定のデバイス詳細を確認する
    nmcli device show ほげほげ

  • デバイスの有効化
    nmcli connection up ほげ

  • デバイスの無効化
    nmcli connection down ほげ

  • 自動接続の有効化
    nmcli con mod hoge connection.autoconnect "yes"

こんな書き方もできる

nmcli con mod eno16777728 connection.autoconnect "yes"
nmcli con mod eno16777728 ipv4.addresses "192.168.101.2/24"
nmcli con mod eno16777728 ipv4.method "manual"
  • 旧 cycconfig
    ip addr

  • ネットワークの再起動
    systemctl restart network.service

# ln -s -f /dev/null /etc/udev/rules.d/70-persistent-net.rules
# rm -rf /dev/.udev/
# rm -f /lib/udev/rules.d/75-persistent-net-generator.rules

PHP7

  • ライブラリなどをyumでインストールする
yum install git autoconf automake libtool openssl* wget gcc gcc-c++ bison libxml2-devel bzip2-devel curl-devel libwebp-devel libjpeg-devel libpng-devel libicu-devel libxslt-devel 
cd /usr/local/src
wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-2.5.8-9.puias6.x86_64.rpm
wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
rpm -ivh libmcrypt-2.5.8-9.puias6.x86_64.rpm
rpm -ivh libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm
wget https://github.com/skvadrik/re2c/releases/download/0.13.6/re2c-0.13.6.tar.gz
gunzip re2c-0.13.6.tar.gz
tar xvf re2c-0.13.6.tar
cd re2c-0.13.6
./configure
make
make install
  • PHP7インストール
git clone -b PHP-7.0.0 https://github.com/php/php-src.git
cd php-src
./buildconf --force

./configure \
--with-config-file-path=/usr/local/php7/etc \
--prefix=/usr/local/php7 \
--enable-mbstring \
--with-mysqli \
--with-pdo-mysql \
--with-mysqli \
--enable-pcntl \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-openssl \
--with-pcre-regex \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-curl \
--with-mhash \
--with-xsl \
--with-mcrypt \
--with-pear \
--enable-exif \
--enable-ftp \
--enable-sockets \
--with-gd \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--without-unixODBC \
--disable-posix \
--disable-sysvmsg \
--disable-sysvshm \
--disable-sysvsem \
--enable-intl \
--with-webp-dir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-png-dir=/usr/lib64

make && make install
  • パスを通す
export PATH=${PATH}:/usr/local/php7/bin/:/usr/local/php7/sbin/
source /etc/profile
  • php-fpmの設定 二つの設定ファイルを修正する
cp -p /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
vim /usr/local/php7/etc/php-fpm.conf

17a18
> pid = run/php-fpm.pid
81a83
> daemonize = yes

cp -p /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
vim /usr/local/php7/etc/php-fpm.d/www.conf

-user = nobody
-group = nobody
+user = nginx
+group = nginx

listen = /var/run/php-fpm.sock
listen.owner = nginx
listen.group = nginx
  • 起動スクリプト作成
cp -pi /usr/local/src/php-src/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp -pi /usr/local/src/php-src/sapi/fpm/php-fpm.service /lib/systemd/system/php-fpm.service
/usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/var/run/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target
chmod 755 /etc/init.d/php-fpm
systemctl daemon-reload
systemctl start php-fpm
systemctl enable php-fpm

nginx

  • 必要なツールをいれる
sudo yum install -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
  • ユーザーを作成する
    sudo useradd --shell /sbin/nologin nginx

  • インストール

wget http://nginx.org/download/nginx-1.8.1.tar.gz

./configure --prefix=/usr/local/nginx-1.8.1 \
--user=nginx \
--group=nginx \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--lock-path=/var/run/nginx.lock \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_stub_status_module

make
make install

ln -s /usr/local/nginx-1.8.1 /usr/local/nginx
  • 起動シェル
/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 起動
systemctl daemon-reload
systemctl start nginx.service
systemctl enable nginx.service

mysql

  • インストール
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum info mysql-community-server
yum -y install mysql-community-server
mysqld --version
  • 起動と停止
systemctl enable mysqld.service
systemctl start mysqld.service
systemctl stop mysqld.service
  • 初期設定

    • 初期パスワードの取得 /var/log/mysqld.logの中に出力されている
    • 初期設定シェルスクリプトの実行 mysql_secure_installation
2
2
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
2
2