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 ...
随机推荐
- 【iCore4 双核心板_ARM】例程三十四:U_DISK_IAP_ARM实验——更新升级STM32
实验现象及操作说明: 1.本例程共有两个代码包,APP和IAP,IAP程序功能实现将APP程序升级至STM32中. 2.直接上电或烧写程序将执行升级的APP应用程序. 3.按下按键上电或写程序将进行升 ...
- 优化实现Mobile/Bumped Diffuse
在上一篇帖子的基础上增加一张法线贴图即可: Shader "James/Scene/Bumped_Diffuse" { Properties { _MainTex ("B ...
- nohup.out文件过大解决方法 定时任务清空
0.1和2分别表示标准输入.标准输出和标准错误信息输出,可以用来指定需要重定向的标准输入或输出. 在一般使用时,默认的是标准输出,既1.当我们需要特殊用途时,可以使用其他标号.例如,将某个程序的错误信 ...
- UE4/Unity3d 根据元数据自动生成与更新UI
大家可能发现一些大佬讲UE4,首先都会讲类型系统,知道UE4会根据宏标记生成一些特定的内容,UE4几乎所有高级功能都离不开这些内容,一般来说,我们不会直接去使用它. 今天这个Demo内容希望能加深大家 ...
- vs2017离线安装且安装包不占用C盘空间
[参考]vs2017离线安装且安装包不占用C盘空间 第一步:下载离线安装包 https://www.visualstudio.com/zh-hans/downloads/ 在官方地址下载vs_prof ...
- java web (sevlet)请求之get,post,forward,redirect
[参考]web请求之get,post,forward,redirect 1,form表单:可以采用post或者get请求,客户端主动跳转,url地址会改变为提交后的地址 2,forward:forwa ...
- org.hibernate.InvalidMappingException: Could not parse mapping document from无法创建sessionFactory
把 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" 改为 "http://hibernate.sourc ...
- phpmyadmin 上传超过50m限制
sql文件太大(达到400m),导致无法正常导入.需要修改php,nginx的配置文件 php.ini配置 post_max_size = 500M upload_max_filesize = 500 ...
- springboot-aop面向切面编程
需求: 项目中需要记录用户操作信息,例如用户登陆系统后做了那些操作,需要有具体的日志记录. 解决办法: 1.编写操作记录日志业务类,在使用的方法中调用(一般记录方式). 2.使用面向切面方式记录日志, ...
- 在windows上搭建SSH服务踩过的坑
前两天安装了windows操作系统,想在windows上做内网穿透,所以就想在windows下启用ssh服务,今天就来讲一下我在搭建ssh服务中遇到的坑. 我显示在Mac下搭建了ssh服务,并且测试通 ...