mkdir -p /data/server/php /data/server/mysql/mysqldb /data/server/nginx
1、安裝nginx
安裝nginx依賴包:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-develtk-devel gdbm-devel db4-devel libpcap-devel xz-devel
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/data/server/nginx
make && make install
啟動nginx:
測試:
2、安裝php
安裝php依賴包:
yum -y install openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxml2 libxml2-devel
建立使用者:
# useradd www
tar -xvf php-5.6.0.tar
cd php-5.6.0
./configure --prefix=/data/server/php --with-config-file-path=/data/server/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-curl --with-openssl --enable-mbregex --with-mysql --with-mysqli --with-mysql-sock --enable-pdo --with-pdo-mysql --enable-mysqlnd --with-gd --with-zlib --enable-zip --with-bz2 --enable-xmlreader --enable-xmlwriter --enable-mbstring --with-xmlrpc --with-libxml-dir=/usr --enable-soap --enable-sockets --enable-pcntl --enable-exif --enable-bcmath --with-mhash --enable-ftp --enable-opcache --disable-fileinfo --with-pear
make && make install
cd /data/server/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vim etc/php-fpm.conf
修改如下,修改完成後儲存並退出:
pid = run/php-fpm.pid
user = web
group = web
# vim /data/server/nginx/conf/nginx.conf
location ~ \.php$
新增php到服務,並啟動php服務
測試:
3、安裝mysql
安裝mysql依賴包:
yum install -y centos-release-scl devtoolset-4-gcc-c++ devtoolset-4-gcc cmake git ncurses-devel openssl-devel bison gcc gcc-c++ ncurses-devel perl make autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel perl kernel-headers cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libxpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libpng* ncurses* libtool* libxml2-devel bison libaio-devel
cmake \
-dcmake_install_prefix=/data/server/mysql \
-dmysql_datadir=/data/server/mysql/data \
-dmysql_unix_addr=/data/server/mysql/mysql.sock
make && make install
[root@chen ~]# groupadd -r mysql
[root@chen ~]# useradd -m -s/sbin/nologin -g mysql -r mysql
[root@chen ~]# cd /data/server/mysql
[root@chen mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/data/server/mysql --datadir=/data/server/mysql/data #初始化資料庫
[root@chen mysql]# cp ./support-files/my-default.cnf /etc/my.cnf
[root@chen mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@chen mysql]# chmod +x /etc/init.d/mysqld
[root@chen mysql]# chowd -r mysql:mysql /data/server/mysql
新增mysql啟動指令碼到環境變數中:
在 /etc/profile 末尾新增:
注意:需要在連線mysql之前,設定軟連線,否則會報以下的錯誤:
error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2)
需要設定軟連線:
ln -s /data/server/mysql/mysql.sock /var/lib/mysql/mysql.sock
重啟mysqld,然後輸入mysql命令即可連線到資料庫
systemctl restart mysqld
mysql
centos7搭建lnmp環境
安裝php 5.6.26 wget 解壓 tar zxvf php 5.6.26.tar.gz 安裝編譯用的環境 yum install y libxml2 devel openssl devel libcurl devel libjpeg devel libpng devel libicu dev...
centos 7 搭建LNMP環境
2.安裝mysql community release el7 5.noarch.rpm包 安裝這個包後,會獲得兩個mysql的yum repo源 etc yum.repos.d mysql community.repo,etc yum.repos.d mysql community source....
centos7 搭建lnmp環境
關閉防火牆和selinux vim etc sysconfig selinux將檔案中selinux enforcing改為禁用,儲存退出 wq selinux disabled不用重啟關閉selinux。setenforce 0關閉放火牆,建議開啟禁用,不然重啟後還是會生效 systemctl s...