lnmp简单搭建

nginx 安裝
unpack.sh
tar -xf /application/nginx-1.18.0.tar.gz
./configure --prefix=/application/nginx-1.18.0 --user=www --group=www --with-http_ssl_module --with-http
ln -s /application/nginx-1.18.0 nginx

注意需要在ansible.conf中配置該IP 不然找不到
#install nginx 
- host :172.16.1.16
  tasks:
    - name: install depend on the package
      yum: name=pcre-devel state=installed
    - name: install openssl
      yum: name=openssl-devel state=installed
    - name: copy file to dest
      copy: dest=/application src=/root/nginx-1.18.0.tar.gz
    - name: create nginx user www
      user: name=www state=present createhome=no shell=/sbin/nologin
    - name: unpack package and 
      script: /server/scripts/unpack.sh
      
下载数据库文件
ftp://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.6
解压数据库文件
tar xf mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz 
mv mysql-5.6.45-linux-glibc2.12-x86_64 /application/
下载的是二进制的包可以直接使用
然后就是文件的拷贝了需要将mysql.server开启mysql的文件拷贝到/etc/init.d/mysqld
cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
由于安装路径所有需要对配置文件进行修改/
sed -ri 's#/usr/local#/application#' /etc/init.d/mysqld /application/mysql/bin/mysqld_safe
useradd mysql -M -s /sbin/nologin -M
设置数据库存放文件的路径的属主属组分别是mysql
chown -R mysql:mysql /application/mysql/data/
将配置文件拷贝到/etc/my.cnf 
cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
执行数据库初始化操作 指定数据库位置 basedir 数据存放位置 用户信息
/etc/init.d/mysqld
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
/application/mysql/bin/mysql -uroot password "centos"

安装php
yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
字符集转换
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
./configure --prefix=/usr/local/libiconv
make
make install
yum -y install libmcrypt-devel mhash mcrypt
./configure
–prefix=/application/php
–with-curl
–with-freetype-dir
–with-gd
–with-gettext
–with-iconv-dir
–with-jpeg-dir
–with-kerberos
–with-libdir=lib64
–with-libxml-dir
–with-mysql
–with-mysqli
–with-openssl
–with-pcre-regex
–with-pdo-mysql
–with-pdo-sqlite
–with-pear
–with-png-dir
–with-xmlrpc
–with-xsl
–with-zlib
–enable-fpm
–enable-bcmath
–enable-libxml
–enable-inline-optimization
–enable-gd-native-ttf
–enable-mbregex
–enable-mbstring
–enable-opcache
–enable-pcntl
–enable-shmop
–enable-soap
–enable-sockets
–enable-sysvsem
–enable-xml
–enable-zip

ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64
make make install
php.ini
php.fpm.ini
touch ext/phar/phar.phar
cp /server/tools/php-5.5.32/php.ini-production /application/php/lib/

cd /application/php/etc
cp php-fpm.conf.default php-fpm.conf
chown -R www:www /application/nginx/html/blog

创建数据库
create database wordpress;
mysqldump -uroot -pcentos -databases >/tmp/bak.sql

你可能感兴趣的:(ansible,yaml)