[LINUX] LEMP stack
系統資訊
查一下版本資訊,使用
cat /etc/os-release
[root@localhost tmp]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
安裝NGINX
[root@localhost tmp]# sudo yum install nginx
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: ftp.cuhk.edu.hk
* extras: ftp.cuhk.edu.hk
* updates: ftp.cuhk.edu.hk
No package nginx available.
Error: Nothing to do
要先安裝 EPEL repo 才抓的到
yum install epel-release
成功了!檢查看看NGINX狀態
service nginx start
service nginx status
設定為開機時自動啟動
[root@localhost tmp]# sudo systemctl enable nginx
--------------下面這段不重要-------------
在沒有圖形介面下
可以用 traceroute 或 links 或 wget 之類的來 檢查loacal host
之後會補上利用DNS 讓外部可以直接連到VM中的localhost 的設定方法
可以用 traceroute 或 links 或 wget 之類的來 檢查loacal host
之後會補上利用DNS 讓外部可以直接連到VM中的localhost 的設定方法
yum install traceroute
安裝PHP
[root@localhost nginx]# yum -y install php
成功!
[root@localhost nginx]# php -v
PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@localhost nginx]# nginx -v
nginx version: nginx/1.10.2
安裝 MYSQL
yum update
sudo rpm -Uvh mysql57-community-release-el6-n.noarch.rpm
找不到?
yum install wget
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
找到了!抓下來…
安裝
yum localinstall mysql57-community-release-el7-7.noarch.rpm
確定已經裝好了
yum repolist enabled | grep "mysql.*-community.*"
安裝發行版…
yum install mysql-community-server
啟動
[root@localhost nginx]# service mysqld start
確認狀態
[root@localhost nginx]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 三 2017-05-03 13:55:19 CST; 1min 32s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 55481 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 55407 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 55484 (mysqld)
CGroup: /system.slice/mysqld.service
└─55484 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
5月 03 13:55:13 localhost.localdomain systemd[1]: Starting MySQL Server...
5月 03 13:55:19 localhost.localdomain systemd[1]: Started MySQL Server.
PHP + MYSQL + NGINX 版本資訊
[root@localhost nginx]# php -v; mysql -V; nginx -v
PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper
nginx version: nginx/1.10.2
php-fpm
好像不用安裝了 後面版本有內建 不過設定還是要做
yum install php-fpm php-mysql
查看 php-fpm 的啟動設定
[root@localhost nginx]# systemctl list-unit-files | grep php-fpm
php-fpm.service disabled
改成開機啟動
[root@localhost nginx]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
啟動然後檢查
[root@localhost nginx]# systemctl start php-fpm
[root@localhost nginx]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since 三 2017-05-03 14:18:30 CST; 9s ago
Main PID: 55678 (php-fpm)
Status: "Ready to handle connections"
CGroup: /system.slice/php-fpm.service
├─55678 php-fpm: master process (/etc/php-fpm.conf)
├─55679 php-fpm: pool www
├─55680 php-fpm: pool www
├─55681 php-fpm: pool www
├─55682 php-fpm: pool www
└─55683 php-fpm: pool www
5月 03 14:18:30 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Man....
5月 03 14:18:30 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.
Hint: Some lines were ellipsized, use -l to show in full.
編輯
vim /etc/php5/fpm/php.ini
找到這一行改成 0
cgi.fix_pathinfo=0
vim /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
sudo service nginx restart
wget http://127.0.0.1/info.php
[root@localhost html]# wget http://127.0.0.1/info.php
--2017-05-03 18:08:16-- http://127.0.0.1/info.php
正在連接 127.0.0.1:80... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 21 [application/octet-stream]
Saving to: ‘info.php.1’
100%[==================================================>] 21 --.-K/s in 0s
2017-05-03 18:08:16 (1.26 MB/s) - ‘info.php.1’ saved [21/21]
留言
張貼留言