linux mysql 实战_linux实用实战
1、編譯安裝搭建wordpress
軟件環(huán)境:
apr-1.6.2.tar.gz
php-7.1.10.tar.xz?http://php.net/
mariadb-10.2.8-linux-x86_64.tar.gz?http://mariadb.org/
wordpress-4.8.1-zh_CN.tar.gz?https://cn.wordpress.org/
1 、源碼編譯安裝Httpd2.4
(1)安裝包組和包
yum groupinstall "development tools"
yum installopenssl-devel expat-devel pcre-devel
(2)解壓包
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
(3)編譯安裝:
cp -r apr-1.6.2? ? httpd-2.4.27/srclib/apr
cp -r apr-util-1.6.0? ? httpd-2.4.27/srclib/apr-util
cd 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=prefork
make -j 4 && make install? 用四核編譯并安裝
(4)修改PATH路徑
vim /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin/:$PATH
./etc/profile.d/lamp.sh? 生效修改
echo $PATH? ? 查看是否生效
(5)啟動(dòng)服務(wù)
apachectl? 啟動(dòng)服務(wù)
ss -tnl? 查看80端口是否打開
2、 二進(jìn)制安裝mariadb
(1)解壓到固定目錄/usr/local/
tar xvf mariadb-10.2.8-linux-x86_64.tar.gz? -C /usr/local/
(2)創(chuàng)建一個(gè)軟連接,或者將mariadb-10.2.8-linux-x86_64目錄名修改為mysql,必須是mysql
cd /usr/local
ln -s mariadb-10.2.8-linux-x86_64/ mysql
(3)創(chuàng)建用戶mysql
useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
(4)生成數(shù)據(jù)庫
cd mysql/
scripts/mysql_install_db? --datadir=/app/mysqldb --user=mysql
(5)? 修改配置文件
mkdir /etc/mysql
cp support-files/my-large.cnf? /etc/mysql/my.cnf
vim /etc/mysql/my.cnf 添加下面三行
[mysqld]
datadir = /app/mysqldb? 數(shù)據(jù)庫位置
innodb_file_per_table = ON? ? 規(guī)定一個(gè)數(shù)據(jù)庫表一個(gè)文件夾
skip_name_resolve = ON? ? 跳過名字解析
(5)添加服務(wù)
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld? 添加服務(wù)
chkconfig --list? ? 查看是否添加成功
(6)創(chuàng)建日志
mkdir /var/log/mariadb
chown mysql /var/log/mariadb/
service mysqld start
(7)修改PATH路徑
vi /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
./etc/profile.d/lamp.sh
mysql_secure_installation? 運(yùn)行安全腳本
(8)創(chuàng)建數(shù)據(jù)庫
mysql -uroot -pcentos
create datebase wpdb;
grant all on wpdb.* to wpuser@'192.168.191.%' 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
(1)安裝依賴包
yum install libxml2-devel bzip2-devel? libmcrypt-devel(epel)
(2)解壓
tar xvf php-7.1.10.tar.xz
(3)編譯,安裝
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 -j 4? && make install
(4)修改配置文件
cp php.ini-production /etc/php.ini
vim /etc/httpd24/httpd.conf
在文件尾部加兩行
AddType application/x-httpd-php? .php
AddType application/x-httpd-php-source .phps
修改下面行
DirectoryIndex index.php index.html
(5) 重啟服務(wù)
apachectl stop
apachectl
4 、測(cè)試php和mariadb連接
vim /app/httpd24/htdocs/index.php
LAMP
$mysqli=newmysqli("localhost","root","centos");
if(mysqli_connect_errno()){
echo "連接數(shù)據(jù)庫失敗!";
$mysqli=null;
exit;
}
echo "連接數(shù)據(jù)庫成功!";
$mysqli->close();
phpinfo();
?>
5、 配置wordpress
(1) 解壓
tar xvf wordpress-4.8.1-zh_CN.tar.gz? -C /app/httpd24/htdocs
(2)cd /app/httpd24/htdocs
mv wordpress/ blog/
注意:如果想要訪問 http://192.168.191.107/就訪問博客,mv wordpress/* /app/httpd24/htdocs
(3) 修改配置文件
cd /app/httpd24/htdocs/blog/
cp? wp-config-sample.php? wp-config.php
vim wp-config.php
define('DB_NAME', 'wpdb');
/** MySQL數(shù)據(jù)庫用戶名 */
define('DB_USER', 'wpuser');
/** MySQL數(shù)據(jù)庫密碼 */
define('DB_PASSWORD', 'centos');
/** MySQL主機(jī) */
define('DB_HOST', 'localhost');
2、搭建php-admin
# yum -y install php-mbstring? ? ? ? ? ? support for multi-byte string handling to PHP
解壓下載文件至指定目錄
# tar -xzvf phpMyAdmin-4.0.10.20-all-languages.tar.gz -C /data
# mv phpMyAdmin-4.0.10.20-all-languages phpMyAdmin
創(chuàng)建phpMyAdmin虛擬主機(jī)
ServerName www.phpMyAdmin.com
DocumentRoot "/data/phpMyAdmin"
Options None
AllowOverride None
Require all granted
總結(jié)
以上是生活随笔為你收集整理的linux mysql 实战_linux实用实战的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: div中的p标签于img设置同一水平_前
- 下一篇: mysql 日期类型比价_MySQL 日