CentOS 7.2中搭建LNMP环境部署WordPress及DokuWiki/MediaWiki

  • 安装MySQL

    rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
    yum install -y mysql-community-server
    chown -R mysql:mysql /var/lib/mysql
    vim /etc/my.cnf

    #修改以下内容
    user=mysql #修改用户为mysql

    #如果之前有安装失败过,需清空/var/lib/mysql下文件先
    service mysqld restart
    grep 'temporary password' /var/log/mysqld.log #查看初始密码
    mysql -uroot -p
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

  • 安装Nginx

    yum install -y nginx
    chkconfig nginx on
    service nginx restart

  • 安装PHP

    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    yum install -y php56w php56w-fpm php56w-mysql php56w-mbstring php56w-xml php56w-pecl-apcu php56w-pecl-imagick php56w-intl
    chkconfig php-fpm on
    service php-fpm start

  • 配置Nginx

    vim /etc/nginx/nginx.conf

    #添加以下内容
    user nginx nginx; #修改nginx运行账号为:nginx组的nginx用户

    service nginx restart

  • 配置PHP

    vim /etc/php-fpm.d/www.conf

    #添加以下内容
    user = nginx #修改用户为nginx
    group = nginx #修改组为nginx

    vim /etc/php.ini

    #放开注释修改
    session.save_path = "/var/lib/php/session" #修改session存储地址为/var/lib/php/session

    chown -R nginx:nginx /var/lib/php/session
    chmod -R 755 /var/lib/php/session
    service php-fpm restart


至此LNMP环境部署完毕,接下来是部署WordPress、DokuWiki和MediaWiki。


  • 安装WordPress

    cd /usr/share/nginx/html/
    wget https://wordpress.org/latest.tar.gz
    tar -zxvf latest.tar.gz
    rm -f latest.tar.gz
    chown nginx:nginx /usr/share/nginx/html/wordpress -R
    chmod 755 /usr/share/nginx/html/wordpress -R
    vim /etc/nginx/nginx.conf

    #替换原有的80端口server
    	server {
    		listen       80;
    		server_name  blog.domian.com;
    		root         /usr/share/nginx/html/wordpress;
    
    		index  index.php index.html index.htm;
    		
    		location ~ \.php$ {
    			fastcgi_pass   127.0.0.1:9000;
    			fastcgi_index  index.php;
    			fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    			include        fastcgi_params;
    		}
    
    		location / {
    			try_files $uri $uri/ /index.php?q=$uri&$args;
    		}
    	}

    service nginx restart #重启nginx
    service php-fpm restart #重启php-fpm
    mysql -u root -p
    mysql> create database wordpress;
    #登陆网址进行设置

  • 安装DokuWiki

    #从网站下载安装包
    tar -zxvf dokuwiki.tgz
    rm -f dokuwiki.tgz
    chown nginx:nginx /usr/share/nginx/html/dokuwiki -R
    chmod 755 /usr/share/nginx/html/dokuwiki -R
    vim /etc/nginx/nginx.conf

    #增加8080端口server
    	server {
    		listen       80;
    		server_name  dokuwiki.domain.com;
    		root         /usr/share/nginx/html/dokuwiki;
    
    		index  index.php index.html index.htm;
    		
    		location ~ \.php$ {
    			fastcgi_pass   127.0.0.1:9000;
    			fastcgi_index  index.php;
    			fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    			include        fastcgi_params;
    		}
    
    		location ~ /(conf|bin|inc)/ {
    			deny all;
    		}
        
    		location ~ /data/ {
    			internal;
    		}
    
    		location / {
    			try_files $uri $uri/ /index.php?q=$uri&$args;
    		}
    	}

    service nginx restart #重启nginx

  • 安装MediaWiki

    cd /usr/share/nginx/html/
    wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz
    tar -zxvf mediawiki-1.27.1.tar.gz
    rm -f mediawiki-1.27.1.tar.gz
    mv mediawiki-1.27.1 mediawiki
    chown nginx:nginx /usr/share/nginx/html/mediawiki -R
    chmod 755 /usr/share/nginx/html/mediawiki -R
    vim /etc/nginx/nginx.conf

    #增加8000端口server
    	server {
    		listen       80;
    		server_name  mediawiki.domain.com;
    		root         /usr/share/nginx/html/mediawiki;
    
    		index  index.php index.html index.htm;
    		
    		location ~ \.php$ {
    			fastcgi_pass   127.0.0.1:9000;
    			fastcgi_index  index.php;
    			fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    			include        fastcgi_params;
    		}
    
    		location / {
    			try_files $uri $uri/ /index.php?q=$uri&$args;
    		}
    		
    		location ^~ /images/ {
    		}		
    	}

    service nginx restart #重启nginx
    #登陆网址进行设置

转载于:https://my.oschina.net/u/2448699/blog/3071029

你可能感兴趣的:(CentOS 7.2中搭建LNMP环境部署WordPress及DokuWiki/MediaWiki)