在lamp基础上安装Wordpress

来源:互联网 发布:成都数控编程工艺招聘 编辑:程序博客网 时间:2024/06/05 10:16

lamp简单介绍

LAMP — Linux+Apache+Mysql/MariaDB+Perl/PHP/Python,一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案。

今天,我们就来一起学习一下lamp的各种安装方法,并在此基础上搭建属于自己的个人博客。

下面的每个实验都可以成功搭建博客,任意选择一种即可。yum安装比较容易实现,自己编译软件可能会出错,请选择适合自己的方法。

实验:yum方式安装LAMP应用wordpress,php为模块方式

软件环境:
操作系统:CentOS6/7
两台主机,一台主机A:安装httpd,php,一台主机B:安装mariadb server
当然,也可以都安装在一台主机上

1 A:yum httpd php php-mysqlvim /etc/php.inidate.timezone = Asia/Shanghaivim /etc/httpd/conf/httpd.conf<IfModule dir_module>    DirectoryIndex index.php index.html</IfModule>systemctl restart httpdvim /var/www/html/index.php<?phpecho date("Y/m/d H:i:s");phpinfo();?>p2 Byum install mariadb-serversystemctl start  mariadbmysql_secure_installationmysql -uroot -pcentos>grant all on  *.* to root@'172.17.1.%' identified by 'centos'; vim /var/www/html/index2.php <?php$mysqli=new mysqli("localhost","root","centos");if(mysqli_connect_errno()){echo "连接数据库失败!";$mysqli=null;exit;}echo "连接数据库成功!";$mysqli->close();测试 http://websrv/3 A上部署wordpressmysql -uroot -pcentos -h172.17.1.177> create database wpdb;> grant all wpdb.* to wpuser@'172.17.1.%' identified by 'centos';> flush privileges;tar xvf wordpress-4.8.1-zh_CN.tar.gz cp -r  wordpress   /var/www/html/blogcd /var/www/html/blogcp wp-config-sample.php wp-config.php vim wp-config.php define('DB_NAME', 'wpdb');define('DB_USER', 'wpuser');define('DB_PASSWORD', 'centos');define('DB_HOST', '172.17.1.166'); #这里写mysql服务器ip测试http://websrv/blog/

实验:LAMP的fastcgi方式应用wordpress

软件环境:
操作系统:CentOS7
两台主机
一台A apache和php-fpm
一台B mariadb server

1A:yum install httpd  php-fpm php-mysqlsystemctl start httpdsystemctl start php-fpm B:yum install mariadb-serversystemctl start mariadbmysql_secure_installation mysql -uroot -pcentos2 A: vim /etc/httpd/conf.d/fcgi.conf DirectoryIndex index.phpProxyRequests OffProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1systemctl reload httpd3 A上部署wordpressmysql -uroot -pcentos> create database wpdb;> grant all wpdb.* to wpuser@'172.17.1.%' identified by 'centos';> flush privileges;tar xvf wordpress-4.8.1-zh_CN.tar.gz cp -r  wordpress   /var/www/html/blogcd /var/www/html/blogcp wp-config-sample.php wp-config.php vim wp-config.php define('DB_NAME', 'wpdb');define('DB_USER', 'wpuser');define('DB_PASSWORD', 'centos');define('DB_HOST', '172.17.1.177');4 测试性能http://websrv/blog/

实验:centos7.3实现基于源码编译安装LAMP的wordpress应用

软件环境:
一台主机
apr-1.6.2.tar.gz
httpd-2.4.27.tar.bz2
php-7.1.10.tar.xz
apr-util-1.6.0.tar.gz
mariadb-10.2.8-linux-x86_64.tar.gz
wordpress-4.8.1-zh_CN.tar.gz

