PHP on CentOS (LAMP) and wordpress
http://php.net/manual/zh/install.windows.php
https://www.unixmen.com/install-wordpress-centos-7-linux/ (Very useful)
https://www.howtoforge.com/apache_php_mysql_on_centos_7_lamp (Very useful)
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-centos-7
https://www.tipsandtricks-hq.com/how-to-uninstall-and-reinstall-wordpress-245 (update wp-config.php and then go to wp-admin/install.php page)
https://codex.wordpress.org/Using_Themes#Get_New_Themes
https://www.tipsandtricks-hq.com/how-to-fix-the-unable-to-create-directory-error-in-wordpress-5264 (this happend, and might also related to faliure to install themes online)
https://httpd.apache.org/docs/2.2/vhosts/examples.html
下载中文版: https://cn.wordpress.org/
To check whether PHP got installed on your machine:
# rmp -qa | grep -i php (looks it looking for installed packages containing "php")
Or
# locate php (looks like it's searching files with name containing "php" )
#Install Apache on CentOS
sudo yum -y install httpd sudo systemctl start httpd sudo systemctl enable httpd #Test Apache and use browser to check the default website by apache
sudo systemctl status httpd #installing MySql/MariaDB
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation #install PHP
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl #install Wordpress
sudo yum install zip unzip
sudo wget https://wordpress.org/latest.zip sudo unzip latest.zip
sudo cp -avr wordpress /var/www/html
sudo chmod -R 775 wordpress
sudo chown apache:apache wordpress
Quetions:
PHP configuratioin files?
Apache configuration files?
Answer: /etc/httpd/conf/httpd.conf
How to host multiple websites on apache in centos?
https://www.mysysadmintips.com/linux/servers/586-host-multiple-websites-on-apache-in-centos
This tutorial shows how to setup Apache Virtual Hosts in CentOS 7. This is useful if you want to host more than one website on a single CentOS web server. For instructions on how to setup Apache, PHP, and SQL database on CentOS 7, check this article.
Setup folder structure for your websites
We are going to create 2 folders for each website. The first will hold HTML and other content, second - log files.
/var/www/sites/domain1/html
/var/log/httpd/domain1
/var/www/sites/domain2/html
/var/log/httpd/domain2
/var/www/sites/domain3/html
/var/log/httpd/domain3
Log files will be stored in var/log/httpd/... subfolders, which is the default place to store log files in Linux. People often store Apache log files in /var/www/ subfolders, but in CentOS with SELinux enabled this can cause access denied errors. This can be fixed with chcon command, but I prefer to store all my log files in /var/logs...
You can also place index.html files with some sample text in each html directory which we'll use later for testing.
Create folder structure for virtual host files
Create folders:
/etc/httpd/sites-available
/etc/httpd/sites-enabled
sites-available will hold virtual host config files for websites that are configured, but not necessary enabled. These files are actually ignored when Apache starts, but this system allows to easily disable and enable websites without having to delete or create new virtual host files every time we want to take a site offline and put it back online.
sites-enabled will hold symbolic links to virtual host files inside sites-available that are enabled. They will be loaded when Apache starts.
Add sites-enabled to Apache config
Open file /etc/httpd/conf/httpd.conf and at the very end of the file add following text:
IncludeOptional sites-enabled/*.conf
This will tell Apache to look for virtual host files with extension .conf in sites-enabled directory.
Create Virtual Host files
In directory /etc/httpd/sites-available create config files for each website (domain1.conf, domain2.conf, etc.) with following content:
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com
DocumentRoot /var/www/sites/domain1/html
ErrorLog /var/log/httpd/domain1/error.log
CustomLog /var/log/httpd/domain1/access.log combined
</VirtualHost>
Change domain1 to match your domain names and directories you created previously.
If Apache can't match the requested domain to any of the virtual hosts, the first (alphabetically) virtual host site will be loaded. If you want to have more control over this, you can create a dedicated virtual host (i.e. 00_default) that will be loaded only when no matching virtual host exist. ServerName and ServerAlias should not match any of your domains (i.e. example.com) The name starts with 00 so that it is always the first virtual hosts alphabetically. The site linked to this default virtual host could show an error message, redirect to another domain, etc.
Edit httpd.conf
Edit the main Apache configuration file /etc/httpd/conf/httpd.conf according to your requirements.
In my particular case, I made following changes:
Set webmaster email address:
ServerAdmin administrator@domain.com
Set main document root:
DocumentRoot "/var/www/sites"
Configure main document root:
<Directory "/var/www/sites">
AllowOverride All
Options FollowSymLinks
</Directory>
AllowOverride All - is required if you intend to use .htaccess files for directory level configuration. By default, this is set to None, in which case .htaccess overrides would be ignored.
Options -Indexes - prevents directory listing.
Enable Virtual Hosts
To enable websites, we need to create symbolic links in /etc/httpd/sites-enabled pointing to appropriate config files in sites-available. To do this, run:
ln -s /etc/httpd/sites-available/domain1.conf /etc/httpd/sites-enabled/domain1.conf
For changes to take effect we need to restart Apache:
systemctl restart httpd.service
To disable a particular website, simply delete relevant symbolic link (or change the extension) and restart Apache.
Before going live, you can test if everything is working locally. To do this, edit the hosts file on your client machine to point domains configured inside virtual hosts to the CentOS web server's IP address. If everything was setup properly, pointing your web browser to one of the domains should load index.html file from an appropriate /var/www/sites/... directory.
2015.01
CentOS 7
以下为最近学习小结:
问题一: 创建新用户并设置密码
解决方案:
创建新用户 adduser <username>
设置密码 passwd <username>
问题二:使用新用户登录,执行 "sudo yum update",没有sudo 权限,得到错误: “<user> is not in the sudoers file. This incident will be reported.”
解决方案:http://www.cnblogs.com/evasnowind/archive/2011/02/04/1949113.html
一、$whereis sudoers -------找出文件所在的位置,默认都是/etc/sudoers
二、 #chmod u+w /etc/sudoers 以超级用户登录su -root ,修改文件权限即添加文件拥有这的写权限 限,ls -al /etc/sudoers 可以查看原文件的权限。
三、vim /etc/sudoers 编辑文件,在root ALL=(ALL)ALL行下添加XXX ALL=(ALL)ALL,XXX为你的用户名。添加方法:找到root行,按下”i“键进入编辑模式添加即可!编辑好后esc键进入一般模式,“:wq"保存退出!
最后, #chmod u-w /etc/sudoers 回到文件的原权限!
问题三: 没有安装VIM
解决方案: # yum -y install vim*
操作4: Install MySQL on CentOS-7
https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-7
操作5: 本机登录mysql创建帐户、密码及新的数据库
> mysql -u root
> create user '<username>'@'%';
> SET Password for '<username>'@'%' = Password('mypassword');
此时该用户已经可以远程登录了!
TODO: set password for mysql for root account.
> create database <db-name>;
> grant all privileges on <dbname>.* to '<user>'@'localhost';
> select current_user();
到此,数据库、连接用户名密码已经配置完成!
操作6:尝试直接使用IP或域名访问此服务器
[slin@iZwz9h33t7dnsizrtbp8yhZ www]$ wget http://www.linsw.com
--2017-06-14 10:52:14-- http://www.linsw.com/
Resolving www.linsw.com (www.linsw.com)... 120.77.38.243
Connecting to www.linsw.com (www.linsw.com)|120.77.38.243|:80... failed: Connection refused.
操作6-1: 尝试安装nodejs, 分别使用80与非80端口,来看一下服务器上的nodejs能否正常工作
> sudo yum install nodejs
准备以下内容给 nodetest /index.js文件:
var port = (process.env.port || 8080);
if (process.argv.length > 2) {
for (var i = 2; i < process.argv.length; i++) {
console.log(process.argv[i]);
var m = /port=(\d+)/.exec(process.argv[i]);
if (m) {
port = m[1];
}
}
}
var http = require('http');
var server = http.createServer(function(req, res, next){
console.log('got request:' + req.url);
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('hello world from shawn. NodeJS');
});
/*server.on('listen', function(){
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
console.log(bind);
});
*/
var port = 80;
server.listen(port);
server.on('error', function(err){
console.log(err);
});
console.log('server is listening on port: ' + port);
> sudo nodejs ~/www/nodetest/index.js
说明機器上沒有别的进程在使用80端口;那接下来应该需要安装apache httpd服务。
操作7:安装apache, php
http://www.cnblogs.com/swlin/p/PHP.html
> sudo yum -y install httpd
> sudo systemctl enable httpd
> sudo systemctl start httpd
至此,httpd服务成功安装,并可以通过域名成功访问,并显示一个默认的测试页面。
> sudo systemctl status httpd
操作7-2:
#install PHP
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl
#install Wordpress
sudo yum install zip unzip
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo mkdir /var/www/websites/
sudo cp -avr wordpress /var/www/websites/mywebsite
sudo chmod -R 775 mywebsite
sudo chown apache:apache mywebsite
操作8: rewrite module
打开httpd.conf(在那里? APACHE目录的CONF目录里面),用文本编纂器打开后,查找
(1)
Options FollowSymLinks
AllowOverride None
改为
Options FollowSymLinks
AllowOverride All
(2)去掉下面的注释
LoadModule rewrite_module modules/mod_rewrite.so
(3) 修改文件 /etc/httpd/virutal_hosts/<your-host-file>.conf,在<VirtualHost *:80>节点里面增加如下内容
<Directory /var/www/websites/dev_gmpflex_com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
操作9:解决wordpress安装主题时一直提示需要FTP用户名及密码,其它完全不需要安装 FTP SERVER的:
解决方案:
http://jingyan.baidu.com/article/4f34706efc1237e387b56da4.html
第一,如果我们安装的是lnmp一键安装包,那可以使用。授权组来解决。
chown -R 775 /home/wwwroot/my-website-name(修改成网站域名目录)
第二,如果是其他的可以使用在wp-config.php文件中添加脚本方式。
define("FS_METHOD","direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
上述脚本添加到文件最后面就可以。
但是,之后我又遇到问题: 安装失败,无法创建目录。
操作9-1: chmod -R 777 /var/www/ (这个搞定问题,但不知道直接到本人使用的/var/www/websites/行不行?)
=================
centos new user: slin/ABcd1234
如果您的.htaccess文件可写,我们即会自动帮您完成,但其目前不可写,所以以下是您需要加入您的.htaccess文件中的mod_rewrite规则。点击文本框并按CTRL + a来全选。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
http://blog.sina.com.cn/s/blog_6452c6b40100qr7m.html
PHP on CentOS (LAMP) and wordpress的更多相关文章
- centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节课
centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节 ...
- Centos 7使用docker部署LAMP搭建wordpress博客系统
0.简要概述 LAMP是目前比较流行的web框架,即Linux+Apache+Mysql+PHP的网站架构方案.docker是目前非常流行的虚拟化应用容器,可以为任何应用创建一个轻量级.可移植的容器. ...
- LAMP 搭建wordpress部署教程贴.
LAMP 搭建wordpress部署教程贴.这是一篇主要将LAMP,并且通过wordpress来进行验证,演示.如何去部署PHP CMS很多新手看到LAMP就很很头大,觉得很难搞,编译安装,搞了好几天 ...
- LAMP 建立 Wordpress 站点 Linux Apache MariaDB PHP
使用LAMP建立Wordpress, 要求如下: 准备工作: VMware 14 CentOS 7.4 最小化 安装镜像 Wordpress 安装包, 下载 预热: 使用VMware新建4台虚拟机, ...
- 于CentOS 6 安装 Wordpress
1.两种方式给Wordpress 首先,你可以去wordpress最新的官方网站看看wordpress多少下载.例wordpress 3.9.1下载地址: http://cn.wordpress.or ...
- LVS之-LAMP搭建wordpress
author:JevonWei 版权声明:原创作品 LVS搭建wordpress,涉及的知识点有DNS,LAMP,NFS及LVS 网络拓扑图 网络环境 NFS 192.168.198.130 mysq ...
- 【简书】在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目
在阿里云自带的CentOS + LAMP环境下部署一个Laravel项目 作者 DonnieZero 关注 2017.07.29 22:02* 字数 2218 阅读 5556评论 3喜欢 1赞赏 1 ...
- 实战!基于lamp安装wordpress详解-技术流ken
简介 LAMP 是Linux Apache MySQL PHP的简写,其实就是把Apache, MySQL以及PHP安装在Linux系统上,组成一个环境来运行动态的脚本文件.现在基于lamp搭建wor ...
- centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课
centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课 mysq ...
随机推荐
- Spring-boot之 rabbitmq
今天学习了下spring-boot接入rabbitmq. windows下的安装:https://www.cnblogs.com/ericli-ericli/p/5902270.html 使用博客:h ...
- spring boot 项目启动无任何反应
遇到的问题 spring boot项目启动后无任何报错,ps有进程,nohub无日志 定位 更换jar包,问题依然存在,将jar包放到其他服务器,运行正常,排除打包问题 同服务器其他系统运行正常,但停 ...
- 在github上搭建个人博客
1.平台注册账号,新建域名 github(源码托管服务站):https://github.com/到GitHub官网,注册自己的账号,填好用户名,密码,邮箱,并完成邮箱验证就可以啦!默认的域名是htt ...
- windows下IDEA的terminal配置bash命令
使用git-bash.exe会单独打开一个窗口,而我们希望是在终端内置的命令行.这里我使用bash.exe 在IDEA中,打开settings,设置相应的bash路径 settings–>Too ...
- odoo:开源 ERP/CRM 入门与实践 -- 上海嘉冰信息技术公司提供咨询服务
odoo:开源 ERP/CRM 入门与实践 看了这张图,或许你对odoo有了一些兴趣. 这次Chat就是和大家一起交流开源ERP/CRM系统:odoo 对以下读者有帮助:研发.产品.项目.市场.服务. ...
- springboot项目使用拦截器修改/添加前端传输到后台header和cookie参数
本质上来讲,request请求当中的参数是无法更改的,也不能添加或者删除. 但在后台程序中,一般对request的参数的操作,都是通过request的getParameter.getParameter ...
- TIJ -- CountDownLatch
1. 2. Class : CountDownLatchDemo package lime.thinkingInJava._021._007._001; import java.sql.Time; i ...
- C++将时间格式转换成秒数
#include <stdio.h> #include <time.h> #include <string.h> #include <stdlib.h> ...
- threding模块的其他用法
import threading import time def func(n): time.sleep(0.5) n += 1 print(n, threading.current_thread() ...
- gym 101873
题还没补完 以下是牢骚:删了 现在只有六个...太恐怖了,我发现四星场我连300人的题都不会啊. C:最短路加一维状态就好了叭..嗯,一开始没看到输出的那句话 那个 "."也要输 ...