软件版本
1.X
2.X
主要目录和文件
安装包:apr-1.7.0.tar.gz 、apr-util-1.6.1.tar.gz 、httpd-2.4.25.tar.gz
[root@localhost opt]# tar zxvf apr-1.7.0.tar.gz -C /opt
[root@localhost opt]# tar zxvf apr-util-1.6.1.tar.gz -C /opt
[root@localhost opt]# tar zxvf httpd-2.4.25.tar.gz -C /opt
[root@localhost opt]# mv apr-1.7.0/ httpd-2.4.25/srclib/apr
[root@localhost opt]# mv apr-util-1.6.1/ httpd-2.4.25/srclib/apr-util
[root@localhost opt]# yum -y install gcc gcc-c++ make pcre-devel expat-devel perl ==//安装gcc的编译和pcre 包是per语言==
[root@localhost httpd-2.4.25]# ./configure \
>--prefix=/usr/local/httpd \
>--enable-so--enable-rewrite\
>--enable-charset-lite\
--enable-cgi
[root@localhost httpd-2.4.25]#make
[root@localhost httpd-2.4.25]#make install
[root@localhost httpd-2.4.25]# cd /usr/local/ //到安装路径
[root@localhost local]# cd httpd/
[root@localhost httpd]# cd conf/
[root@promote bin]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@promote bin]# ls /etc/init.d
functions httpd netconsole network README
[root@promote bin]# vim /etc/init.d
[root@promote bin]# vim /etc/init.d/httpd
#!/bin/sh
#chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
#description:Apache is a World Wide Web server
[root@promote local]# chkconfig --add httpd //将httpd加入到service 管理器
[root@promote /]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf //将http的配置文件做软链接到/etc/httpd.conf
[root@promote local]# cd /usr/local/httpd/conf
[root@promote conf]# vim httpd.conf
Listen 192.168.75.134:80 //修改Apache服务器的地址
#Listen 80
#ServerName www.kgc.com:80 //设置域名的地址
[root@promote /]# ln -s /usr/local/httpd//bin/* /usr/local/bin //将http的数据文件软链接到/usr/local/bin目录中
[root@promote /]# ls /usr/local/httpd//bin
ab checkgid htcacheclean httxt2dbm
apachectl dbmmanage htdbm logresolve
apr-1-config envvars htdigest rotatelogs
apu-1-config envvars-std htpasswd
apxs fcgistarter httpd
[root@promote /]# service httpd start
httpd (pid 66785) already running
[root@promote /]# httpd -t //检查语法
Syntax OK
[root@promote /]# netstat -ntap | grep 80
tcp 0 0 192.168.75.134:80 0.0.0.0:* LISTEN 66785/httpd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 8031/dnsmasq
[root@promote /]#
[root@promote /]# iptables -F
[root@promote /]# setenforce 0
[root@promote /]#
常用数据库的语句
1:使用SHOW语句找出在服务器上当前存在什么数据库:
mysql> SHOW DATABASES;
2:创建一个数据库MYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3:选择你所创建的数据库
mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!)
4:查看现在的数据库中存在什么表
mysql> SHOW TABLES;
MySQL配置文件目录
安装包
mysql-5.6.26.tar.gz
[root@promote mysql]# yum install ncurses-devel autoconf cmake -y //安装编译器
[root@promote mysql]# cd mysql-5.6.26/
[root@promote mysql-5.6.26]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //设置安装路径
> -DDEFAULT_CHARSET=utf8 \ //设置字体样式
> -DDEFAULT_COLLATION=utf8_general_ci \ // 指定默认使用的字符集校对规则
> -DEXTRA_CHARSETS=all \ //字符集的设置
> -DSYSCONFIDIR=/etc \ //指定初始化参数文件目录(数据库的配置文件)
> -DMYSQL_DATADIR=/home/mysql/ \ //指定数据库的数据存在家目录
> -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock //其他设置远程连接数据库的通讯文件
[root@promote mysql-5.6.26]#make
[root@promote mysql-5.6.26]#make install
[root@promote mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@promote mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld //添加系统服务
[root@promote mysql-5.6.26]# chmod 755 /etc/init.d/mysqld //给mysqld 文件添加权限
[root@promote mysql-5.6.26]#
[root@promote mysql-5.6.26]# vim /etc/profile //设置环境变量
PATH=$PATH:/usr/local/mysql/bin
[root@promote mysql-5.6.26]# source /etc/profile //环境变量文件生效
[root@promote mysql-5.6.26]# echo $PATH //查看环境变量
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@promote mysql-5.6.26]# useradd -s /sbin/nologin mysql //新建用户
[root@promote mysql-5.6.26]# id mysql
uid=1001(mysql) gid=1001(mysql) 组=1001(mysql)
[root@promote mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/ //数据库的文件进行权限设置
[root@promote mysql-5.6.26]# cd /usr/local/mysql/scripts
[root@promote scripts]# /usr/local/mysql/scripts/mysql_install_db \ //绝对路径
> --user=mysql \ //指定数据库用户
> --ldata=/var/lib/mysql \ //指定数据库的库存放位置
> --basedir=/usr/local/mysql \ //指定数据库的服务数据的目录
> --datadir=/home/mysql //指定数据库的数据存放的位置
[root@promote scripts]# vim /etc/init.d/mysqld
[root@promote scripts]# service mysqld start //开启mysqld 服务
Starting MySQL SUCCESS!
[root@promote scripts]# netstat -ntap | grep 3306 //查看端口号是否开启
tcp6 0 0 :::3306 :::* LISTEN 32064/mysqld
[root@promote scripts]# mysqladmin -u root -p password "abc123" //设置MySQL用户的密码
Enter password:
Warning: Using a password on the command line interface can be insecure.
[root@promote scripts]# mysql -u root -p //登录数据库
Enter password: //密码是之前设置的‘abc123’
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; //查看数据库信息
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
[root@promote scripts]# quit //退出数据库
gd 库是 PHP 处理图形的扩展库,它提供了一系列用来处理图片的 API(应用程序编程接口),使用 gd 库可以处理图片或者生成图片。在网站上,gd 库通常用来生成缩略图,或者对图片加水印,或者生成汉字验证码,或者对网站数据生成报表等。
zlib是提供数据压缩用的函式库,由Jean-loup Gailly与Mark Adler所开发。
[root@promote scripts]#cd /opt/php
[root@promote php]# yum -y install \
> gd \ //gd 库是 PHP 处理图形的扩展库
> libpng \
> libpng-devel \
> pcre \
> pcre-devel \ //正则表达式
> libxml2-devel \
> libjpeg-devel
[root@promote php]# tar jxvf php-5.6.11.tar.bz2
[root@promote php]# cd php-5.6.11
[root@promote php-5.6.11]# ./configure \ //编译配置文件
> --prefix=/usr/local/php5 \ //设置安装路径
> --with-gd \ ////gd 库是 PHP 处理图形的扩展库
> --with-zlib \ //zlib 函数库提供了对处理器和内存使用控制的能力
> --with-apxs2=/usr/local/httpd/bin/apxs \ //设置Apache HTTPS Server提供的apxs模块支持程序的文件位置
> --with-mysql=/usr/local/mysql \ //设置MySQL数据库服务程序的安装位置
> --with-config-file-path=/usr/local/php5 \ //设置PHP的配置文件php.ini将要存放的位置
> --enable-mbstring
[root@promote php-5.6.11]#make
[root@promote php-5.6.11]#make install
[root@promote php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini
[root@promote php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin //PHP配置文件做软链接目的路径是/usr/local/bin
[root@promote php-5.6.11]# vim /etc/httpd.conf
[root@promote php-5.6.11]# systemctl restart httpd //修改httpd配置文件,需要重启Apache服务
[root@promote php-5.6.11]# cd /usr/local/httpd/htdocs/
[root@promote htdocs]# vim index.html
<?php
phpinfo();
?>
[root@promote htdocs]# mv index.html index.php //更改文件属性,将.html 改为.php
192.168.65.134/index.php
查看index.php 网页,PHP搭建成功
***************将论坛的压缩包拖至/opt的目录下********************
[root@localhost opt]# unzip Discuz_X2.5_SC_UTF8.zip
[root@localhost php]# ll
总用量 23332
-rw-r--r--. 1 root root 9799758 8月 3 14:31 Discuz_X2.5_SC_UTF8.zip
drwxr-xr-x. 18 ttyy ttyy 4096 8月 3 21:53 php-5.6.11
-rw-r--r--. 1 root root 14081292 8月 3 14:31 php-5.6.11.tar.bz2
drwxr-xr-x. 2 root root 102 4月 27 2012 readme
drwxr-xr-x. 12 root root 4096 4月 27 2012 upload
drwxr-xr-x. 4 root root 72 4月 27 2012 utility
[root@localhost php]# cp -r upload/ /usr/local/httpd/htdocs/bbs
[root@localhost php]# cd /usr/local/httpd/htdocs/bbs/
[root@localhost htdocs]# ll
总用量 8
drwxr-xr-x. 12 root root 4096 8月 4 08:45 bbs
-rw-r--r--. 1 root root 21 8月 3 22:07 index.php
***************给论坛的配置文件添加权限***********************
[root@localhost bbs]# chown -R daemon ./config
[root@localhost bbs]# chown -R daemon ./data
[root@localhost bbs]# chown -R daemon ./uc_client
[root@localhost bbs]# chown -R daemon ./uc_server/data/
[root@localhost bbs]# mysql -u root -p //登录数据库
Enter password: //密码是之前设置的‘abc123’
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; //查看数据库用户
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
mysql> create database bbs; //创建数据库的用户
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use bbs; //切换用户bbs
Database changed
mysql> show tables; //查看用户的数据库的内容为空
Empty set (0.01 sec)
mysql> grant all on bbs.* to 'bbsuser'@'%' identified by 'admin123'; //给用户bbs添加数据库的
Query OK, 0 rows affected (0.04 sec)
mysql> flush privileges; //刷新数据库
Query OK, 0 rows affected (0.00 sec)
mysql> quit //退出
浏览器输入
192.168.75.134/bbs
192.168.75.134/bbs/admin.php