1 源码编译安装Httpd2.4yum groupinstall "development tools"yum install openssl-devel expat-devel pcre-devel tar xvf apr-1.6.2.tar.gz tar xvf apr-util-1.6.0.tar.gz tar xvf httpd-2.4.27.tar.bz2 cp -r apr-1.6.2 httpd-2.4.27/srclib/aprcp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-utilcd httpd-2.4.27/./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=preforkmake -j 4 && make installvim /etc/profile.d/lamp.shPATH=/app/httpd24/bin/:$PATH. /etc/profile.d/lamp.shapachectl ss -tnl2 二进制安装mariadb tar xvf mariadb-10.2.8-linux-x86_64.tar.gz  -C /usr/local/cd /usr/localln -s mariadb-10.2.8-linux-x86_64/ mysqluseradd -r -m -d /app/mysqldb -s /sbin/nologin mysql cd mysql/scripts/mysql_install_db --datadir=/app/mysqldb --user=mysqlmkdir /etc/mysqlcp support-files/my-large.cnf   /etc/mysql/my.cnfvim /etc/mysql/my.cnf[mysqld]datadir = /app/mysqldbinnodb_file_per_table = ONskip_name_resolve = ONcp support-files/mysql.server /etc/init.d/mysqldchkconfig --add mysqldchkconfig --list service mysqld startmkdir /var/log/mariadbchown mysql /var/log/mariadb/service mysqld startvi /etc/profile.d/lamp.sh PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH. /etc/profile.d/lamp.shmysql_secure_installationmysql -uroot -pcentoscreate datebase wpdb;grant all on wpdb.* to wpuser@'172.17.1.%' identified by 'centos';grant all on wpdb.* to wpuser@'127.%' identified by 'centos';grant all on wpdb.* to wpuser@'localhost' identified by 'centos';3 源码编译安装Php--模块方式yum install libxml2-devel bzip2-devel libmcrypt-devel tar xvf php-7.1.10.tar.xz cd php-7.1.10/./configure \--prefix=/app/php \--enable-mysqlnd \--with-mysqli=mysqlnd \--with-openssl \--with-pdo-mysql=mysqlnd \--enable-mbstring \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--enable-sockets \--with-apxs2=/app/httpd24/bin/apxs \--with-mcrypt \--with-config-file-path=/etc \--with-config-file-scan-dir=/etc/php.d \--enable-maintainer-zts \--disable-fileinfo make && make installcp php.ini-production /etc/php.inivim /etc/httpd24/httpd.conf在文件尾部加两行AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps修改下面行<IfModule dir_module>    DirectoryIndex index.php index.html</IfModule>apachectl stopapachectl 4 测试php和mariadb连接vim /app/httpd24/htdocs/index.php <html><body><h1> LAMP</h1></body></html><?php$mysqli=new mysqli("localhost","root","centos");if(mysqli_connect_errno()){echo "连接数据库失败!";$mysqli=null;exit;}echo "连接数据库成功!";$mysqli->close();phpinfo();?>5 配置wordpresstar xvf wordpress-4.8.1-zh_CN.tar.gz  -C /app/httpd24/htdocscd /app/httpd24/htdocsmv wordpress/ blog/cd /app/httpd24/htdocs/blog/cp wp-config-sample.php  wp-config.phpvim wp-config.phpdefine('DB_NAME', 'wpdb');/** MySQL数据库用户名 */define('DB_USER', 'wpuser');/** MySQL数据库密码 */define('DB_PASSWORD', 'centos');/** MySQL主机 */define('DB_HOST', 'localhost');6 登录测试http://websrv/blog 测试性能ab -c 10 -n 100 http://websrv/blog/

实验:CentOS6编译LAMP基于FPM模式的应用wordpress

