您的位置:首页 > 运维架构 > Linux

centos7安装配置lnmp

2015-11-03 16:42 555 查看
yum install nginx mariadb-server mariadb php php-mysql php-fpm
systemctl start nginx
systemctl enable nginx
nano /etc/php.ini
cgi.fix_pathinfo=0
nano /etc/php-fpm.d/www.conf
user = nginx
group = nginx
systemctl start php-fpm
systemctl enable php-fpm
nano /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;

location / {
root /opt/www;
index index.php index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /opt/www;
}

location ~ \.php$ {
root /opt/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
vi nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
}
systemctl restart nginx

#在不停止Nginx服务的情况下平滑变更Nginx配置
1.修改/etc/nginx/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确:
whereis nginx
/usr/sbin/nginx -t
如果屏幕显示以下两行信息,说明配置文件正确:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
2.输入以下命令查看Nginx主进程号:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
屏幕显示的即为Nginx主进程号,例如:
6302
这时,执行以下命令即可使修改过的Nginx配置文件生效:
kill -HUP 6302
或者无需这么麻烦,找到Nginx的Pid文件:
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`

systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb.service

1.centos7 yum安装phpMyAdmin
yum install phpmyadmin
yum install php-mcrypt
vi /etc/phpMyAdmin/config.inc.php(默认,暂时不用修改)
vi /etc/httpd/conf.d/phpMyAdmin.conf(注意使用rpm -qa|grep httpd查看apache版本是不是2.4)
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require all granted
Require ip IP
</RequireAny>
</IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require all granted
Require ip IP
</RequireAny>
</IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/libraries/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/lib/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>

<Directory /usr/share/phpMyAdmin/setup/frames/>
Order Deny,Allow
Deny from All
Allow from None
</Directory>
浏览器http://IP:端口号/phpmyadmin/(登录账号使用mysql的账户密码)

2.centos7 yum安装svnmanager
yum install php-pear
pear list(查看PEAR版本)
pear upgrade PEAR(更新PEAR版本)
pear install channel://pear.php.net/VersionControl_SVN-0.5.2
wget http://prdownloads.sourceforge.net/svnmanager/svnmanager-1.09.tar.gz tar -zxvf svnmanager-1.09.tar.gz -C /var/www/html
cd /var/www/html
mv svnmanager-1.09 svnmanager
cp config.php.linux config.php

mysql -u root -p
create database svn;
grant all on svn.* to guowang@localhost identified by "123456";
flush privileges;
\q

vi /etc/httpd/conf.d/svnmanager.conf<Directory "/var/www/html/svnmanager/"> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from all</Directory>

cd /opt/svn
touch passwd authz
vi config.php
$svn_config_dir="/tmp";
$svn_repos_loc="/opt/svn";
$svn_passwd_file="/opt/svn/passwd";
$svn_access_file="/opt/svn/authz";
$dsn="mysqli://guowang:123456@localhost/svn";

浏览器输入http://IP:端口号/svnmanager/即可
报错1:
测试创建库时报错:fopen(/opt/svn/shop/conf/authz): failed to open stream: Permission denied (@line 207 in file /var/www/html/svnmanager/svnmanager/library/class.accessfile.php
vi /var/www/html/svnmanager/svnmanager/library/class.accessfile.php(发现没有W权限)
解决1:chmod 666 authz

报错2:
编辑库用户组时报错:PHP Fatal error: Class 'PEAR_ErrorStack' not found in /var/www/html/svnmanager/svnmanager/RepositoryModule/UserPrivilegesEditPage.php on line 203
vi UserPrivilegesEditPage.php(发现pear指向错误)
find / -name SVN.php
解决2:
pear uninstall VersionControl_SVN-0.5.0
pear install PEAR-1.9.4
pear install VersionControl_SVN-0.4.0(按照网上方法这样做任然没有解决问题,报错如下)
报错3
svn: E180001: Unable to open repository 'file:///opt/svn/app' (cmd: /usr/bin/svn list --config-dir /opt/svn --non-interactive 'file:///opt/svn/app')
Command used: /usr/bin/svn list --config-dir /opt/svn --non-interactive 'file:///opt/svn/app'
解决3:
pear install VersionControl_SVN-0.4.0(0.5.2换成0.4.0)
chmod 777 /opt/svn(可以看见权限和属主都和以前的root不一样)
报错4:
[authz_svn:error] [pid 9649]
[auth_basic:error] [pid 9653]
解决4:
chown -R apache.apache /opt/svn/accessfile
chown -R apache.apache /opt/svn/passwdfile
2.2svn文件同步到web服务器,即同步到apache的根目录,每一秒同步一次
# vi /opt/wc/web.sh

#!/bin/bash
step=2
for (( i = 0; i < 60; i=(i+step) )); do
svn checkout http://110.120.130.140:1111/svn/web/ /var/www/html/web/
sleep $step
done
exit 0
# crontab -e
* * * * * /opt/wc/web.sh

3.centos7 yum安装memadmin
tar -zxvf memadmin-1.0.12.tar.gz
cp -R memadmin /var/www/html
vi /etc/httpd/conf.d/memadmin.conf
<Directory "/var/www/html/memadmin">
Options FollowSymLinks(Indexes表示当前目录没有index.html就显示目录结构)
AllowOverride None (none表示服务器将忽略.htacess文件)
Order deny,allow (进行WEB访问先后顺序deny和allow对应下一行权限控制)
Deny from all
Allow from all
</Directory>
systemctl restart httpd

vi /var/www/html/memadmin/config.php

$config['user'] = "管理员账号"; // your username
$config['passwd'] = "管理员密码"; // your password
浏览器输入:http://IP:端口/memadmin即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php mysql nginx lnmp