阿里云服务器运维记录

    常用命令:

   关闭防火墙:  systemctl stop firewalld.service
   开机禁用防火墙:systemctl disable firewalld.service
一、创建用户
useradd testuser 创建用户testuser
passwd testuser 给已创建的用户testuser设置密码
usermod –help修改用户这个命令的相关参数
userdel testuser 删除用户testuser
添加的用户信息在文件 /etc/passwd 文件中
二、给用户添加sudo权限
  添加文件的写权限。也就是输入命令”chmod u+w /etc/sudoers”
编辑/etc/sudoers文件,进入编辑模式,找到这一 行:”root ALL=(ALL) ALL”在起下面添加”xxx ALL=(ALL) ALL”(这里的xxx是你的用户名)
撤销文件的写权限。也就是输入命令”chmod u-w /etc/sudoers”。
三、安装apache
下载httpd-2.2.6.tar.bz2  把httpd-2.2.6.tar.bz2放到/soft 下
如果下载支持php的apache,需要在php的网站下载apache
tar jxvf httpd-2.2.6.tar.bz2
./configure  –prefix=/usr/local/apache   –enable-module=so   //  配置apache路径,支持php
make     //编译apache
make install    //安装apache
cd /usr/local/apache   //进入apache的目录
cp -a httpd.conf httpd.conf-     //备份conf目录下的 apache配置文件
1.解决apr not found问题
APR和APR-UTIL的下载地址:http://apr.apache.org/download.cgi
tar -zxf apr-1.4.5.tar.gz
./configure –prefix=/usr/local/apr
make
make install
2.解决APR-util not found问题>>>>
tar -zxf apr-util-1.3.12.tar.gz
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/bin/apr-1-config
make
make install
 3  ../configure仍提示APR-util not found,增加–with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util后出现
#./configure –help | grep pcre
–with-pcre=PATH        Use external PCRE library下载:http://sourceforge.net/projects/pcre
下载地址二:http://ftp.exim.llorien.org/pcre/
#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure –prefix=/usr/local/pcre
#make
#make install
You need a C++ compiler for C++ support  解决办法
yum install -y gcc gcc-c++
4.编译Apache
./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre  –enable-module=so
安装64位 2.2 –enable-lib64 \
    -libdir=/usr/lib64 \
make
make install
在modules目录中只有httpd.exp,解决办法,添加如下编译标志
–enable-mods-shared=’headers rewrite dav’ (凡是你想编译的模块都可以写到后边的引号里面,以空格分隔)
–enable-mods-shared=most (编译最多的模块)
–enable-mods-shared=all (编译所有模块)
遇到的问题:
通过编译./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –with-pcre=/usr/local/pcre  –enable-module=so  –enable-mods-shared=most
发现启动时候总报错,Invalid command ‘Order’  Invalid command ‘AddType’错误,多方查找,最后编译参数更改为:
./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/  –enable-so
终于正常启动
5.apache部署与配置
启动服务 service httpd start        //启动服务
service httpd restart -k granceful 重启
新添加配置
修改文件  httpd.conf
ServerName localhost:80
  AddType application/x-httpd-php .php