软件版本ls /root/srcapr-1.6.2.tar.gz      apr-util-1.6.0.tar.gz  httpd-2.4.28.tar.bz2 mariadb-5.5.57-linux-x86_64.tar.gz  php-5.6.31.tar.xzwordpress-4.8.1-zh_CN.tar.gzxcache-3.2.0.tar.gz1yum groupinstall "development tools"yum install openssl-devel expat-devel pcre-devel bzip2-devel libxml2-devel libmcrypt-devel2 编译httpd2.4tar xvf apr-1.6.2.tar.gz tar xvf apr-util-1.6.0.tar.gz tar xvf httpd-2.4.28.tar.bz2 mv apr-1.6.2 httpd-2.4.28/srclib/aprmv apr-util-1.6.0 httpd-2.4.28/srclib/apr-utilcd /root/src/httpd-2.4.28./configure --prefix=/app/httpd24 \--enable-so \--enable-ssl \--enable-cgi \--enable-rewrite \--with-zlib \--with-pcre \--with-included-apr \--enable-modules=most \--enable-mpms-shared=all \--with-mpm=preforkmake -j 4 && make installvim /etc/profile.d/lamp.shPATH=/app/httpd24/bin:/usr/local/mysql/bin/:/app/php/bin/:$PATH . /etc/profile.d/lamp.sh cp /etc/init.d/httpd  /etc/init.d/httpd24vim /etc/init.d/httpd24chkconfig --add httpd24service httpd24 start3 二进制安装mariadb-5.5.57mkdir /appuseradd -d /app/mysqldb -r -m -s /sbin/nologin mysqltar xf /root/mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local/ln -s /usr/local/mariadb-5.5.57-linux-x86_64 /usr/local/mysqlcd /usr/local/mysql/mkdir /etc/mysql/cp support-files/my-huge.cnf  /etc/mysql/my.cnfvim /etc/mysql/my.cnf[mysqld]datadir = /app/mysqldb  这一行必须添加innodb_file_per_table = on 数据库引擎,每个表单独一个文件,不是必须要添加的,只是为了方便管理skip_name_resolve = on  忽略名字解析,加快访问速度,这一行不是必须要添加的scripts/mysql_install_db  --user=mysql --datadir=/app/mysqldb cp  support-files/mysql.server  /etc/init.d/mysqldchkconfig --add mysqldtouch /var/log/mysqld.logchown mysql  /var/log/mysqld.logecho 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.shservice mysqld startmysql_secure_installation   #安全初始化#创建博客所需的数据库wpdb和账号wpusermysql -uroot -pcentos> create database wpdb;> grant all wpdb.* to wpuser@'192.168.37.%' identified by 'centos';> flush privileges;4 编译安装php-5.6.31 tar xvf  php-5.6.31.tar.xzcd /root/src/php-5.6.31./configure \--prefix=/app/php \--with-mysql=/usr/local/mysql \--with-openssl  \--with-mysqli=/usr/local/mysql/bin/mysql_config \--enable-mbstring \--with-freetype-dir \--with-jpeg-dir  \--with-png-dir  \--with-zlib  \--with-libxml-dir=/usr \--enable-xml \--enable-sockets \--enable-fpm \--with-mcrypt  \--with-config-file-path=/etc/php/  \--with-config-file-scan-dir=/etc/php.d  \--with-bz2make -j 4 && make install cp php.ini-production /etc/php/php.inicp sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpm chkconfig --add php-fpmcp /app/php/etc/php-fpm.conf.default  /app/php/etc/php-fpm.conf service php-fpm startss -ntl5 配置httpd支持php vim /app/httpd24/conf/httpd.conf去掉下面两行注释LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so修改下面行DirectoryIndexindex.phpindex.html加下面四行AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsProxyRequests OffProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$16 布署wordpresstar xvf wordpress-4.8.1-zh_CN.tar.gz cp -r  wordpress   /app/httpd24/htdocs/blogcd /app/httpd24/htdocs/blogcp wp-config-sample.php wp-config.php vim wp-config.php define('DB_NAME', 'wpdb');define('DB_USER', 'wpuser');define('DB_PASSWORD', 'centos');define('DB_HOST', '172.17.1.177');ab 测试性能7 编译安装xcache  #提高服务器上的 PHP 性能tar xvf xcache-3.2.0.tar.gz cd xcache-3.2.0./configure  --enable-xcache --with-php-config=/app/php/bin/php-config make && make install mkdir /etc/php.d/cp xcache.ini  /etc/php.d/ls /app/php/lib/php/extensions/no-debug-non-zts-20131226/vim /etc/php.d/xcache.ini extension = /app/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so 修改此行service php-fpm restart8 测试phpinfo() 确认xcache 已加载ab 测试性能

在浏览器地址栏输入你的web服务器ip,我这次搭建的博客是在网站主目录下的blog目录,所以在地址栏内输入:172.17.1.177/blog/,回车,就可以看到下图,这时wordpress搭建完成,只需要注册一下站点标题,用户,密码,邮箱,最后点击“安装WordPress”
这里写图片描述

看到这张图代表你已经成功了!!
博客首页

原创粉丝点击