CentOS7 搭建简单的LAMP

简单的搭建LAMP步骤:
1.安装Apache:
   rz:上传所需要的安装包
   tar zxf httpd-2.2.17.tar.gz [解压apache安装包]
   cd httpd-2.2.17/[进入Apache解压后的目录]
   ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lit --enable-cgi[配置参数]
    make -j 4&& make install [编译安装]
    cp /usr/local/httpd/bin/apachectl  /etc/init.d/httpd[复制路径文件]
    vim /etc/init.d/httpd[进入添加为系统服务 chkconfig: 35 87 32]
    chkconfig --add httpd[添加Apache系统服务]
    chkconfig httpd on[开机自启]
    httpd -t[语法检测]
    ln -s /usr/local/httpd/bin/* /usr/sbin/[语法检测不正确是添加连接]
    httpd -t
    vim /usr/local/httpd/conf/httpd.conf[找到ServerName下添加域名ServerName www.xxx.com]
    service httpd start[启动apache]
    netstat -anlpt | grep httpd[查看端口号]
    firewall-cmd --zone=public --add-port=80/tcp --permanent[防火墙的规则]
    firewall-cmd --reload[重新加载防火墙]
************************************************************************************************    
    
    在安装好php之后,对Apache进行配置
    vim /usr/local/httpd/conf/httpd.conf
    在53行添加:AddType application/x-httpd.php .php
    在169行 添加 index.php
    service httpd graceful
==========================================================================================================================
2.mysql搭建
    mysql安装前的准备:
    yum -y install ncurses-devel cmake[安装必须的插件]
    useradd -s /sbin/nologin mysql -M[创建指定mysql用户]
    tar zxf mysql-5.5.38.tar.gz [包的解压]    
    cd  mysql-5.5.38/[进入解压后的目录]
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
    make -j 4 && make install[编译安装]    
    cd /usr/local/mysql
    cd support-files/
    vim my-default.cnf(编辑配置文件内容太少)
    重新配置文件:在/etc/my.cnf重写完整的配置文件
[client]
port = 3306
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
[mysqld]
##########################
## summary
###########################
bind-address = 0.0.0.0
port = 3306
basedir=/usr/local/mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
tmpdir = /tmp
pid-file=/tmp/mysqld.pid
skip-grant-tables
skip-networking

explicit_defaults_for_timestamp=1
lower_case_table_names=1

table_open_cache = 8000
connect_timeout = 20
wait_timeout = 86400
max_connections = 2000
max_user_connections = 1900
max_connect_errors = 100000
max_allowed_packet = 1G
character-set-server = utf8mb4
collation-server = utf8mb4_bin
server-id = 1
log_bin = mysql-bin
binlog_format = MIXED
sync_binlog = 1
expire_logs_days =7
binlog_cache_size = 128m
max_binlog_cache_size =512m
max_binlog_size =256M

binlog_ignore_db=mysql
binlog_ignore_db=information_schema
binlog_ignore_db=performation_schema
binlog_ignore_db=sys
relay_log = mysql-relay-bin
relay_log_purge = on
relay_log_recovery = on
max_relay_log_size = 1G
log_error=/var/log/mysqld_error.log
slow_query_log = on
slow_query_log_file = /var/log/mysqld_slow.log
long_query_time = 2
log_queries_not_using_indexes = on
general_log = on
general_log_file = /var/log/mysqld_gener.log
innodb_file_per_table=1
innodb_log_file_size=1024M
innodb_log_buffer_size=64M

    
    chown -R mysql:mysql /usr/local/mysql/[用户权限调整]
    chown -R mysql:mysql /data/mysql/[数据权限调整]
    初始化数据库:
    /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
    echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile[环境变量的配置]
    . /etc/profile[执行生效文件这个文件]
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld[添加服务配置文件]
    cp support-files/my-medium.cnf  /etc/my.cnf[配置文件]、
    chmod +x /etc/init.d/mysqld [执行权限调整]
    chkconfig --add mysqld
    chkconfig  mysqld on
    chkconfig  mysqld start
    service  mysqld start
    netstat -anlpt | grep mysqld
=============================================================================
3.php的搭建    
    tar zxf php-5.5.35.tar.gz [解压PHP安装包]
    cd php-5.5.35/[进入解压后的目录]
    yum install -y libxml2-devel
    ./configure  --prefix=/usr/local/php --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm
   make -j 4 && make install[编译和安装]
   cp php.ini-production  /usr/local/php/php.ini[配置文件]
编辑创建一个PHP测试文件:
vim /usr/local/httpd/htdocs/index.php
<php
phpinfo();
?>  

 
yum -y install zlib-devel libxml2-devel libpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel
======================================================================================
搭建bbs论坛:
  tar zxf Discuz_7.0.0_FULL_SC_UTF8.zip (上传)
  unzip Discuz_7.0.0_FULL_SC_UTF8.zip  -d discuz(解压)
  mysql
  进入数据库后:
  创建discuz数据库,然后将数据库的所有权限给用户
  grant all on discuz.* to admin@localhost identified by '123456';
 
  systemctl start mysql
  cd discuz/(安装discuz)
  mv upload/ /usr/local/httpd/htdocs/bbs(将upload目录移动到bbs目录下)
  cd /usr/local/httpd/htdocs/bbs/
  chowm -R daemon config.inc.php attachments/ forumdata/ uc_client/data/cache/ templates/
  通过外部网页的形式安装bbs
  vim /usr/local/php/php.ini
  修改:short_open_tag=on
  service httpd restart
  同意之后无法写入:
  chmod 777 -R /usr/local/httpd/htdocs/bbs/*
  service httpd restart
 ==========================================================================================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值