LoadModule php5_module “D:/install/php-5.3.28/php5apache2_2.dll” (windows下)
//PHPIniDir “D:/install/php-5.3.28” (windows下)
Include conf/include/*.conf
apache 支持php  LoadModule php5_module  modules/libphp5.so
–prefix=/usr/local/apache2(目录名称一定要用apache2)
**********直接删除目录后  无法找到配置文件  chkconfig –level 2345 httpd off
6.apache stop时候报错
killall -9 httpd
        7. 遇到的问题及解决办法
Invalid command RewriteEngine解决方法:
LoadModule rewrite_module modules/mod_rewrite.so
Apache启动错误:Invalid command ‘Order’
LoadModule authz_host_module modules/mod_authz_host.so
403错误,没有访问权限,需要修改  Allow from all
报错_default_ VirtualHost overlap on port 80, the first has precedence
去掉#NameVirtualHost *:80前面的#号  或者添加
如果还是forbidden,检查一下目录的访问权限
2014-05-12 最后的配置
ServerName localhost:80
NameVirtualHost *:80
AddType application/x-httpd-php .php
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadFile   /usr/local/libxml2/lib/libxml2.so
LoadModule mime_module  modules/mod_mime.so
LoadModule php5_module        modules/libphp5.so
LoadModule autoindex_module /usr/lib64/httpd/modules/mod_autoindex.so
LoadModule dir_module  modules/mod_dir.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule log_config_module  /usr/lib64/httpd/modules/mod_log_config.so
LoadModule setenvif_module /etc/httpd/modules/mod_setenvif.so
LoadModule logio_module   /usr/lib64/httpd/modules/mod_logio.so
Include “conf/include/*.conf”
四、安装php
php yum 源
CentOs 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
1.获取安装文件: http://www.php.net/downloads.php  php-5.3.8.tar.gz
获取安装php需要的支持文件:http://download.csdn.net/download/netlong339/1351852     libxml2-2.6.32.tar.gz
http://xmlsoft.org/ ftp://xmlsoft.org/libxml2/
tar zxvf libxml2-2.6.32.tar.gz
cd libxml2-2.6.32
./configure –prefix=/usr/local/libxml2
make
make install
安装php
./configure \
–prefix=/usr/local/php \
–with-mysql=/usr/local/mysql \
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-libxml-dir=/usr/local/libxml2
#make
#make install
如果出现  MySQL client library is not bundled anymore!   解决办法   –with-mysql=mysqlnd (这种办法不知道什么意思) 或者  –with-mysql=/usr/lib64/mysql
安装php的时候,报错如下:
                     Configure: error: Please reinstall the BZip2 distribution
          解决方法如下:
             #yum install bzip2 bzip2-devel
Please reinstall the libcurl distribution
  解决办法:
yum -y install curl-devel
configure: error: jpeglib.h not found.
   解决办法:
yum -y  install libjpeg-dev
configure: error: png.h not found.
    解决办法:
 yum install libpng-devel
configure: error: Cannot find libmysqlclient under /usr 解决
     解决办法:
ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 libmysqlclient.so (默认是在lib路径在找,需要建立软连接)
我安装成功使用的编译参数为:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-libxml-dir=/usr/local/libxml2 –with-gd –with-openssl –enable-gd-native-ttf –with-jpeg-dir –with-png-dir –with-zlib –with-gettext –with-curl  –with-iconv –with-bz2 –enable-soap -enable-sockets –enable-mbstring=all –enable-ftp –with-mysql=mysqlnd–with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-freetype-dir=/usr/include/freetype2/
关于php mysql驱动问题,一直提示找不到驱动,在网上找,说要添加如下编译参数,不编译mysql
编译参数:
–with-mysql=mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
mysqlnd是php5.3以后版本加入的,5.3以下版本必须还是要编译mysql。
php.ini配置问题:
date.timezone=PRC  解决date报错问题
用yum安装  #yum -y install php
安装php的相关组件
yum search php (搜索php相关的组件)
yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
  2016-12-7: 添加gd,freetype安装
1,下载libpng (http://www.libpng.org/), libjpeg(http://www.ijg.org/files/  ),gd 安装包 (http://www.libgd.org/Main_Page)
2. 安装jpeg   ./configure –prefix=/usr/local/jpeg –enable-shared  –enable-static
libtool错误,cp /usr/share/libtool/config/config.guess .
    cp /usr/share/libtool/config/config.sub .
     make clean  后重新编译
/usr/bin/install: cannot create regular file `/usr/local/jpeg/include/jconfig.h’: No such file or directory, 解决办法
mkdir -p /usr/local/jpeg/include
                        mkdir -p /usr/local/jpeg/lib
                        mkdir -p /usr/local/jpeg/bin
                        mkdir -p /usr/local/jpeg/man/man1
3. 安装libpng./configure –prefix=/usr/local/png
4. 安装gd  ./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/jpeg –with-png=/usr/local/png –with-freetype=/usr/local/freetype
./configure –prefix=/usr/local/php \
      –with-config-file-path=/usr/local/php/etc\
              –with-apxs2=/usr/local/apache2/bin/apxs \
              –with-libxml-dir=/usr/local/libxml2 \
             –with-openssl \
             –enable-gd-native-ttf \
             –with-jpeg-dir=/usr/local/jpeg\
             –with-png-dir=/usr/local/png\
             –with-freetype-dir=/usr/local/freetype\
             –with-gd=/usr/local/gd2\
             –with-zlib \
             –with-gettext \
             –with-curl  \
             –with-iconv \
             –with-bz2 \
             –enable-soap \
             –enable-sockets \
             –enable-mbstring=all \
             –enable-ftp \
             –with-mysql  \
    –with-pdo-mysql=mysqlnd \
    –enable-pdo \
    –enable-fpm
五、安装mysql
yum安装mysql
1.检查是否有安装过
yum list installed mysql*
rpm -qa | grep mysql*
查看有没有安装包:
          yum list mysql*
2.安装mysql客户端:yum install mysql
3. 安装mysql 服务器端:yum install mysql-server
yum install mysql-devel
4. 启动&&停止:
数据库字符集设置
mysql配置文件/etc/my.cnf中加入default-character-set=utf8
启动mysql服务:
service mysqld start或者/etc/init.d/mysqld start
开机启动:
chkconfig -add mysqld,查看开机启动设置是否成功chkconfig –list | grep mysql*
关闭:
service mysqld stop
5.登陆
创建root管理员:   mysqladmin -u root password 123456
登录:mysql -u root -p输入密码即可。
忘记密码: service mysqld stop
 mysqld_safe –user=root –skip-grant-tables
mysql -u root
use mysql
update user set password=password(“new_pass”) where user=”root”;
flush privileges;
6. 远程访问
开放防火墙的端口号
mysql增加权限:mysql库中的user表新增一条记录host为“%”,user为“root”。
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’WITH GRANT OPTION
增加其他host的访问权限:
create user unionapp identified by ‘unionapp’;
grant all privileges on unionapp.* to ‘unionapp’@’%’ with grant option;
flush privileges;
7,重要目录
数据库目录
          /var/lib/mysql/
配置文件
        /usr/share /mysql(mysql.server命令及配置文件)
相关命令
          /usr/bin(mysqladmin mysqldump等命令)
启动脚本
         /etc/rc.d/init.d/(启动脚本文件mysql的目录)
或者直接取下载  rpm安装包 rpm -ivh MySQL-server-community-5.1.25-0.rhel5.i386.rpm MySQL-client-community-5.1.25-0.rhel5.i386.rpm
8,设置root用户密码
mysql -u root -p
输入密码  daidai&81…
目前db用户:forum : f1o2r3u4m5
    wordpress :  wordpress1119…
创建用户和数据库,并授予用户数据库操作权限
create database ihelpuDB;
insert into mysql.user (Host, User, Password) values (‘localhost’,’ihelpu’, password(‘ihelpudaidai’));
FLUSH PRIVILEGES;
grant all privileges on ihelpuDB.* to ihelpu@localhost identified by ‘ihelpudaidai’;
授予部分权限 grant select,update on  。。。。。。。select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
9. 设置客户端登陆用户
在配置文件中添加如下内容
[client]
user = ihelpu
password = dddaaaxxx
六、Linux系统手动安装rzsz 软件包
https://ohse.de/uwe/software/lrzsz.html
wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz下载。
解压 tar zxvf  rzsz-3.34.tar.gz
make posix
cp rz sz  /usr/bin/
设置环境变量 export  RZSZLINE=/dev/modem
七、Linux下SVN安装配置
http://subversion.apache.org/download/#recommended-release
http://subversion.tigris.org/
$ yum install subversion
$ yum install mod_dav_svn
svnserve –version 检查是否安装成功
建立版本库目录(可建立多个,新建库后以下各项都需重新配置。注意区别安装目录与版本库目录,以下讲的都是版本库目录)
mkdir –p /opt/svndata/repos
建立svn版本库(与上面目录对应)
svnadmin create /opt/svndata/repos  执行此命令后svn自动在repos目录下添加必须的配置文件.
修改版本库配置文件
vi /opt/svndata/repos/conf/svnserve.conf
[general]
anon-access = none # 使非授权用户无法访问
auth-access = write # 使授权用户有写权限
password-db = /opt/svndata/repos/conf/pwd.conf # 指明密码文件路径
authz-db = /opt/svndata/repos/conf/authz.conf # 访问控制文件
realm = /opt/svndata/repos # 认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字。
其它采用默认配置. 各语句都必须顶格写, 左侧不能留空格, 否则会出错.
其中pwd.conf 与 authz.conf 在新建版本库时系统不会自动创建,需要自己创建。
指令简介:这是svn配置文件的格式,请按照以上格式书写。
配置用户
vi /opt/svndata/repos/conf/pwd.conf
输入以下内容:
[users]
username1 = password1
username2 = password2
可以添加多个,此为用户名密码对。
配置权限
vi /opt/svndata/repos/conf/authz.conf
指令简介:此配置文件采用“基于路径的授权”策略,中括号里指定路径,以下列出对各用户的授权。包括只读r,读写rw。没有列出的用户,则不允许访问。还可以对用户分组,具体请参考svn手册,以下是简单例子:
[/opt/svndata/repos]
user1 = rw
user2 = r
我的配置
[/]      相当于启动时候的根目录   /opt/svndata/
guomei = rw
[repos:/]   相当于目录   /opt/svndata/repos
guomei = rw
[repos:/lixiaoyun]
lixiaoyun = rw
启动服务
killall svnserve
svnserve -d -r /opt/svndata/  启动服务, 以deamon方式运行(输入路径为跟目录)
创建guomei目录
svn mkdir file:///opt/svndata/repos/guomei/ihelpu -m “create ihelpu”
八, yum安装Apahce, PHP, Mysql, 以及php连接mysql库组件。
yum -y install httpd php mysql mysql-server php-mysql
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
九、eclipse安装svn插件
help-》安装新软件,输入网址, select all ,next 重启eclipse
http://subclipse.tigris.org/update_1.0.x
十、安装openfire
首先下载OpenFire的Linux安装包,下载地址http://www.igniterealtime.org/downloads/index.jsp#openfire;
tar -zxvf 报名
安装java,安装后在/etc/profile后面添加配置如下:
                JAVA_HOME=/usr/java/jdk1.5.0_16;export JAVA_HOME
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
启动OpenFire   # /etc/init.d/openfire
输入http:http://your.ip:9090/,进入配置页面
               域:服务器ip
      使用标准数据库连接,数据库驱动选择mysqlJDBC驱动程序类为:com.mysql.jdbc.Driver数据库URL:jdbc:mysql://IP:3306/openfire(其中IP为服务器端IP)用户名:openfire密码:123456
openfire 为数据库
  特性设置:默认为初使设置
               管理员帐户: 密码 daidai
Openfire管理控制台  在ofuser表,将admin的plainPassword设置为123456, encryptedPassword设置为空。再用admin登陆,密码为:123456,即可登陆。
  实现php增加用户
http://www.igniterealtime.org/projects/openfire/plugins.jsp下载插件User Service,实现php同步用户
                拷贝userservice.jar 文件到plugins目录
  进入管理界面设置   服务器-》服务器设置-》User Service  添加用户 http://www.igniterealtime.org/projects/openfire/plugins/userservice/readme.html
参考  http://www.igniterealtime.org/projects/openfire/plugins/userservice/readme.html
下载:http://www.igniterealtime.org/downloads/index.jsp
                asmack包  http://asmack.freakempire.de/
十一: 安装Nginx
   http://www.cnblogs.com/skynet/p/4146083.html
   nginx依赖以下模块:  gzip模块需要 zlib 库, rewrite模块需要 pcre 库, ssl 功能需要openssl库
   1.  http://www.pcre.org/    http://www.openssl.org/source/   http://www.zlib.net/
       下载,解压,./configure    make & make install
依赖  yum install -y gcc gcc-c++
   2. 安装nginx  ./configure –prefix=/usr/local/nginx   make & make install
   3. 启动nginx,配置nginx.conf,
      cd /usr/local/nginx/sbin    ./nginx -s reload
      测试: ./nginx -t
      配置 php:
cp php.ini-production /usr/local/php/etc/php.ini  #php配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #php-fpm配置文件
修改php-fpm.conf 文件, 设置pid名称/var/run/php-fpm/php-fpm.pid
      要支持php  启动 /usr/local/php/sbin/php-fpm  start   //新版 /usr/sbin/php-fpm -D
关闭 kill -INT `cat /var/run/php-fpm/php-fpm.pid`
    重启 kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`    service php-fpm stop/start
查看php-fpm进程数: #  ps aux | grep -c php-fpm
查看端口  netstat -ntlp
       注意::添加用户和ssh模块,需要编译时带参数 如:[root@localhost nginx-1.4.4]# ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_stub_status_module –with-http_ssl_module

You May Also Like

About the Author: daidai5771

发表评论

电子邮件地址不会被公开。 必填项已用*标注