LAMP+wordpress环境搭建
1、安装Nginx
yum -y install gcc gcc-c++ make make-zlib automake autoconf pcre pcre-devel zlib zlib-devel openssl openssl-devel libtool
useradd -r -s /sbin/nologin nginx
mkdir -p /usr/local/nginx
cd nginx-1.16.1
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
make && make install
mkdir -p /usr/local/nginx/logs
mkdir -p /var/tmp/nginx/client/
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s reload
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
2、安装MySql
yum -y install make cmake gcc gcc-c++ bison bison-devel ncurses ncurses-devel autoconf automake
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql/logs
mkdir -p /usr/local/mysql/temp
tar -xf mysql-5.6.26.tar.gz
cd mysql-5.6.26/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
make && make install
vim /etc/my.cnf
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
[mysqld]
#skip-grant-tables
character-set-server=utf8
collation-server=utf8_general_ci
skip-external-locking
skip-name-resolve
user=mysql
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
tmpdir=/usr/local/mysql/temp
socket=/usr/local/mysql/mysql.sock
log-bin-trust-function-creators=1
log-error=/usr/local/mysql/logs/mysql_error.log
pid-file=/usr/local/mysql/mysql.pid
open_files_limit=10240
back_log=600
max_connections=500
max_connect_errors=6000
wait_timeout=600
interactive_timeout=600
#open_tables=600
#table_cache=650
#opened_tables=630
max_allowed_packet=1024M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size=300
query_cache_type=1
query_cache_size=128M
query_cache_limit=2M
query_cache_min_res_unit=16k
tmp_table_size=256M
max_heap_table_size=256M
key_buffer_size=128M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=64M
lower_case_table_names=1
default-storage-engine=INNODB
innodb_buffer_pool_size=2G
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_flush_method=O_DIRECT
#######################
thread_concurrency=32
long_query_time=2
slow-query-log=on
slow-query-log-file=/usr/local/mysql/logs/mysql-slow.log
## master slave db backup start
server_id=66
#binlog-do-db=nancheng
binlog-ignore-db=mysql
log-bin=nancheng-plasma-bin
binlog_cache_size=1M
binlog_format=mixed
expire_logs_days=7
slave_skip_errors=1062
######################### db copy end
[mysqldump]
quick
max_allowed_packet=32M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
scp命令使用
scp /etc/my.cnf root@192.168.235.202:/etc/
报错可使用如下命令
rm -rf ~/.ssh/known_hosts
chown -Rf mysql.mysql /usr/local/mysql/
chown -Rf mysql.mysql /usr/local/mysql/
chown -Rf mysql.mysql /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
## mkdir -p /var/run/mysqld
## chown -Rf mysql.mysql /var/run/mysqld/
## /usr/local/mysql/bin/mysqld_safe --user=mysql &
ln -s /usr/local/mysql/bin/* /usr/local/bin/
ln -s /usr/local/mysql/sbin/* /usr/local/sbin/
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
CentOS 6启动服务
service mysql start
chkconfig mysql on
CentOS 7 启动服务
systemctl start mysql
systemctl enable mysql
启动时报错:Failed to start mysql.service: Unit not found.
cp -a /usr/local/mysql/support-files/mysql.server /etc/systemd/system/
赋予远程主机登录访问数据库权限
mysql -uroot -p
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
use mysql;
update user set password=password("jytc$123") where user='root';
flush privileges;
3、安装PHP
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
cp -frp /usr/lib64/libldap* /usr/lib/
mkdir -p /usr/local/php
groupadd www
useradd -r -g www www
cd php-7.2.0
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-libmbfl --enable-ftp --with-gd --enable-gd-jis-conv --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enabl+e-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm
make && make install
4、安装后全局配置
cd /root/php-7.2.0
cp -a php.ini-development /usr/local/php/php.ini
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
pid = run/php-fpm.pid
cd /usr/local/php/etc/php-fpm.d
mv www.conf.default www.conf
vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name liujuan520.com.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/wordpress;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html/wordpress; #PHP网页文档根目录
fastcgi_pass 127.0.0.1:9000; #php-fpm的监听地址
fastcgi_index index.php; #php网页文件
include fastcgi.conf; #用include调用fastcgi_conf样本配置(查找文件所在位置并修改)
}
5、配置wordpress
cd /usr/local/nginx/html/wordpress
cp wp-config-sample.php wp-config.php
vim wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define( 'DB_NAME', 'wordpress' );
/** MySQL数据库用户名 */
define( 'DB_USER', 'root' );
/** MySQL数据库密码 */
define( 'DB_PASSWORD', 'jytc$123' );
/** MySQL主机 */
define( 'DB_HOST', '106.54.201.234' );
/** 创建数据表时默认的文字编码 */
define( 'DB_CHARSET', 'utf8' );
/** 数据库整理类型。如不确定请勿更改 */
define( 'DB_COLLATE', '' );